Re: [PATCH net-next v1 06/11] page_pool: Coordinate refill with memory providers

From: Björn Töpel

Date: Thu Nov 12 2026 - 10:25:34 EST


Stanislav Fomichev <sdf.kernel@xxxxxxxxx> writes:

> On 11/11, Björn Töpel wrote:
>> Stanislav Fomichev <sdf.kernel@xxxxxxxxx> writes:
>>
>> > On 11/10, Björn Töpel wrote:
>>
>> >> diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
>> >> index 989120cbf452..ca12cbf7b825 100644
>> >> --- a/include/net/netdev_rx_queue.h
>> >> +++ b/include/net/netdev_rx_queue.h
>> >> @@ -33,6 +33,12 @@ struct netdev_rx_queue {
>> >> struct pp_memory_provider_params mp_params;
>> >> /* stamps the page pools of each queue allocation */
>> >> u32 mp_gen;
>> >> + /* NAPI of the running queue, for memory provider wakeups. Set while
>> >> + * mp_armed, and if the provider has a refill_done op. Written under
>> >> + * the ops lock, read under RCU, see netif_mp_wake().
>> >> + */
>> >> + struct napi_struct __rcu *mp_napi;
>> >> + bool mp_armed;
>> >
>> > The comment should explain why mp_napi != napi? (I do not understand why)
>>
>> Fair. It's the same NAPI, with other rules. napi is the driver's
>> association: read under the ops lock, and not cleared when the NAPI is
>> deleted. Provider wakeups run without that lock, from socket syscalls
>> and ->release_netmem().
>>
>> mp_napi is an RCU copy, set only while the device is up and the queue
>> isn't restarting, for providers with ->refill_done(). netif_napi_del()
>> clears it before its grace period. Setting it also schedules the NAPI
>> once, which replays wakeups lost while the queue was stopped. I'll put
>> that in the comment.
>
> And all this only to make sure that we are not recycling something from
> the old pp into the new one? And reworking existing pointer to change/update
> its lifetime is not gonna do it?

No, it's how the provider wakes the queue when chunks show up: userspace
posts FILL and calls {e,}poll() or sendto(), or an old page pool
releases chunks after a restart. It replaces ndo_xsk_wakeup.

But! I think that rxq->napi can do it: make it RCU, clear it when the
NAPI is deleted, and have the driver poll the queue once after enabling
its NAPI, as fbnic does. A wakeup that hits a stopped queue is then
covered by that poll, so mp_napi and mp_armed go (and with them the
error-path bugs Sashiko found...) I'll do that in v2.


Björn