From: netdev-bot+sashiko@kernel.org
To: bjorn@kernel.org
Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
ilias.apalodimas@linaro.org, alexanderduyck@fb.com,
saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com,
leon@kernel.org, michael.chan@broadcom.com,
pavan.chebbi@broadcom.com, corbet@lwn.net, shuah@kernel.org,
bpf@vger.kernel.org, netdev@vger.kernel.org, stuclar@meta.com,
sdf@fomichev.me, horms@kernel.org, martin.lau@linux.dev,
almasrymina@google.com, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
rdunlap@infradead.org, kernel-team@meta.com,
dimitri.daskalakis1@gmail.com, bobbyeshleman@meta.com,
mohsin.bashr@gmail.com, kees@kernel.org, leitao@debian.org,
maxime.chevallier@bootlin.com, cuitao@kylinos.cn,
vadim.fedorenko@linux.dev, mike.marciniszyn@gmail.com,
kuniyu@google.com, jiayuan.chen@linux.dev, mkarsten@uwaterloo.ca,
razor@blackwall.org, dw@davidwei.uk, asml.silence@gmail.com,
linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 04/15] page_pool: Let memory providers take back net_iovs
Date: Wed, 25 Nov 2026 14:08:08 +0000 [thread overview]
Message-ID: <179561568855.3135.15810206390695616800@kernel.org> (raw)
In-Reply-To: <20261124125654.183091-4-bjorn@kernel.org>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] page_pool_hand_off() in net/core/page_pool.c (lines 846-851)
branches on netmem_is_net_iov() and casts the netmem down to a net_iov…
- [Low] The kernel-doc for memory_provider_ops.hand_off in
include/net/page_pool/memory_provider.h (lines 39-44) says a false…
--
page_pool: Let memory providers take back net_iovs
This commit adds a hand_off() memory provider op and an mp_hand_off flag
in struct net_iov. When a net_iov is marked, its last put goes to the
provider instead of the page pool cache, and it stays charged to the
pool. The hook is wired into __page_pool_put_page(),
page_pool_drain_frag() and page_pool_free_frag(). The commit also adds a
provider-owned mp_state byte.
> diff --git a/include/net/page_pool/memory_provider.h b/include/net/page_pool/memory_provider.h
> index d52c7a450c68e..bfc2841582225 100644
> --- a/include/net/page_pool/memory_provider.h
> +++ b/include/net/page_pool/memory_provider.h
> @@ -36,6 +36,12 @@ enum mp_flags {
> struct memory_provider_ops {
> netmem_ref (*alloc_netmems)(struct page_pool *pool, gfp_t gfp);
> bool (*release_netmem)(struct page_pool *pool, netmem_ref netmem);
> + /* Takes a free net_iov marked mp_hand_off that stays charged to the
> + * pool; the provider puts it back later. Returns false to have the
> + * pool recycle it instead. Called where the pool puts netmem, outside
> + * hard IRQ context. Needed by providers that mark net_iovs.
> + */
[Severity: Low]
Is "Returns false to have the pool recycle it instead" true for every
caller?
In __page_pool_put_page() and page_pool_drain_frag(), a false return falls
through to recycling, because __page_pool_page_can_be_recycled() is always
true for a net_iov.
page_pool_destroy() calls page_pool_free_frag(). There, a false return
falls through to this:
if (!netmem || page_pool_unref_netmem(netmem, drain_count) ||
page_pool_hand_off(pool, netmem))
return;
page_pool_return_netmem(pool, netmem);
For a provider pool, page_pool_return_netmem() calls
mp_ops->release_netmem() and bumps pages_state_release_cnt. The net_iov is
then taken out of the pool instead of being recycled. The commit message
says a hand-off provider wants to avoid exactly this.
The only provider in the series, xsk_sink_hand_off(), always returns true,
so nothing reaches this path today. Could the comment or
page_pool_free_frag() be changed so the two agree?
> + bool (*hand_off)(struct page_pool *pool, netmem_ref netmem);
> int (*init)(struct page_pool *pool);
> void (*destroy)(struct page_pool *pool);
> int (*nl_fill)(void *mp_priv, struct sk_buff *rsp,
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 8a1ea21ccdcdc..200b0569b9fe7 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -840,6 +840,16 @@ static bool __page_pool_page_can_be_recycled(netmem_ref netmem)
> !page_is_pfmemalloc(netmem_to_page(netmem)));
> }
>
> +/* A memory provider takes back a free net_iov it marked, see
> + * &memory_provider_ops.hand_off
> + */
> +static bool page_pool_hand_off(struct page_pool *pool, netmem_ref netmem)
> +{
> + return netmem_is_net_iov(netmem) &&
> + unlikely(netmem_to_net_iov(netmem)->mp_hand_off) &&
> + pool->mp_ops->hand_off(pool, netmem);
> +}
[Severity: Low]
This isn't a bug, but does this fit the netmem abstraction rules?
page_pool_hand_off() branches on netmem_is_net_iov() and downcasts with
netmem_to_net_iov() inside page_pool core. Before this patch, page_pool.c
had no netmem_to_net_iov() call.
The netmem_ref kernel-doc in include/net/netmem.h says:
Downcasting netmem_ref via netmem_to_page() or netmem_to_net_iov() in
callers is not allowed unless a code path strictly requires a specific
backing type ... In such cases, add a netmem helper here that handles
both page and net_iov cases
Documentation/networking/netmem.rst also says core code should avoid
per-netmem-type branching. It also says new code must not assume that
using a memory provider implies net_iov memory.
The mp_hand_off flag lives in struct net_iov, and the hand_off() contract
only covers net_iovs. So a provider that hands out page-backed netmems
can't use this hook.
Would a netmem.h helper fit better here? For example, something like
netmem_mp_hand_off() that returns false for pages and is called from
page_pool core.
> +
> /* If the page refcnt == 1, this will try to recycle the page.
> * If pool->dma_sync is set, we'll try to sync the DMA area for
> * the configured size min(dma_sync_size, pool->max_len).
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124112707.118678-1-bjorn%40kernel.org
next prev parent reply other threads:[~2026-11-25 14:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:26 [PATCH net-next 00/15] xsk: Receive in the device's buffer layout Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 01/15] xdp: Let memory providers offer XDP a view of their net_iovs Björn Töpel
2026-11-25 14:07 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 02/15] xdp: Keep the shared info of a buffer in kernel memory Björn Töpel
2026-11-25 14:07 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 03/15] net: Add memory providers that only feed XDP Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 04/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko [this message]
2026-11-24 12:56 ` [PATCH net-next 05/15] xdp: Run programs on buffers that must not hold kernel structures Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 06/15] xsk: Lend UMEM chunks to the page pools of a queue Björn Töpel
2026-11-24 14:34 ` Magnus Karlsson
2026-11-24 15:12 ` Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 07/15] xsk: Deliver to the socket in the device's buffer layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 08/15] xsk: Receive " Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 09/15] eth: fbnic: Support XDP redirect Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 10/15] eth: fbnic: Receive into XDP-only memory providers Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 11/15] net: Add netif_rxq_has_xdp_only_mp() Björn Töpel
2026-11-24 12:56 ` [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory providers Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 13/15] eth: bnxt: " Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 14/15] selftests: net: xsk: Test the device's RX buffer layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
2026-11-24 12:56 ` [PATCH net-next 15/15] Documentation: networking: Describe AF_XDP RX in the device's layout Björn Töpel
2026-11-25 14:08 ` netdev-bot+sashiko
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=179561568855.3135.15810206390695616800@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexanderduyck@fb.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=asml.silence@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bobbyeshleman@meta.com \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=cuitao@kylinos.cn \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dimitri.daskalakis1@gmail.com \
--cc=dw@davidwei.uk \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=ilias.apalodimas@linaro.org \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=leitao@debian.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=maxime.chevallier@bootlin.com \
--cc=mbloch@nvidia.com \
--cc=memxor@gmail.com \
--cc=michael.chan@broadcom.com \
--cc=mike.marciniszyn@gmail.com \
--cc=mkarsten@uwaterloo.ca \
--cc=mohsin.bashr@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=razor@blackwall.org \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=stuclar@meta.com \
--cc=tariqt@nvidia.com \
--cc=vadim.fedorenko@linux.dev \
--cc=yonghong.song@linux.dev \
/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