Netdev List
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Magnus Karlsson" <magnus.karlsson@intel.com>,
	"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Willem de Bruijn" <willemb@google.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	"Simon Horman" <horms@kernel.org>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Tony Nguyen" <anthony.l.nguyen@intel.com>,
	"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
	intel-wired-lan@lists.osuosl.org,
	"Clément Lecigne" <clecigne@google.com>
Subject: Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size
Date: Tue, 1 Dec 2026 15:08:56 +0100	[thread overview]
Message-ID: <70b2dc98-9cbb-4e40-881c-4026d9e44b0d@intel.com> (raw)
In-Reply-To: <87mrqpzd8a.fsf@all.your.base.are.belong.to.us>

From: Björn Töpel <bjorn@kernel.org>
Date: Tue, 01 Dec 2026 08:12:05 +0100

> Alexander Lobakin <aleksander.lobakin@intel.com> writes:
> 
>> From: Björn Töpel <bjorn@kernel.org>
>> Date: Mon, 30 Nov 2026 13:37:33 +0100
>>> diff --git a/net/core/xdp.c b/net/core/xdp.c
>>> index 1d679e8fd649..33a6740b411f 100644
>>> --- a/net/core/xdp.c
>>> +++ b/net/core/xdp.c
>>> @@ -738,33 +760,27 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,
>>>   */
>>>  struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp)
>>>  {
>>> +	u32 size = xdp->data_end - xdp->data_hard_start;
>>>  	const struct xdp_rxq_info *rxq = xdp->rxq;
>>>  	u32 len = xdp->data_end - xdp->data_meta;
>>> -	u32 truesize = xdp->frame_sz;
>>>  	struct sk_buff *skb = NULL;
>>>  	struct page_pool *pp;
>>>  	int metalen;
>>> -	void *data;
>>>  
>>>  	if (!IS_ENABLED(CONFIG_PAGE_POOL))
>>>  		return NULL;
>>>  
>>>  	local_lock_nested_bh(&system_page_pool.bh_lock);
>>>  	pp = this_cpu_read(system_page_pool.pool);
>>> -	data = page_pool_dev_alloc_va(pp, &truesize);
>>> -	if (unlikely(!data))
>>> -		goto out;
>>>  
>>> -	skb = napi_build_skb(data, truesize);
>>> -	if (unlikely(!skb)) {
>>> -		page_pool_free_va(pp, data, true);
>>> +	skb = xdp_zc_alloc_head(pp, rxq->dev, size);
>>> +	if (unlikely(!skb))
>>>  		goto out;
>>> -	}
>>>  
>>>  	skb_mark_for_recycle(skb);
>>
>> I'd move this call to the bottom of xdp_zc_alloc_head() -- kmalloc'd
>> skbs shouldn't be marked for PP recycling.
> 
> Thanks for the acks, Olek!
> 
> I think we need to keep the mark here. A head from kmalloc can still
> carry pp frags from xdp_copy_frags_from_zc(). pp_recycle applies to
> those frags too, so marking only the pp head would make the kmalloc case
> bypass the pp release path.
> 
> The mark does not change how the head is freed. __alloc_skb() leaves
> head_frag clear, so skb_free_head() calls kfree() without checking
> pp_recycle.

Ack, I completely forgot about the frags =\

Thanks,
Olek

  reply	other threads:[~2026-12-01 14:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:37 [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-11-30 16:41   ` Alexander Lobakin
2026-12-01 12:39   ` netdev-bot+sashiko
2026-11-30 12:37 ` [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-11-30 16:54   ` Alexander Lobakin
2026-12-01  7:12     ` Björn Töpel
2026-12-01 14:08       ` Alexander Lobakin [this message]
2026-12-01 12:39   ` netdev-bot+sashiko
2026-11-30 12:37 ` [PATCH net v2 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-11-30 16:56   ` Alexander Lobakin
2026-11-30 12:37 ` [PATCH net v2 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-01 12:39   ` 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=70b2dc98-9cbb-4e40-881c-4026d9e44b0d@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clecigne@google.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --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=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=willemb@google.com \
    --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