diff options
| author | Jens Axboe <axboe@kernel.dk> | 2019-04-13 11:28:55 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2019-04-13 21:08:22 -0400 |
| commit | 917257daa0fea7a007102691c0e27d9216a96768 (patch) | |
| tree | b9eb940786c1bc428f79025919777848b2fd6e54 | |
| parent | 06058632464845abb1af91521122fd04dd3daaec (diff) | |
io_uring: only test SQPOLL cpu after we've verified it
We currently call cpu_possible() even if we don't use the CPU. Move the
test under the SQ_AFF branch, which is the only place where we'll use
the value. Do the cpu_possible() test AFTER we've limited it to a max
of NR_CPUS. This avoids triggering the following warning:
WARNING: CPU: 1 PID: 7600 at include/linux/cpumask.h:121 cpu_max_bits_warn
if CONFIG_DEBUG_PER_CPU_MAPS is enabled.
While in there, also move the SQ thread idle period assignment inside
SETUP_SQPOLL, as we don't use it otherwise either.
Reported-by: syzbot+cd714a07c6de2bc34293@syzkaller.appspotmail.com
Fixes: 6c271ce2f1d5 ("io_uring: add submission polling")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
| -rw-r--r-- | fs/io_uring.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index e5008c1b82be..24355e0c47f0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c | |||
| @@ -2241,10 +2241,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx, | |||
| 2241 | mmgrab(current->mm); | 2241 | mmgrab(current->mm); |
| 2242 | ctx->sqo_mm = current->mm; | 2242 | ctx->sqo_mm = current->mm; |
| 2243 | 2243 | ||
| 2244 | ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle); | ||
| 2245 | if (!ctx->sq_thread_idle) | ||
| 2246 | ctx->sq_thread_idle = HZ; | ||
| 2247 | |||
| 2248 | ret = -EINVAL; | 2244 | ret = -EINVAL; |
| 2249 | if (!cpu_possible(p->sq_thread_cpu)) | 2245 | if (!cpu_possible(p->sq_thread_cpu)) |
| 2250 | goto err; | 2246 | goto err; |
| @@ -2254,10 +2250,18 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx, | |||
| 2254 | if (!capable(CAP_SYS_ADMIN)) | 2250 | if (!capable(CAP_SYS_ADMIN)) |
| 2255 | goto err; | 2251 | goto err; |
| 2256 | 2252 | ||
| 2253 | ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle); | ||
| 2254 | if (!ctx->sq_thread_idle) | ||
| 2255 | ctx->sq_thread_idle = HZ; | ||
| 2256 | |||
| 2257 | if (p->flags & IORING_SETUP_SQ_AFF) { | 2257 | if (p->flags & IORING_SETUP_SQ_AFF) { |
| 2258 | int cpu; | 2258 | int cpu; |
| 2259 | 2259 | ||
| 2260 | cpu = array_index_nospec(p->sq_thread_cpu, NR_CPUS); | 2260 | cpu = array_index_nospec(p->sq_thread_cpu, NR_CPUS); |
| 2261 | ret = -EINVAL; | ||
| 2262 | if (!cpu_possible(p->sq_thread_cpu)) | ||
| 2263 | goto err; | ||
| 2264 | |||
| 2261 | ctx->sqo_thread = kthread_create_on_cpu(io_sq_thread, | 2265 | ctx->sqo_thread = kthread_create_on_cpu(io_sq_thread, |
| 2262 | ctx, cpu, | 2266 | ctx, cpu, |
| 2263 | "io_uring-sq"); | 2267 | "io_uring-sq"); |
