From: Stefan Metzmacher <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Cc: Stefan Metzmacher <[email protected]>
Subject: [PATCH v3 4/6] io_uring: complete sq_thread setup before calling wake_up_new_task()
Date: Sun, 25 Apr 2021 01:26:06 +0200 [thread overview]
Message-ID: <d9ef1236abbe13401a7bbc50eb55be7ee15e5483.1619306115.git.metze@samba.org> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Stefan Metzmacher <[email protected]>
---
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 234c4b8a015c..856289b13488 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6781,19 +6781,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);
- snprintf(buf, sizeof(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;
@@ -7888,6 +7879,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;
@@ -7940,6 +7932,15 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
goto err_sqpoll;
}
+ snprintf(tsk_comm, sizeof(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
next prev parent reply other threads:[~2021-04-24 23:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 23:26 [PATCH v3 0/6] Complete setup before calling wake_up_new_task() Stefan Metzmacher
2021-04-24 23:26 ` [PATCH v3 1/6] kernel: always initialize task->pf_io_worker to NULL Stefan Metzmacher
2021-04-24 23:26 ` [PATCH v3 2/6] io_uring: io_sq_thread() no longer needs to reset current->pf_io_worker Stefan Metzmacher
2021-04-24 23:26 ` [PATCH v3 3/6] io-wq: call set_task_comm() before wake_up_new_task() Stefan Metzmacher
2021-04-24 23:26 ` Stefan Metzmacher [this message]
2021-04-24 23:26 ` [PATCH v3 5/6] io-wq: warn about future set_task_comm() overflows Stefan Metzmacher
2021-04-25 0:08 ` Pavel Begunkov
2021-04-24 23:26 ` [PATCH v3 6/6] io_uring: " Stefan Metzmacher
2021-04-25 16:28 ` [PATCH v3 0/6] Complete setup before calling wake_up_new_task() Jens Axboe
2021-04-26 16:01 ` Stefan Metzmacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9ef1236abbe13401a7bbc50eb55be7ee15e5483.1619306115.git.metze@samba.org \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox