From: sashiko-bot@kernel.org
To: "Taehee Yoo" <ap420073@gmail.com>
Cc: dri-devel@lists.freedesktop.org, bpf@vger.kernel.org,
media-ci@linuxtv.org
Subject: Re: [RFC PATCH net-next 02/13] net: devmem: extend memory provider for knod
Date: Tue, 21 Jul 2026 07:17:53 +0000 [thread overview]
Message-ID: <20260721071753.ABBE41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719175857.4071636-3-ap420073@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The patch silently increases PP_ALLOC_CACHE_REFILL from 64 to up to 4096 (for 4K pages), severely bloating struct page_pool and causing order-5 page allocation failures.
- [High] Ignored error return value of page_pool_set_dma_addr_netmem can lead to silent DMA address truncation and memory corruption on 32-bit architectures with 64-bit DMA.
- [Medium] The is_kernel_rodata check in page_pool_init prevents loadable driver modules from utilizing the new PP_FLAG_CUSTOM_MEMORY_PROVIDER feature.
--
--- Patch [2]: [RFC PATCH net-next 02/13] net: devmem: extend memory provider for knod ---
commit 685f164a3b04db75b3dba6257fd2806218155a24
Author: Taehee Yoo <ap420073@gmail.com>
net: devmem: extend memory provider for knod
This commit extends the devmem memory-provider path so a knod accelerator
can back a NIC page_pool with accelerator-exported memory. This lets the
NIC DMA received packets directly into accelerator memory.
> diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
> index 03da138722f58..3e866f249768e 100644
> --- a/include/net/page_pool/types.h
> +++ b/include/net/page_pool/types.h
[ ... ]
> @@ -54,11 +62,11 @@
> * would have to take a slower code path.
> */
> #if PAGE_SIZE >= SZ_64K
> -#define PP_ALLOC_CACHE_REFILL 4
> +#define PP_ALLOC_CACHE_REFILL 256
> #elif PAGE_SIZE >= SZ_16K
> -#define PP_ALLOC_CACHE_REFILL 16
> +#define PP_ALLOC_CACHE_REFILL 1024
> #else
> -#define PP_ALLOC_CACHE_REFILL 64
> +#define PP_ALLOC_CACHE_REFILL 4096
> #endif
[Severity: High]
Will this increase to PP_ALLOC_CACHE_REFILL cause page_pool_create() to
fail unpredictably under memory fragmentation?
Since PP_ALLOC_CACHE_SIZE is defined as PP_ALLOC_CACHE_REFILL * 2, the
inline cache array inside struct page_pool grows to 8,192 entries for 4K
pages. At 8 bytes per pointer, this array alone consumes ~65.5KB.
This forces an order-5 kzalloc_node allocation for the page_pool struct,
which is highly prone to failure under fragmentation and drastically bloats
the memory footprint per RX queue.
[ ... ]
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 21dc4a9c8714d..fd7444943b9f5 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -272,7 +272,17 @@ static int page_pool_init(struct page_pool *pool,
>
> xa_init_flags(&pool->dma_mapped, XA_FLAGS_ALLOC1);
>
> - if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
> + if (pool->slow.flags & PP_FLAG_CUSTOM_MEMORY_PROVIDER) {
> + /* Driver-managed pool with a directly-supplied memory
> + * provider, not bound to a netdev rx queue.
> + */
> + if (WARN_ON(!pool->slow.mp_ops || !pool->slow.mp_priv)) {
> + err = -EINVAL;
> + goto free_ptr_ring;
> + }
> + pool->mp_priv = pool->slow.mp_priv;
> + pool->mp_ops = pool->slow.mp_ops;
[Severity: Medium]
Will this new flag work for loadable driver modules?
When PP_FLAG_CUSTOM_MEMORY_PROVIDER is used, pool->mp_ops is populated here.
Later in page_pool_init(), there is a preexisting check:
if (WARN_ON(!is_kernel_rodata((unsigned long)pool->mp_ops))) {
err = -EFAULT;
goto free_ptr_ring;
}
Because is_kernel_rodata() only checks against the core kernel's
__start_rodata and __end_rodata boundaries, any memory provider ops struct
allocated in a loadable module's .rodata section will fail this check.
This renders the new feature unusable for modular drivers.
> + } else if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
> netdev_assert_locked(pool->slow.netdev);
> rxq = __netif_get_rx_queue(pool->slow.netdev,
> pool->slow.queue_idx);
[ ... ]
> @@ -725,6 +735,16 @@ void page_pool_clear_pp_info(netmem_ref netmem)
> netmem_set_pp(netmem, NULL);
> }
>
> +void page_pool_provider_set_netmem(struct page_pool *pool, netmem_ref netmem,
> + dma_addr_t addr)
> +{
> + netmem_to_nmdesc(netmem)->pp_magic = 0;
> + netmem_to_nmdesc(netmem)->pp = NULL;
> + atomic_long_set(&netmem_to_nmdesc(netmem)->pp_ref_count, 0);
> + page_pool_set_pp_info(pool, netmem);
> + page_pool_set_dma_addr_netmem(netmem, addr);
[Severity: High]
Does this silently ignore DMA address truncation?
page_pool_set_dma_addr_netmem() returns a boolean indicating whether the
DMA address exceeded the capacity of the storage representation (such as
on 32-bit architectures with 64-bit DMA support).
Because page_pool_provider_set_netmem() returns void and discards this
boolean, memory providers will be unaware if their DMA address was
truncated. This could lead to silent data corruption or IOMMU faults
when the hardware uses the truncated address.
> +}
> +
> static __always_inline void __page_pool_release_netmem_dma(struct page_pool *pool,
> netmem_ref netmem)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260719175857.4071636-1-ap420073@gmail.com?part=2
next prev parent reply other threads:[~2026-07-21 7:17 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 17:58 [RFC PATCH net-next 00/13] net: knod: in-kernel network offload device Taehee Yoo
2026-07-19 17:58 ` [RFC PATCH net-next 01/13] net: knod: add uapi and core headers Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 02/13] net: devmem: extend memory provider for knod Taehee Yoo
2026-07-20 19:43 ` Mina Almasry
2026-07-21 16:15 ` Taehee Yoo
2026-07-21 7:17 ` sashiko-bot [this message]
2026-07-19 17:58 ` [RFC PATCH net-next 03/13] net: core: add XDP_MODE_HW offload hook " Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 04/13] net: knod: add offload device core and control plane Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 05/13] bpf: offload: allow PERCPU_ARRAY maps for offloaded programs Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 06/13] drm/amdkfd: prepare kfd core for the knod provider Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 07/13] drm/amdkfd: add knod provider core Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 08/13] drm/amdkfd: add GPU instruction emitter and disassembler Taehee Yoo
2026-07-20 20:05 ` Natalie Vock
2026-07-20 20:53 ` Andrew Lunn
2026-07-21 16:36 ` Hoyeon Lee
2026-07-19 17:58 ` [RFC PATCH net-next 09/13] drm/amdkfd: add BPF-to-GPU JIT offload Taehee Yoo
2026-07-19 17:58 ` [RFC PATCH net-next 10/13] net/mlx5e: add knod XDP offload support Taehee Yoo
2026-07-21 7:17 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 11/13] bnxt_en: " Taehee Yoo
2026-07-21 7:18 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 12/13] selftests: drivers/net: add knod tests Taehee Yoo
2026-07-21 7:18 ` sashiko-bot
2026-07-19 17:58 ` [RFC PATCH net-next 13/13] drm/amdkfd: add IPsec full-packet offload Taehee Yoo
2026-07-21 7:18 ` sashiko-bot
2026-07-20 19:18 ` [RFC PATCH net-next 00/13] net: knod: in-kernel network offload device Mina Almasry
2026-07-21 15:17 ` Taehee Yoo
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=20260721071753.ABBE41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ap420073@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.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