[Linux-stm32] [PATCH net-next 2/2] igb: xsk: solve underflow of nb_pkts in zerocopy mode
Jason Xing
kerneljasonxing at gmail.com
Mon Jul 21 10:22:05 UTC 2025
Hi Simon,
On Mon, Jul 21, 2025 at 6:12 PM Simon Horman <horms at kernel.org> wrote:
>
> On Mon, Jul 21, 2025 at 04:33:43PM +0800, Jason Xing wrote:
> > From: Jason Xing <kernelxing at tencent.com>
> >
> > There is no break time in the while() loop, so every time at the end of
> > igb_xmit_zc(), underflow of nb_pkts will occur, which renders the return
> > value always false. But theoretically, the result should be set after
> > calling xsk_tx_peek_release_desc_batch(). We can take i40e_xmit_zc() as
> > a good example.
> >
> > Returning false means we're not done with transmission and we need one
> > more poll, which is exactly what igb_xmit_zc() always did before this
> > patch. After this patch, the return value depends on the nb_pkts value.
> > Two cases might happen then:
> > 1. if (nb_pkts < budget), it means we process all the possible data, so
> > return true and no more necessary poll will be triggered because of
> > this.
> > 2. if (nb_pkts == budget), it means we might have more data, so return
> > false to let another poll run again.
> >
> > Fixes: f8e284a02afc ("igb: Add AF_XDP zero-copy Tx support")
> > Signed-off-by: Jason Xing <kernelxing at tencent.com>
> > ---
> > drivers/net/ethernet/intel/igb/igb_xsk.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
> > index 5cf67ba29269..243f4246fee8 100644
> > --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> > +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> > @@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)
> > if (!nb_pkts)
> > return true;
> >
> > - while (nb_pkts-- > 0) {
> > + while (i < nb_pkts) {
>
> Hi Jason,
>
> FWIIW, I think using a for loop is a more idiomatic way
> of handling the relationship between i, nb_pkts, and
> the iterations of this loop.
Sure, I can turn it into 'for (i = 0; i < nb_pkts; i++)' in the next version.
Thanks,
Jason
More information about the Linux-stm32
mailing list