* [PATCH] io_uring: add likely/unlikely in io_get_sqring()
@ 2019-11-21 18:24 Pavel Begunkov
0 siblings, 0 replies; only message in thread
From: Pavel Begunkov @ 2019-11-21 18:24 UTC (permalink / raw)
To: Jens Axboe, io-uring
The number of SQEs to submit is specified by a user, so io_get_sqring()
in most of the cases succeeds. Hint compilers about that.
Checking ASM genereted by gcc 9.2.0 for x64, there is one branch
misprediction.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
fs/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index fa1cf7263959..86d1d8f272ae 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3112,11 +3112,11 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)
*/
head = ctx->cached_sq_head;
/* make sure SQ entry isn't read before tail */
- if (head == smp_load_acquire(&rings->sq.tail))
+ if (unlikely(head == smp_load_acquire(&rings->sq.tail)))
return false;
head = READ_ONCE(sq_array[head & ctx->sq_mask]);
- if (head < ctx->sq_entries) {
+ if (likely(head < ctx->sq_entries)) {
s->ring_file = NULL;
s->sqe = &ctx->sq_sqes[head];
s->sequence = ctx->cached_sq_head;
--
2.24.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, back to index
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 18:24 [PATCH] io_uring: add likely/unlikely in io_get_sqring() Pavel Begunkov
IO-Uring Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/io-uring/0 io-uring/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 io-uring io-uring/ https://lore.kernel.org/io-uring \
io-uring@vger.kernel.org
public-inbox-index io-uring
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.kernel.vger.io-uring
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git