mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
net: ti: icssg-prueth: Fix AF_XDP fill ring alloc and wakeup condition
emac_rx_packet_zc() calls prueth_rx_alloc_zc() with count (frames
received in the current NAPI poll) as the allocation budget. Two
problems arise from this:
1. When the CPPI5 descriptor pool is exhausted (avail_desc == 0,
FDQ already holds the maximum number of descriptors), count > 0
still triggers allocation attempts that all fail, spamming the
kernel log with "rx push: failed to allocate descriptor" at
high packet rates.
2. The XSK wakeup condition "ret < count" is wrong when avail_desc
is zero: ret == 0 and count can be up to 64, so the condition is
always true. This causes ~200 spurious ndo_xsk_wakeup() calls
per second even when the FDQ is already full, wasting CPU cycles
in repeated NAPI invocations that process zero frames.
Fix both by introducing alloc_budget = min(budget, avail_desc):
- When avail_desc == 0 no allocation is attempted, avoiding pool
exhaustion errors. The wakeup condition "ret < alloc_budget"
evaluates to 0 < 0 == false, correctly clearing the wakeup flag
so the hardware IRQ re-arms NAPI without spurious kicks.
- In steady state avail_desc == count <= budget, so alloc_budget
== count and behaviour is unchanged.
- After a dry-ring stall (count == 0, avail_desc > 0), alloc_budget
> 0 causes new descriptors to be posted to the FDQ so the hardware
can resume receiving immediately.
Fixes: 7a64bb388d ("net: ti: icssg-prueth: Add AF_XDP zero copy for RX")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
Link: https://patch.msgid.link/20260611185744.2498070-2-m-malladi@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c66f8511a8
commit
dfb787f7d1
|
|
@ -927,6 +927,7 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id,
|
|||
struct cppi5_host_desc_t *desc_rx;
|
||||
struct prueth_swdata *swdata;
|
||||
dma_addr_t desc_dma, buf_dma;
|
||||
int avail_desc, alloc_budget;
|
||||
struct xdp_buff *xdp;
|
||||
int xdp_status = 0;
|
||||
int count = 0;
|
||||
|
|
@ -993,16 +994,13 @@ static int emac_rx_packet_zc(struct prueth_emac *emac, u32 flow_id,
|
|||
if (xdp_status & ICSSG_XDP_REDIR)
|
||||
xdp_do_flush();
|
||||
|
||||
/* Allocate xsk buffers from the pool for the "count" number of
|
||||
* packets processed in order to be able to receive more packets.
|
||||
*/
|
||||
ret = prueth_rx_alloc_zc(emac, count);
|
||||
avail_desc = k3_cppi_desc_pool_avail(rx_chn->desc_pool);
|
||||
alloc_budget = min_t(int, budget, avail_desc);
|
||||
|
||||
ret = prueth_rx_alloc_zc(emac, alloc_budget);
|
||||
|
||||
if (xsk_uses_need_wakeup(rx_chn->xsk_pool)) {
|
||||
/* If the user space doesn't provide enough buffers then it must
|
||||
* explicitly wake up the kernel when new buffers are available
|
||||
*/
|
||||
if (ret < count)
|
||||
if (ret < alloc_budget)
|
||||
xsk_set_rx_need_wakeup(rx_chn->xsk_pool);
|
||||
else
|
||||
xsk_clear_rx_need_wakeup(rx_chn->xsk_pool);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user