From: Jens Axboe <axboe@kernel.dk>
To: Jackie Liu <liuyun01@kylinos.cn>
Cc: ebiggers@kernel.org, liuzhengyuan@kylinos.cn,
linux-block@vger.kernel.org
Subject: Re: [PATCH] io_uring: fix io_sq_thread_stop running in front of io_sq_thread
Date: Fri, 5 Jul 2019 10:25:22 -0600 [thread overview]
Message-ID: <2c3affad-fc75-d64d-c0e0-829d2343d074@kernel.dk> (raw)
In-Reply-To: <1562307120-6785-1-git-send-email-liuyun01@kylinos.cn>
On 7/5/19 12:12 AM, Jackie Liu wrote:
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 4ef62a4..4bbecbb 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -231,6 +231,7 @@ struct io_ring_ctx {
> struct task_struct *sqo_thread; /* if using sq thread polling */
> struct mm_struct *sqo_mm;
> wait_queue_head_t sqo_wait;
> + bool sqo_thread_started;
>
> struct {
> /* CQ ring */
> @@ -2009,6 +2010,8 @@ static int io_sq_thread(void *data)
> unsigned inflight;
> unsigned long timeout;
>
> + ctx->sqo_thread_started = true;
> +
> old_fs = get_fs();
> set_fs(USER_DS);
>
> @@ -2243,6 +2246,8 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
> static void io_sq_thread_stop(struct io_ring_ctx *ctx)
> {
> if (ctx->sqo_thread) {
> + while (!ctx->sqo_thread_started)
> + schedule();
> /*
> * The park is a bit of a work-around, without it we get
> * warning spews on shutdown with SQPOLL set and affinity
>
Probably want to make that an unsigned long, and then use
set_bit/test_bit for this to avoid funky memory ordering issues.
--
Jens Axboe
prev parent reply other threads:[~2019-07-05 16:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 8:21 INFO: task hung in io_uring_release syzbot
2019-07-02 6:00 ` Eric Biggers
2019-07-04 3:58 ` JackieLiu
2019-07-04 4:57 ` JackieLiu
2019-07-05 6:12 ` [PATCH] io_uring: fix io_sq_thread_stop running in front of io_sq_thread Jackie Liu
2019-07-05 16:25 ` Jens Axboe [this message]
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=2c3affad-fc75-d64d-c0e0-829d2343d074@kernel.dk \
--to=axboe@kernel.dk \
--cc=ebiggers@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=liuyun01@kylinos.cn \
--cc=liuzhengyuan@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.