Signed-off-by: Stefan Metzmacher <metze@xxxxxxxxx> --- fs/io_uring.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index cf46b890a36f..320672930d87 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6721,19 +6721,10 @@ static int io_sq_thread(void *data) struct io_sq_data *sqd = data; struct io_ring_ctx *ctx; unsigned long timeout = 0; - char buf[TASK_COMM_LEN]; DEFINE_WAIT(wait); - sprintf(buf, "iou-sqp-%d", sqd->task_pid); - set_task_comm(current, buf); - - if (sqd->sq_cpu != -1) - set_cpus_allowed_ptr(current, cpumask_of(sqd->sq_cpu)); - else - set_cpus_allowed_ptr(current, cpu_online_mask); - current->flags |= PF_NO_SETAFFINITY; - mutex_lock(&sqd->lock); + while (!test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state)) { int ret; bool cap_entries, sqt_spin, needs_sched; @@ -7887,6 +7878,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx, fdput(f); } if (ctx->flags & IORING_SETUP_SQPOLL) { + char tsk_comm[TASK_COMM_LEN]; struct task_struct *tsk; struct io_sq_data *sqd; bool attached; @@ -7943,6 +7935,15 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx, goto err_sqpoll; } + sprintf(tsk_comm, "iou-sqp-%d", sqd->task_pid); + set_task_comm(tsk, tsk_comm); + + if (sqd->sq_cpu != -1) + set_cpus_allowed_ptr(tsk, cpumask_of(sqd->sq_cpu)); + else + set_cpus_allowed_ptr(tsk, cpu_online_mask); + tsk->flags |= PF_NO_SETAFFINITY; + sqd->thread = tsk; ret = io_uring_alloc_task_context(tsk, ctx); wake_up_new_task(tsk); -- 2.25.1