Skip to content

Commit afbed3f

Browse files
kuba-moodavem330
authored andcommitted
net/mlx5e: do as little as possible in napi poll when budget is 0
NAPI gets called with budget of 0 from netpoll, which has interrupts disabled. We should try to free some space on Tx rings and nothing else. Specifically do not try to handle XDP TX or try to refill Rx buffers - we can't use the page pool from IRQ context. Don't check if IRQs moved, either, that makes no sense in netpoll. Netpoll calls _all_ the rings from whatever CPU it happens to be invoked on. In general do as little as possible, the work quickly adds up when there's tens of rings to poll. The immediate stack trace I was seeing is: __do_softirq+0xd1/0x2c0 __local_bh_enable_ip+0xc7/0x120 </IRQ> <TASK> page_pool_put_defragged_page+0x267/0x320 mlx5e_free_xdpsq_desc+0x99/0xd0 mlx5e_poll_xdpsq_cq+0x138/0x3b0 mlx5e_napi_poll+0xc3/0x8b0 netpoll_poll_dev+0xce/0x150 AFAIU page pool takes a BH lock, releases it and since BH is now enabled tries to run softirqs. Reviewed-by: Tariq Toukan <[email protected]> Fixes: 60bbf7e ("mlx5: use page_pool for xdp_return_frame call") Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2897041 commit afbed3f

File tree

1 file changed

+9
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+9
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,22 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
161161
}
162162
}
163163

164+
/* budget=0 means we may be in IRQ context, do as little as possible */
165+
if (unlikely(!budget))
166+
goto out;
167+
164168
busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq);
165169

166170
if (c->xdp)
167171
busy |= mlx5e_poll_xdpsq_cq(&c->rq_xdpsq.cq);
168172

169-
if (likely(budget)) { /* budget=0 means: don't poll rx rings */
170-
if (xsk_open)
171-
work_done = mlx5e_poll_rx_cq(&xskrq->cq, budget);
173+
if (xsk_open)
174+
work_done = mlx5e_poll_rx_cq(&xskrq->cq, budget);
172175

173-
if (likely(budget - work_done))
174-
work_done += mlx5e_poll_rx_cq(&rq->cq, budget - work_done);
176+
if (likely(budget - work_done))
177+
work_done += mlx5e_poll_rx_cq(&rq->cq, budget - work_done);
175178

176-
busy |= work_done == budget;
177-
}
179+
busy |= work_done == budget;
178180

179181
mlx5e_poll_ico_cq(&c->icosq.cq);
180182
if (mlx5e_poll_ico_cq(&c->async_icosq.cq))

0 commit comments

Comments
 (0)