mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: brauner@kernel.org, ebiederm@xmission.com,
	torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 3/5] io_uring: Convert to use setup_thread_fn callout
Date: Sun, 12 Feb 2023 19:00:18 -0600	[thread overview]
Message-ID: <20230213010020.1813-4-michael.christie@oracle.com> (raw)
In-Reply-To: <20230213010020.1813-1-michael.christie@oracle.com>

This converts io_uring to use the setup_thread_fn callout so it can set
the task's name during copy_process. It then doesn't need the temp buffer
and will work like kthread and vhost.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 io_uring/io-wq.c  | 11 +++++++----
 io_uring/sqpoll.c | 13 +++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index 455df0c0deb5..4981bfd5581f 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -617,13 +617,9 @@ static int io_wqe_worker(void *data)
 	struct io_wqe *wqe = worker->wqe;
 	struct io_wq *wq = wqe->wq;
 	bool last_timeout = false;
-	char buf[TASK_COMM_LEN];
 
 	worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
 
-	snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task->pid);
-	set_task_comm(current, buf);
-
 	while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) {
 		long ret;
 
@@ -739,8 +735,15 @@ static inline bool io_should_retry_thread(long err)
 	}
 }
 
+static int io_wqe_setup_thread(struct task_struct *tsk, void *data)
+{
+	snprintf(tsk->comm, TASK_COMM_LEN, "iou-wrk-%d", tsk->pid);
+	return 0;
+}
+
 static struct kernel_clone_fns io_wqe_clone_fns = {
 	.thread_fn	= io_wqe_worker,
+	.setup_thread_fn = io_wqe_setup_thread,
 };
 
 static void create_worker_cont(struct callback_head *cb)
diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index 8d60b9775798..373067a714dc 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -223,12 +223,8 @@ 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
@@ -312,8 +308,17 @@ static int io_sq_thread(void *data)
 	do_exit(0);
 }
 
+static int io_sq_setup_thread(struct task_struct *tsk, void *data)
+{
+	struct io_sq_data *sqd = data;
+
+	snprintf(tsk->comm, TASK_COMM_LEN, "iou-sqp-%d", sqd->task_pid);
+	return 0;
+}
+
 static struct kernel_clone_fns io_sq_clone_fns = {
 	.thread_fn	= io_sq_thread,
+	.setup_thread_fn = io_sq_setup_thread,
 };
 
 int io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
-- 
2.25.1


  parent reply	other threads:[~2023-02-13  1:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13  1:00 [PATCH 0/5] kernel: Standardize task comm setup for kthreads Mike Christie
2023-02-13  1:00 ` [PATCH 1/5] kernel: Move kernel_clone_args's fn to new struct Mike Christie
2023-02-13  3:30   ` kernel test robot
2023-02-13  5:28   ` kernel test robot
2023-02-13 19:57   ` Linus Torvalds
2023-02-13  1:00 ` [PATCH 2/5] kernel: Add kernel_clone_fns function to setup task Mike Christie
2023-02-13  1:00 ` Mike Christie [this message]
2023-02-13  1:00 ` [PATCH 4/5] kernel: Prepare set_kthread_struct to be used for setup_thread_fn Mike Christie
2023-02-13 19:54   ` Linus Torvalds
2023-02-14  0:50     ` Mike Christie
2023-02-14 18:00       ` Linus Torvalds
2023-02-13  1:00 ` [PATCH 5/5] kernel: Convert kthread to use setup_thread_fn Mike Christie
2023-02-13  3:41   ` kernel test robot
2023-02-13  3:41   ` kernel test robot

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=20230213010020.1813-4-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®