Re: [PATCH bpf-next v3 3/4] xdp: recycle Page Pool backed skbs built from XDP frames

From: Jesper Dangaard Brouer
Date: Thu Mar 16 2023 - 13:11:37 EST



On 15/03/2023 15.58, Alexander Lobakin wrote:
From: Jesper Dangaard Brouer <jbrouer@xxxxxxxxxx>
Date: Wed, 15 Mar 2023 15:55:44 +0100

On 13/03/2023 22.55, Alexander Lobakin wrote:
[...]

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);

I hope this is safe ;-) ... Meaning hopefully drivers does the correct
thing when XDP_REDIRECT'ing page_pool pages.

Safe when it's done by the schoolbook. For now I'm observing only one
syzbot issue with test_run due to that it assumes yet another bunch
o'things I wouldn't rely on :D (separate subthread)


Looking for drivers doing weird refcnt tricks and XDP_REDIRECT'ing, I
noticed the driver aquantia/atlantic (in aq_get_rxpages_xdp), but I now
see this is not using page_pool, so it should be affected by this (but I
worry if atlantic driver have a potential race condition for its refcnt
scheme).

If we encounter some driver using Page Pool, but mangling refcounts on
redirect, we'll fix it ;)


Thanks for signing up for fixing these issues down-the-road :-)

For what is it worth, I've rebased to include this patchset on my
testlab.

For now, I've tested mlx5 with cpumap redirect and net stack processing,
everything seems to be working nicely. When disabling GRO/GRO, then the
cpumap get same and sometimes better TCP throughput performance,
even-though checksum have to be done in software. (Hopefully we can soon
close the missing HW checksum gap with XDP-hints).

--Jesper