From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC841F000C1; Tue, 1 Dec 2026 07:12:08 +0000 (UTC) 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== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Alexander Lobakin Cc: Magnus Karlsson , Maciej Fijalkowski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , netdev@vger.kernel.org, bpf@vger.kernel.org, Simon Horman , Stanislav Fomichev , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Tony Nguyen , Przemek Kitszel , intel-wired-lan@lists.osuosl.org, =?utf-8?Q?Cl=C3=A9ment?= Lecigne Subject: Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size In-Reply-To: References: <20261130123737.125432-1-bjorn@kernel.org> <20261130123737.125432-3-bjorn@kernel.org> Date: Tue, 01 Dec 2026 08:12:05 +0100 Message-ID: <87mrqpzd8a.fsf@all.your.base.are.belong.to.us> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alexander Lobakin writes: > From: Bj=C3=B6rn T=C3=B6pel > 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 =3D xdp->data_end - xdp->data_hard_start; >> const struct xdp_rxq_info *rxq =3D xdp->rxq; >> u32 len =3D xdp->data_end - xdp->data_meta; >> - u32 truesize =3D xdp->frame_sz; >> struct sk_buff *skb =3D NULL; >> struct page_pool *pp; >> int metalen; >> - void *data; >>=20=20 >> if (!IS_ENABLED(CONFIG_PAGE_POOL)) >> return NULL; >>=20=20 >> local_lock_nested_bh(&system_page_pool.bh_lock); >> pp =3D this_cpu_read(system_page_pool.pool); >> - data =3D page_pool_dev_alloc_va(pp, &truesize); >> - if (unlikely(!data)) >> - goto out; >>=20=20 >> - skb =3D napi_build_skb(data, truesize); >> - if (unlikely(!skb)) { >> - page_pool_free_va(pp, data, true); >> + skb =3D xdp_zc_alloc_head(pp, rxq->dev, size); >> + if (unlikely(!skb)) >> goto out; >> - } >>=20=20 >> 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=C3=B6rn