🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25027

Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size

#25027
From: Björn Töpel
Date: Tue, 01 Dec 2026 07:12
58 lines
10438 bytes
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.


Björn
Technical Details
Message-ID: <87mrqpzd8a.fsf@all.your.base.are.belong.to.us>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374779-linux-kernel-netdev=dewy.ru
References: <20261130123737.125432-1-bjorn@kernel.org> <20261130123737.125432-3-bjorn@kernel.org> <d260c8da-e0b4-438a-b77c-d3f2c0e01e3c@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374779-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size
Date: Tue, 01 Dec 2026 08:12:05 +0100
Organization: Usenet Network
Message-ID: <87mrqpzd8a.fsf@all.your.base.are.belong.to.us>
References: <20261130123737.125432-1-bjorn@kernel.org> <20261130123737.125432-3-bjorn@kernel.org> <d260c8da-e0b4-438a-b77c-d3f2c0e01e3c@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network; logging-data="1645312"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:I9t9OeOLhcFmP2eEUbzgSdGB9Us= sha256:FHX3Sef8QLS2J5zKCXQSSFJ5GwiIJ6GSTFyeHUV6bIg= sha1:TDE5g0VglG26LS3xbgsRuM0nF3o= sha256:vinQRiqR8XLlBcxrDJLANyEdrbcIRwHy8K1I7pPjUDc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 8DC0A11728B; Tue,  1 Dec 2026 10:12:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QyAkvH5iEH78; Tue,  1 Dec 2026 10:12:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-374779-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 58B7611723D; Tue,  1 Dec 2026 10:12:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 10EB4238D4; Tue,  1 Dec 2026 07:12:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796109135; b=oxP7zlw7R29M2spqxKtcx32VGUdM0NdWEWMIWmw77ALb/8xVZI3Y4zWv7TqzRL2jq3ea W5XEnKExSrnVTdSRXQgXcwVKuYbO3cWK2t1lS7K9uX+zGrWDXfrBhBGBUKE6RDRJudSXJ uZygTjUYuX7YF1W7G5mHZrCAxKqn9yQdsXMUA7L202Rm+wMUrGU1322uUcrbpnwc3gI70 ahDJ5fINeFIab3cI5wlV0e1zT3c9+gc5n1BLkNLtBCqQ0ygcyKl7IOyfYxxe45rBW0W0m 4Im+4KrNJhC/Ip3vCk6EYcX4X6/4qBvAZQzwd8QLzTNLQ3+siFjSd6DPKPicjIeJqgQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109135; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Z3M3ljZ/epHwVmcyPj4jXphHCTQSBEHbofYsMdEZmCc=; b=T1JAnpPIxQvAE/H9wTFpxYmpay1s4DUIAIa+U4luj+9aVfKR2sLhyK5I2fWEJ0R6mjvV XgMYTJUFs4LsT93CTs5xv15i46Asceud3RZbkAi8mH8yiMSAIjuJ4DlhFgU9e5yiHomAb GaZZ9OMSSQVnfV20ZDboZDQAq9MhOWWGykEtd/cIu2O3VK9BhMqG9Uzwiuem6UzU1nf7U h8g5ajBIcNGVX3lNLs7e//Eb7tFl0fCRN9mQ/5yZ0c7gVI7BqcKgECJEiBKzK5nfcmY2k rGUTjxcepb3S6VlQS4QsRJOld3pFZshriJ8lyy0qBc6NdEpI6/xdq4cbc1iGT4GCa6g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=l8xZf2zt; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AC5E606A681; Tue,  1 Dec 2026 07:12:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=l8xZf2zt
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796109129; b=TIj6ljoQGRi8750cVdP59UOzwy/PqTB9kmrhbiRQwfn3I/amyVSi+ibnjvRV+E+wIpFv Eym7WMIHFwFQLQSl41n/x8Z9yB8uYziPemMq6RVe0Oe1GvpU7puJ3reNruG+LZSWlJb3k KLkeFl0jtVaPlxUjSXbyxDx7GKI2kG4LOS2lYXJ8RvQJ8DAspenDqOlA0QKhqOIjVQUDO K/Rc3Geo+awY8GnfSaPPIPXPb+Pp+mS6sxCjkMnWdLtJHOyDpNgTuWOjcvg42bHFmLsSK 7qGfXrnitOG18zyZEy2OA9TbdAaPaudM0Q+ivwLCjcvtFq2h4Fcs7bXdJ7MpjYjMHwg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109129; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Z3M3ljZ/epHwVmcyPj4jXphHCTQSBEHbofYsMdEZmCc=; b=bjb3ipgPoh40eRIc1lKPZwsP+LNxGtSKetlYOAplicQhmiJnXsGQOVRv6wLcJhRb2rgv g8b7x/EksusWb5rAZyXfJfzCzCQCTq8unMgAx1kIwB45sI1IN/6E7AxXSeu9zKawYP+uG TgFRsT0ljsZ53aYWsrIHuuyz9dOSuEDar2bPbID1B+lz6jCD8ZJs/D9q1xfd4GKnCF8Qn apC4edn0WzuuQJgqn1AvJk1b6zCuXgIJFUdcdw/mQlrltKscOfvKP/YXFjsavodezjc1D atdKmdZ7Sa5IzneLsbmsExA9BOjRntbggYEkU1HndC6UB4Y3/aQFLw64N+cpRH8OCbw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=l8xZf2zt; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96845606A332; Tue,  1 Dec 2026 07:12:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC841F000C1; Tue,  1 Dec 2026 07:12:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796109129; bh=Z3M3ljZ/epHwVmcyPj4jXphHCTQSBEHbofYsMdEZmCc=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=l8xZf2zts/Kv7Z1s4VaSBs5WfZvxWveeOROlXqTIVw9q5QpDehyi2rSPTiMSqxbNE HF2W0oTUb7StCvpJgnWm0Fh0/9nvja9iqITKN1FsyrHvHLcFoL2et8Czm9i8cOLwTX hFsUtqt15eIkft3SWZ9z4KKxNWBjL/kCITKLAvE/Zr6nARhfRPtWRorEN/ftxgccxB uKjQwuhGZ50acC3FtjfA3Ii5IqnqXrFEDmS5dnczihrzrU9bJjqzssu2eQ9SPD0fOz Q+Z/x8a/zFLRrsY8i3HLQBXVe2FFHeqJi5FNSfyjR8stKAG+vDyFpmLRxZfi90QLME LLsB/LFEEnwaw==
X-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>
X-In-Reply-To: <d260c8da-e0b4-438a-b77c-d3f2c0e01e3c@intel.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list