Commit a13030f
io_uring: simplify the SQPOLL thread check when cancelling requests
In io_uring_try_cancel_requests, we check whether sq_data->thread ==
current to determine if the function is called by the SQPOLL thread to do
iopoll when IORING_SETUP_SQPOLL is set. This check can race with the SQPOLL
thread termination.
io_uring_cancel_generic is used in 2 places: io_uring_cancel_generic and
io_ring_exit_work. In io_uring_cancel_generic, we have the information
whether the current is SQPOLL thread already. And the SQPOLL thread never
reaches io_ring_exit_work.
So to avoid the racy check, this commit adds a boolean flag to
io_uring_try_cancel_requests to determine if the caller is SQPOLL thread.
Reported-by: [email protected]
Reported-by: Li Zetao <[email protected]>
Reviewed-by: Li Zetao <[email protected]>
Signed-off-by: Bui Quang Minh <[email protected]>
Reviewed-by: Pavel Begunkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>1 parent 94d5744 commit a13030f
1 file changed
+11
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
2869 | 2870 | | |
2870 | 2871 | | |
2871 | 2872 | | |
2872 | | - | |
| 2873 | + | |
| 2874 | + | |
2873 | 2875 | | |
2874 | 2876 | | |
2875 | 2877 | | |
| |||
3037 | 3039 | | |
3038 | 3040 | | |
3039 | 3041 | | |
3040 | | - | |
| 3042 | + | |
| 3043 | + | |
3041 | 3044 | | |
3042 | 3045 | | |
3043 | 3046 | | |
| |||
3067 | 3070 | | |
3068 | 3071 | | |
3069 | 3072 | | |
3070 | | - | |
| 3073 | + | |
3071 | 3074 | | |
3072 | 3075 | | |
3073 | 3076 | | |
| |||
3140 | 3143 | | |
3141 | 3144 | | |
3142 | 3145 | | |
3143 | | - | |
| 3146 | + | |
| 3147 | + | |
3144 | 3148 | | |
3145 | 3149 | | |
3146 | 3150 | | |
3147 | 3151 | | |
3148 | 3152 | | |
3149 | | - | |
| 3153 | + | |
| 3154 | + | |
3150 | 3155 | | |
3151 | 3156 | | |
3152 | 3157 | | |
| |||
0 commit comments