From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 6/8] io_uring/zcrx: notify user when out of buffers
Date: Tue, 19 May 2026 09:37:05 -0600 [thread overview]
Message-ID: <a2a92049-0974-478a-9297-76af96b455d8@kernel.dk> (raw)
In-Reply-To: <6d1187c8-ba4f-41ad-b692-351d8b072038@gmail.com>
On 5/19/26 9:30 AM, Pavel Begunkov wrote:
> On 5/19/26 16:26, Jens Axboe wrote:
>> On 5/19/26 5:44 AM, Pavel Begunkov wrote:
>>> @@ -1126,6 +1142,48 @@ static unsigned io_zcrx_refill_slow(struct page_pool *pp, struct io_zcrx_ifq *if
>>> return allocated;
>>> }
>>> +static void zcrx_notif_tw(struct io_tw_req tw_req, io_tw_token_t tw)
>>> +{
>>> + struct io_kiocb *req = tw_req.req;
>>> + struct io_ring_ctx *ctx = req->ctx;
>>> +
>>> + io_post_aux_cqe(ctx, req->cqe.user_data, req->cqe.res, 0);
>>> + percpu_ref_put(&ctx->refs);
>>> + io_poison_req(req);
>>> + kmem_cache_free(req_cachep, req);
>>> +}
>>> +
>>> +static void zcrx_send_notif(struct io_zcrx_ifq *ifq, unsigned type)
>>> +{
>>> + gfp_t gfp = GFP_ATOMIC | __GFP_NOWARN | __GFP_ZERO;
>>> + u32 type_mask = 1 << type;
>>> + struct io_kiocb *req;
>>> +
>>> + if (!(type_mask & ifq->allowed_notif_mask))
>>> + return;
>>> +
>>> + guard(spinlock_bh)(&ifq->ctx_lock);
>>> + if (!ifq->master_ctx)
>>> + return;
>>> + if (type_mask & ifq->fired_notifs)
>>> + return;
>>> +
>>> + req = kmem_cache_alloc(req_cachep, gfp);
>>> + if (unlikely(!req))
>>> + return;
>>
>> It'd be nice to avoid an allocation here inside ctx_lock and with bh's
>> disabled, which looks like is also the only reason why GFP_ATOMIC is
>> being used here.
>
> I thought about it, but it's already bh, it'd need to do pre
> allocations + caching to be reliable, but that's left out for now.
Not sure I follow - GFP_KERNEL would be more reliable than GFP_ATOMIC.
What's the contract in terms of the notification? If we fail the alloc,
then userspace can't rely on the notification on the refill failure.
Are we under bh save already here, before doing it ourselves? If so,
then how does the guard work?
>> Maybe opportunistically check ->fired_notifs early? Might also avoid the
>> lock in the first place if we get back-to-back of these.
>
> Slow path, doesn't matter
Agree, not a huge deal as we hope to not hit the notif path.
--
Jens Axboe
next prev parent reply other threads:[~2026-05-19 15:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 11:44 [PATCH 0/8] first zcrx updates for 7.2 Pavel Begunkov
2026-05-19 11:44 ` [PATCH 1/8] io_uring/zcrx: make scrubbing more reliable Pavel Begunkov
2026-05-19 11:44 ` [PATCH 2/8] io_uring/zcrx: poison pointers on unregistration Pavel Begunkov
2026-05-19 11:44 ` [PATCH 3/8] io_uring/zcrx: remove extra ifq close Pavel Begunkov
2026-05-19 11:44 ` [PATCH 4/8] io_uring/zcrx: reorder fd allocation in zcrx_export() Pavel Begunkov
2026-05-19 11:44 ` [PATCH 5/8] io_uring/zcrx: add ctx pointer to zcrx Pavel Begunkov
2026-05-19 11:46 ` Pavel Begunkov
2026-05-19 11:44 ` [PATCH 6/8] io_uring/zcrx: notify user when out of buffers Pavel Begunkov
2026-05-19 15:26 ` Jens Axboe
2026-05-19 15:30 ` Pavel Begunkov
2026-05-19 15:37 ` Jens Axboe [this message]
2026-05-19 15:40 ` Pavel Begunkov
2026-05-19 15:43 ` Jens Axboe
2026-05-19 16:04 ` Pavel Begunkov
2026-05-19 16:08 ` Pavel Begunkov
2026-05-19 16:09 ` Jens Axboe
2026-05-19 11:44 ` [PATCH 7/8] io_uring/zcrx: notify user on frag copy fallback Pavel Begunkov
2026-05-19 11:44 ` [PATCH 8/8] io_uring/zcrx: add shared-memory notification statistics Pavel Begunkov
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=a2a92049-0974-478a-9297-76af96b455d8@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox