From: Jens Axboe <axboe@kernel.dk>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/4] io_uring: improve alloc_cache branch prediction
Date: Mon, 9 Nov 2026 14:37:55 -0700 [thread overview]
Message-ID: <628e574b-9d79-4997-a147-51ccbd11e35d@kernel.dk> (raw)
In-Reply-To: <20261103211031.592745-1-csander@purestorage.com>
On 11/3/26 2:10 PM, Caleb Sander Mateos wrote:
> A call to io_uring_alloc_async_data() that provides a struct io_alloc_cache
> currently has 2 unnecessary NULL checks in the fast path:
> - Of the struct io_alloc_cache *, even though it points to a struct io_ring_ctx
> field
> - Of the void * entry popped from the cache, even though all cache entries are
> non-NULL
> The compiler also incorrectly assumes the success path in io_alloc_cache_get()
> is the unlikely one because it's written as an early return.
>
> Avoid the first NULL check by splitting io_uring_alloc_async_data()'s cache
> logic to a separate function io_uring_alloc_cached_async_data() that uses the
> cache unconditionally. Avoid the second by returning a separate success bool
> from io_cache_alloc() instead of checking the NULL-ness of the returned entry.
> Also mark io_alloc_cache_get() and io_alloc_cache_put()'s success paths as
> likely so the compiler can avoid jumps in the fast path.
>
> The final commit is a small code simplification in io_futex_wait() noticed while
> touching the neighboring io_cache_alloc() call.
I hand-applied this, as it needed changes for the post-7.3 trees.
Patch 3 is somewhat marginal I'd say in terms of rewards for the
churn, but churn is cheap these days...
Anyway, check the end result, please.
--
Jens Axboe
next prev parent reply other threads:[~2026-11-09 21:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 21:10 [PATCH 0/4] io_uring: improve alloc_cache branch prediction Caleb Sander Mateos
2026-11-03 21:10 ` [PATCH 1/4] io_uring: split io_uring_alloc_async_data() Caleb Sander Mateos
2026-11-03 21:10 ` [PATCH 2/4] io_uring/alloc_cache: mark cache success paths as likely Caleb Sander Mateos
2026-11-03 21:10 ` [PATCH 3/4] io_uring/alloc_cache: assume io_alloc_cache_get() doesn't return NULL Caleb Sander Mateos
2026-11-03 21:10 ` [PATCH 4/4] io_uring/futex: avoid ifd NULL check in io_futex_wait() Caleb Sander Mateos
2026-11-09 21:37 ` Jens Axboe [this message]
2026-11-09 23:14 ` [PATCH 0/4] io_uring: improve alloc_cache branch prediction Caleb Sander Mateos
2026-11-09 21:38 ` Jens Axboe
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=628e574b-9d79-4997-a147-51ccbd11e35d@kernel.dk \
--to=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@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.