Netdev List
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Cc: netdev@vger.kernel.org, "Clément Léger" <cleger@meta.com>,
	"Vishwanath Seshagiri" <vishs@meta.com>
Subject: Re: [PATCH 6/8] io_uring/zcrx: notify user when out of buffers
Date: Tue, 19 May 2026 17:08:01 +0100	[thread overview]
Message-ID: <57122bd8-034a-4f12-b1f7-641798252044@gmail.com> (raw)
In-Reply-To: <7db0d602-bbbd-4554-996c-1dcefd69e2bf@gmail.com>

On 5/19/26 17:04, Pavel Begunkov wrote:
> On 5/19/26 16:43, Jens Axboe wrote:
>> On 5/19/26 9:40 AM, Pavel Begunkov wrote:
>>> On 5/19/26 16:37, Jens Axboe wrote:
>>>> 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?
>>>
>>> In 99% of cases it's called from softirq, not sure what you mean
>>> by how it works.
>>
>> Ah ok, I thought you meant it was already called with softirqs disabled.
>> In which case the guard would seem broken, as we'd enable softirqs when
>> exiting. But if we're just inside softirq yeah it's fine, and there's no
>> point shuffling the allocation either.
> 
> Softirqs are run with bh disabled, but bh_disable()/enable() are
> reenterable.

Better to say they're counting nesting

>> Question on the contract still stands, in terms of missing a
>> notification. I guess since it's a hint basically it doesn't really
>> matter, just something that should be documented on the userspace side.
> 
> Should rather be improved than documented, I'd say, but it's still
> better than not getting anything at all. And it's the only place
> where it can in theory be dropped, e.g. CQE overflow handling,
> though different GFP.
> 
>> Do you have test cases for these?
> 
> Clement needs to resend them. Actually, seems I forgot to CC Vish
> and Clement here, my bad.
> 

-- 
Pavel Begunkov


  reply	other threads:[~2026-05-19 16:08 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
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 [this message]
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=57122bd8-034a-4f12-b1f7-641798252044@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cleger@meta.com \
    --cc=io-uring@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vishs@meta.com \
    /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