Skip to contentSkip to conversation

ixgbe: tweak page counting for XDP_REDIRECT

PATCH Superseded Björn Töpel 2 participants 2 messages Mar 22, 2018 – Mar 23, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ixgbe: tweak page counting for XDP_REDIRECT

From: Bj?rn T?pel <[email protected]>

The current page counting scheme assumes that the reference count cannot decrease until the received frame is sent to the upper layers of the networking stack. This assumption does not hold for the XDP_REDIRECT action, since a page (pointed out by xdp_buff) can have its reference count decreased via the xdp_do_redirect call.

To work around that, we now start off by a large page count and then don't allow a refcount less than two.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4 -3
index fb80edbd2739..8dbb2ce06287 100644
@@ -1629,7 +1629,8 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
 	bi->dma = dma;
 	bi->page = page;
 	bi->page_offset = ixgbe_rx_offset(rx_ring);
-	bi->pagecnt_bias = 1;
+	page_ref_add(page, USHRT_MAX - 1);
+	bi->pagecnt_bias = USHRT_MAX;
 	rx_ring->rx_stats.alloc_rx_page++;
 
 	return true;
@@ -2039,8 +2040,8 @@ static bool ixgbe_can_reuse_rx_page(struct ixgbe_rx_buffer *rx_buffer)
 	 * the pagecnt_bias and page count so that we fully restock the
 	 * number of references the driver holds.
 	 */
-	if (unlikely(!pagecnt_bias)) {
-		page_ref_add(page, USHRT_MAX);
+	if (unlikely(pagecnt_bias == 1)) {
+		page_ref_add(page, USHRT_MAX - 1);
 		rx_buffer->pagecnt_bias = USHRT_MAX;
 	}
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 ixgbe: tweak page counting for XDP_REDIRECT

Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Bj?rn T?pel
Sent: Thursday, March 22, 2018 2:03 AM
To: Kirsher, Jeffrey T <[email protected]>; intel-wired- lan at lists.osuosl.org
Cc: netdev at vger.kernel.org; Topel, Bjorn <[email protected]>; Karlsson, Magnus <[email protected]>
Subject: [Intel-wired-lan] [PATCH] ixgbe: tweak page counting for XDP_REDIRECT

From: Bj?rn T?pel <[email protected]>

The current page counting scheme assumes that the reference count cannot decrease until the received frame is sent to the upper layers of the networking stack. This assumption does not hold for the XDP_REDIRECT action, since a page (pointed out by xdp_buff) can have its reference count decreased via the xdp_do_redirect call.

Quoted 7 lines

To work around that, we now start off by a large page count and then don't allow a refcount less than two.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)