From: Almog Khaikin <almogkh@gmail.com>
To: io-uring@vger.kernel.org
Cc: axboe@kernel.dk, asml.silence@gmail.com
Subject: [PATCH] io_uring: fix memory ordering when SQPOLL thread goes to sleep
Date: Sun, 6 Mar 2022 12:35:44 +0200 [thread overview]
Message-ID: <20220306103544.96974-1-almogkh@gmail.com> (raw)
Without a full memory barrier between the store to the flags and the
load of the SQ tail the two operations can be reordered and this can
lead to a situation where the SQPOLL thread goes to sleep while the
application writes to the SQ tail and doesn't see the wakeup flag.
This memory barrier pairs with a full memory barrier in the application
between its store to the SQ tail and its load of the flags.
Signed-off-by: Almog Khaikin <almogkh@gmail.com>
---
fs/io_uring.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4715980e9015..221961be9213 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7613,6 +7613,13 @@ static int io_sq_thread(void *data)
needs_sched = false;
break;
}
+
+ /*
+ * Ensure the store of the wakeup flag is not
+ * reordered with the load of the SQ tail
+ */
+ smp_mb();
+
if (io_sqring_entries(ctx)) {
needs_sched = false;
break;
--
2.35.1
next reply other threads:[~2022-03-06 10:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 10:35 Almog Khaikin [this message]
2022-03-06 13:32 ` [PATCH] io_uring: fix memory ordering when SQPOLL thread goes to sleep Almog Khaikin
2022-03-06 21:00 ` Jens Axboe
2022-03-06 21:35 ` Almog Khaikin
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=20220306103544.96974-1-almogkh@gmail.com \
--to=almogkh@gmail.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.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 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.