The GVE RX NAPI will continue polling as long as
1) there are packets to be processed, and
2) less than NAPI budget SKBs (denoted in GVE by work_done) have been
passed up to the kernel.
However, GVE does not account for all of the packets that don't create
SKBs, namely error packets and XDP packets.
This can result in XDP programs that scarcely return XDP_PASS failing to
exit the NAPI poll as long as the NIC is DMA'ing packets, possibly
processing the entire RX ring before returning from the NAPI.
This has 3 negative implications:
1) XDP RX path can run much longer than is desirable, hogging CPU
resources.
2) If XDP_PASS is never returned, the work_done never increases beyond
0, which can lead to scheduling delays due to missed chances to
reschedule the NAPI.
3) In AF_XDP zero-copy, XSK_TX occurs after the RX poll. If the RX poll
takes a long time, it will delay TX, leading to degraded performance.
Ensure every packet is accounted for in work_done by incrementing
work_done before checking for the existence of a SKB.
Fixes: 293b49361f91 ("gve: add XDP DROP and PASS support for DQ")
Cc: stable@vger.kernel.org
Reviewed-by: Tim Hostetler <redacted>
Reviewed-by: Jordan Rhee <redacted>
Signed-off-by: Joshua Washington <joshwash@google.com>
---
drivers/net/ethernet/google/gve/gve_rx_dqo.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
index 0ece2f6fdffb..db38bc645296 100644
--- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
@@ -1145,13 +1145,14 @@ int gve_rx_poll_dqo(struct gve_notify_block *block, int budget)
/* Free running counter of completed descriptors */
rx->cnt++;
- if (!rx->ctx.skb_head)
- continue;
-
if (!compl_desc->end_of_packet)
continue;
work_done++;
+
+ if (!rx->ctx.skb_head)
+ continue;
+
pkt_bytes = rx->ctx.skb_head->len;
/* The ethernet header (first ETH_HLEN bytes) is snipped off
* by eth_type_trans.
--
2.55.0.691.gc56d675ccc-goog