From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Yunsheng Lin <linyunsheng@huawei.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>
Cc: brouer@redhat.com,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Larysa Zaremba" <larysa.zaremba@intel.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Song Liu" <song@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 1/2] xdp: recycle Page Pool backed skbs built from XDP frames
Date: Fri, 3 Mar 2023 11:31:35 +0100 [thread overview]
Message-ID: <ac7c7be0-656a-8b5a-c629-e135e39f844a@redhat.com> (raw)
In-Reply-To: <36d42e20-b33f-5442-0db7-e9f5ef9d0941@huawei.com>
On 02/03/2023 03.30, Yunsheng Lin wrote:
> On 2023/3/2 0:03, Alexander Lobakin wrote:
>> __xdp_build_skb_from_frame() state(d):
>>
>> /* Until page_pool get SKB return path, release DMA here */
>>
>> Page Pool got skb pages recycling in April 2021, but missed this
>> function.
>>
>> xdp_release_frame() is relevant only for Page Pool backed frames and it
>> detaches the page from the corresponding Pool in order to make it
>> freeable via page_frag_free(). It can instead just mark the output skb
>> as eligible for recycling if the frame is backed by a PP. No change for
>> other memory model types (the same condition check as before).
>> cpumap redirect and veth on Page Pool drivers now become zero-alloc (or
>> almost).
>>
>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> ---
>> net/core/xdp.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/core/xdp.c b/net/core/xdp.c
>> index 8c92fc553317..a2237cfca8e9 100644
>> --- a/net/core/xdp.c
>> +++ b/net/core/xdp.c
>> @@ -658,8 +658,8 @@ struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf,
>> * - RX ring dev queue index (skb_record_rx_queue)
>> */
>>
>> - /* Until page_pool get SKB return path, release DMA here */
>> - xdp_release_frame(xdpf);
>> + if (xdpf->mem.type == MEM_TYPE_PAGE_POOL)
>> + skb_mark_for_recycle(skb);
>
>
> We both rely on both skb->pp_recycle and page->pp_magic to decide
> the page is really from page pool. So there was a few corner case
> problem when we are sharing a page for different skb in the driver
> level or calling skb_clone() or skb_try_coalesce().
> see:
> https://github.com/torvalds/linux/commit/2cc3aeb5ecccec0d266813172fcd82b4b5fa5803
> https://lore.kernel.org/netdev/MW5PR15MB51214C0513DB08A3607FBC1FBDE19@MW5PR15MB5121.namprd15.prod.outlook.com/t/
> https://lore.kernel.org/netdev/167475990764.1934330.11960904198087757911.stgit@localhost.localdomain/
>
> As the 'struct xdp_frame' also use 'struct skb_shared_info' which is
> sharable, see xdp_get_shared_info_from_frame().
>
> For now xdpf_clone() does not seems to handling frag page yet,
> so it should be fine for now.
>
> IMHO we should find a way to use per-page marker, instead of both
> per-skb and per-page markers, in order to avoid the above problem
> for xdp if xdp has a similar processing as skb, as suggested by Eric.
>
Moving to a per-page marker can be *more* expensive if the struct-page
memory isn't cache-hot. So, if struct-page is accessed anyhow then sure
we can move it to a per-page marker.
> https://lore.kernel.org/netdev/CANn89iKgZU4Q+THXupzZi4hETuKuCOvOB=iHpp5JzQTNv_Fg_A@mail.gmail.com/
>
>>
>> /* Allow SKB to reuse area used by xdp_frame */
>> xdp_scrub_frame(xdpf);
>>
>
next prev parent reply other threads:[~2023-03-03 10:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 16:03 [PATCH bpf-next v1 0/2] xdp: recycle Page Pool backed skbs built from XDP frames Alexander Lobakin
2023-03-01 16:03 ` [PATCH bpf-next v1 1/2] " Alexander Lobakin
2023-03-01 19:08 ` kernel test robot
2023-03-01 19:18 ` kernel test robot
2023-03-02 2:30 ` Yunsheng Lin
2023-03-03 10:31 ` Jesper Dangaard Brouer [this message]
2023-03-03 11:22 ` Alexander Lobakin
2023-03-03 12:44 ` Yunsheng Lin
2023-03-03 13:26 ` Alexander Lobakin
2023-03-06 1:09 ` Yunsheng Lin
2023-03-06 11:58 ` Alexander Lobakin
2023-03-07 2:50 ` Yunsheng Lin
2023-03-07 18:14 ` Alexander Lobakin
2023-03-08 6:27 ` Yunsheng Lin
2023-03-09 16:27 ` Alexander Lobakin
2023-03-01 16:03 ` [PATCH bpf-next v1 2/2] xdp: remove unused {__,}xdp_release_frame() Alexander Lobakin
2023-03-03 10:39 ` [PATCH bpf-next v1 0/2] xdp: recycle Page Pool backed skbs built from XDP frames Jesper Dangaard Brouer
2023-03-03 11:31 ` Alexander Lobakin
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=ac7c7be0-656a-8b5a-c629-e135e39f844a@redhat.com \
--to=jbrouer@redhat.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=hawk@kernel.org \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linyunsheng@huawei.com \
--cc=maciej.fijalkowski@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=toke@redhat.com \
/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