Skip to content

Commit 917257d

Browse files
committed
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: [email protected] Fixes: 6c271ce ("io_uring: add submission polling") Signed-off-by: Jens Axboe <[email protected]>
1 parent 0605863 commit 917257d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/io_uring.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,10 +2241,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
22412241
mmgrab(current->mm);
22422242
ctx->sqo_mm = current->mm;
22432243

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-
22482244
ret = -EINVAL;
22492245
if (!cpu_possible(p->sq_thread_cpu))
22502246
goto err;
@@ -2254,10 +2250,18 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
22542250
if (!capable(CAP_SYS_ADMIN))
22552251
goto err;
22562252

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+
22572257
if (p->flags & IORING_SETUP_SQ_AFF) {
22582258
int cpu;
22592259

22602260
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+
22612265
ctx->sqo_thread = kthread_create_on_cpu(io_sq_thread,
22622266
ctx, cpu,
22632267
"io_uring-sq");

0 commit comments

Comments
 (0)