From: Christian Brauner <christian.brauner@ubuntu.com>
To: Mike Christie <michael.christie@oracle.com>
Cc: hdanton@sina.com, hch@infradead.org, stefanha@redhat.com,
jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com,
virtualization@lists.linux-foundation.org, axboe@kernel.dk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 6/9] io_uring: switch to kernel_worker
Date: Wed, 22 Sep 2021 14:53:46 +0200 [thread overview]
Message-ID: <20210922125346.qd2koricy5vt3655@wittgenstein> (raw)
In-Reply-To: <20210921215218.89844-7-michael.christie@oracle.com>
On Tue, Sep 21, 2021 at 04:52:15PM -0500, Mike Christie wrote:
> Convert io_uring and io-wq to use kernel_worker.
>
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
Looks good to me,
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
> fs/io-wq.c | 15 ++++++++-------
> fs/io_uring.c | 11 +++++------
> include/linux/sched/task.h | 1 -
> 3 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/fs/io-wq.c b/fs/io-wq.c
> index c2e0e8e80949..74e68132a227 100644
> --- a/fs/io-wq.c
> +++ b/fs/io-wq.c
> @@ -69,6 +69,9 @@ struct io_worker {
>
> #define IO_WQ_NR_HASH_BUCKETS (1u << IO_WQ_HASH_ORDER)
>
> +#define IO_WQ_CLONE_FLAGS (CLONE_FS | CLONE_FILES | CLONE_SIGHAND | \
> + CLONE_THREAD | CLONE_IO)
> +
> struct io_wqe_acct {
> unsigned nr_workers;
> unsigned max_workers;
> @@ -549,13 +552,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;
>
> @@ -652,7 +651,7 @@ static void io_init_new_worker(struct io_wqe *wqe, struct io_worker *worker,
> list_add_tail_rcu(&worker->all_list, &wqe->all_list);
> worker->flags |= IO_WORKER_F_FREE;
> raw_spin_unlock(&wqe->lock);
> - wake_up_new_task(tsk);
> + kernel_worker_start(tsk, "iou-wrk-%d", wqe->wq->task->pid);
> }
>
> static bool io_wq_work_match_all(struct io_wq_work *work, void *data)
> @@ -682,7 +681,8 @@ static void create_worker_cont(struct callback_head *cb)
> worker = container_of(cb, struct io_worker, create_work);
> clear_bit_unlock(0, &worker->create_state);
> wqe = worker->wqe;
> - tsk = create_io_thread(io_wqe_worker, worker, wqe->node);
> + tsk = kernel_worker(io_wqe_worker, worker, wqe->node,
> + IO_WQ_CLONE_FLAGS, KERN_WORKER_IO);
> if (!IS_ERR(tsk)) {
> io_init_new_worker(wqe, worker, tsk);
> io_worker_release(worker);
> @@ -752,7 +752,8 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
> if (index == IO_WQ_ACCT_BOUND)
> worker->flags |= IO_WORKER_F_BOUND;
>
> - tsk = create_io_thread(io_wqe_worker, worker, wqe->node);
> + tsk = kernel_worker(io_wqe_worker, worker, wqe->node, IO_WQ_CLONE_FLAGS,
> + KERN_WORKER_IO);
> if (!IS_ERR(tsk)) {
> io_init_new_worker(wqe, worker, tsk);
> } else if (!io_should_retry_thread(PTR_ERR(tsk))) {
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index e372d5b9f6dc..1df7bec8bd76 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -7393,12 +7393,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
> @@ -8580,6 +8576,8 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
> fdput(f);
> }
> if (ctx->flags & IORING_SETUP_SQPOLL) {
> + unsigned long flags = CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
> + CLONE_THREAD | CLONE_IO;
> struct task_struct *tsk;
> struct io_sq_data *sqd;
> bool attached;
> @@ -8621,7 +8619,8 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
>
> sqd->task_pid = current->pid;
> sqd->task_tgid = current->tgid;
> - tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);
> + tsk = kernel_worker(io_sq_thread, sqd, NUMA_NO_NODE,
> + flags, KERN_WORKER_IO);
> if (IS_ERR(tsk)) {
> ret = PTR_ERR(tsk);
> goto err_sqpoll;
> @@ -8629,7 +8628,7 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
>
> sqd->thread = tsk;
> ret = io_uring_alloc_task_context(tsk, ctx);
> - wake_up_new_task(tsk);
> + kernel_worker_start(tsk, "iou-sqp-%d", sqd->task_pid);
> if (ret)
> goto err;
> } else if (p->flags & IORING_SETUP_SQ_AFF) {
> diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
> index ba0499b6627c..781abbc1c288 100644
> --- a/include/linux/sched/task.h
> +++ b/include/linux/sched/task.h
> @@ -87,7 +87,6 @@ extern void exit_files(struct task_struct *);
> extern void exit_itimers(struct signal_struct *);
>
> extern pid_t kernel_clone(struct kernel_clone_args *kargs);
> -struct task_struct *create_io_thread(int (*fn)(void *i), void *arg, int node);
> struct task_struct *kernel_worker(int (*fn)(void *), void *arg, int node,
> unsigned long clone_flags, u32 worker_flags);
> __printf(2, 3)
> --
> 2.25.1
>
next prev parent reply other threads:[~2021-09-22 12:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 21:52 [PATCH V2 0/9] Use copy_process/create_io_thread in vhost layer Mike Christie
2021-09-21 21:52 ` [PATCH V2 1/9] fork: Make IO worker options flag based Mike Christie
2021-09-22 12:44 ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 2/9] fork: pass worker_flags to copy_thread Mike Christie
2021-09-22 12:42 ` Christian Brauner
2021-09-22 14:18 ` Geert Uytterhoeven
2021-09-21 21:52 ` [PATCH V2 3/9] fork: move PF_IO_WORKER's kernel frame setup to new flag Mike Christie
2021-09-22 12:32 ` Geert Uytterhoeven
2021-09-22 12:39 ` Christian Brauner
2021-09-22 12:45 ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 4/9] fork: add option to not clone or dup files Mike Christie
2021-09-22 12:46 ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 5/9] fork: add helper to clone a process Mike Christie
2021-09-22 12:50 ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 6/9] io_uring: switch to kernel_worker Mike Christie
2021-09-22 12:53 ` Christian Brauner [this message]
2021-09-21 21:52 ` [PATCH V2 7/9] fork: Add worker flag to ignore signals Mike Christie
2021-09-22 12:52 ` Christian Brauner
2021-09-21 21:52 ` [PATCH V2 8/9] vhost: move worker thread fields to new struct Mike Christie
2021-10-04 13:12 ` Michael S. Tsirkin
2021-09-21 21:52 ` [PATCH V2 9/9] vhost: use kernel_worker to check RLIMITs and inherit v2 cgroups Mike Christie
2021-10-04 13:12 ` Michael S. Tsirkin
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=20210922125346.qd2koricy5vt3655@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=hdanton@sina.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.christie@oracle.com \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.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;
as well as URLs for NNTP newsgroup(s).