All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Björn Töpel" <bjorn@kernel.org>, bpf@vger.kernel.org
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH net v4 5/5] xsk: Keep the shared info of zero-copy buffers in kernel memory
Date: Sat, 05 Dec 2026 14:21:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-251624@kernel.org> (raw)
In-Reply-To: <20261204142030.626820-6-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] xsk: order-1 kmalloc demotion on 4K multi-buffer XDP_PASS skb
  heads
--

commit 97c565848cf50ed7cfbc3a8831daad9dd6b074f8
Author: Björn Töpel <bjorn@kernel.org>

xsk: Keep the shared info of zero-copy buffers in kernel memory

This commit moves the skb_shared_info of zero-copy XSK buffers from UMEM
tailroom into struct xsk_buff_pool and drops the tailroom reservation
from zero-copy multi-buffer Rx frame sizes.

> diff --git a/include/net/xdp_sock_drv.h b/include/net/xdp_sock_drv.h
> index a40ad3f90f13c..ec74bf3ffa510 100644
> --- a/include/net/xdp_sock_drv.h
> +++ b/include/net/xdp_sock_drv.h

[ ... ]

> @@ -58,18 +53,7 @@ static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
>  
>  static inline u32 xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
>  {
> -	u32 frame_size =  __xsk_pool_get_rx_frame_size(pool);
> -	struct xdp_umem *umem = pool->umem;
> -	bool mbuf;
> -
> -	/* Reserve tailroom only for zero-copy pools that opted into
> -	 * multi-buffer. The reserved area is used for skb_shared_info,
> -	 * matching the XDP core's xdp_data_hard_end() layout.
> -	 */
> -	mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
> -	frame_size -= xsk_pool_get_tailroom(mbuf);
> -
> -	return ALIGN_DOWN(frame_size, 128);
> +	return ALIGN_DOWN(__xsk_pool_get_rx_frame_size(pool), 128);
>  }

[Severity: Medium]
Does removing the tailroom subtraction demote 4 KiB-chunk multi-buffer
XDP_PASS skb heads to order-1 kmalloc-8k allocations?

With a 4096-byte UMEM chunk and zero headroom, xsk_pool_get_rx_frame_size()
now returns 3840 bytes instead of 3456.  On idpf (libeth_xskfq_create()),
a multi-buffer XDP_PASS head passes 256 + 3840 = 4096 bytes to
xdp_build_skb_from_zc() -> xdp_zc_alloc_head().

Because SKB_HEAD_ALIGN(4096) is 4416 > PAGE_SIZE (previously 4032),
xdp_zc_alloc_head() bypasses system_page_pool and falls back to
__netdev_alloc_skb() -> kmalloc-8k.  i40e_construct_skb_zc() hits the same
order-1 fallback in napi_alloc_skb() once totalsize reaches 3840.

This doubles skb head memory and truesize from 4 KiB to 8 KiB on every
multi-buffer XDP_PASS packet, loses per-CPU page recycling, and risks
GFP_ATOMIC order-1 allocation failures under memory fragmentation.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204142030.626820-1-bjorn@kernel.org?part=5

      reply	other threads:[~2026-12-05 14:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:20 [PATCH net v4 0/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 1/5] libeth: xdp: Count completed XDP_TX buffers up Björn Töpel
2026-12-05 14:21   ` sashiko-bot
2026-12-05 15:17   ` netdev-bot+sashiko
2026-12-04 14:20 ` [PATCH net v4 2/5] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 3/5] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 4/5] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 5/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-05 14:21   ` sashiko-bot [this message]

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=sashiko-outbox-251624@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=intel-wired-lan@lists.osuosl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.