* [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring
@ 2026-11-18 13:59 Magnus Karlsson
2026-11-18 14:18 ` Maciej Fijalkowski
0 siblings, 1 reply; 4+ messages in thread
From: Magnus Karlsson @ 2026-11-18 13:59 UTC (permalink / raw)
To: magnus.karlsson, magnus.karlsson, intel-wired-lan,
anthony.l.nguyen, maciej.fijalkowski, przemyslaw.kitszel
xdp_tx_active counts the XDP_TX buffers on an XDP ring, so that
ice_clean_xdp_irq_zc() can complete AF_XDP zero-copy frames in bulk when
there are none. It is incremented for every XDP_TX frame and decremented
when such a frame completes. ice_clean_tx_ring() frees the frames that
are still on the ring, both through ice_xsk_clean_xdp_ring() and through
ice_unmap_and_free_tx_buf(), but leaves the counter as it was.
After a ring is cleaned with XDP_TX frames in flight, for example when
an AF_XDP socket is bound or unbound, xdp_tx_active therefore stays
non-zero for the lifetime of the ring. ice_clean_xdp_irq_zc() then
always takes the per-descriptor slow path.
The ring is empty after ice_clean_tx_ring(), so reset the counter
there, together with next_to_use and next_to_clean.
Fixes: 59e92bfe4df7 ("ice: xsk: Borrow xdp_tx_active logic from i40e")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 35a480a1e172..f26646825a1e 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -228,6 +228,7 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
tx_ring->next_to_use = 0;
tx_ring->next_to_clean = 0;
+ tx_ring->xdp_tx_active = 0;
if (!tx_ring->netdev)
return;
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring
2026-11-18 13:59 [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring Magnus Karlsson
@ 2026-11-18 14:18 ` Maciej Fijalkowski
2026-11-18 14:32 ` Magnus Karlsson
0 siblings, 1 reply; 4+ messages in thread
From: Maciej Fijalkowski @ 2026-11-18 14:18 UTC (permalink / raw)
To: Magnus Karlsson
Cc: magnus.karlsson, intel-wired-lan, anthony.l.nguyen,
przemyslaw.kitszel
On Wed, Nov 18, 2026 at 02:59:20PM +0100, Magnus Karlsson wrote:
> xdp_tx_active counts the XDP_TX buffers on an XDP ring, so that
> ice_clean_xdp_irq_zc() can complete AF_XDP zero-copy frames in bulk when
> there are none. It is incremented for every XDP_TX frame and decremented
> when such a frame completes. ice_clean_tx_ring() frees the frames that
> are still on the ring, both through ice_xsk_clean_xdp_ring() and through
> ice_unmap_and_free_tx_buf(), but leaves the counter as it was.
>
> After a ring is cleaned with XDP_TX frames in flight, for example when
> an AF_XDP socket is bound or unbound, xdp_tx_active therefore stays
> non-zero for the lifetime of the ring. ice_clean_xdp_irq_zc() then
> always takes the per-descriptor slow path.
>
> The ring is empty after ice_clean_tx_ring(), so reset the counter
> there, together with next_to_use and next_to_clean.
Has that ever happen on your side?
Maybe to be sure we are not leaking buffers we should teach
ice_xsk_clean_xdp_ring() to decrement xdp_tx_active for ICE_TX_BUF_XSK_TX
and on ice_clean_tx_ring() warn if xdp_tx_active is still non-zero?
Feels a bit rigoristic, but I think I stumbled upon some off-by-one bugs
where we rely on ntc != ntu loop. non-xsk clean goes 0..count.
>
> Fixes: 59e92bfe4df7 ("ice: xsk: Borrow xdp_tx_active logic from i40e")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
> index 35a480a1e172..f26646825a1e 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> @@ -228,6 +228,7 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
>
> tx_ring->next_to_use = 0;
> tx_ring->next_to_clean = 0;
> + tx_ring->xdp_tx_active = 0;
>
> if (!tx_ring->netdev)
> return;
> --
> 2.38.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring
2026-11-18 14:18 ` Maciej Fijalkowski
@ 2026-11-18 14:32 ` Magnus Karlsson
2026-11-18 15:48 ` Maciej Fijalkowski
0 siblings, 1 reply; 4+ messages in thread
From: Magnus Karlsson @ 2026-11-18 14:32 UTC (permalink / raw)
To: Maciej Fijalkowski
Cc: Magnus Karlsson, intel-wired-lan, anthony.l.nguyen,
przemyslaw.kitszel
On Wed, 18 Nov 2026 at 15:18, Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> On Wed, Nov 18, 2026 at 02:59:20PM +0100, Magnus Karlsson wrote:
> > xdp_tx_active counts the XDP_TX buffers on an XDP ring, so that
> > ice_clean_xdp_irq_zc() can complete AF_XDP zero-copy frames in bulk when
> > there are none. It is incremented for every XDP_TX frame and decremented
> > when such a frame completes. ice_clean_tx_ring() frees the frames that
> > are still on the ring, both through ice_xsk_clean_xdp_ring() and through
> > ice_unmap_and_free_tx_buf(), but leaves the counter as it was.
> >
> > After a ring is cleaned with XDP_TX frames in flight, for example when
> > an AF_XDP socket is bound or unbound, xdp_tx_active therefore stays
> > non-zero for the lifetime of the ring. ice_clean_xdp_irq_zc() then
> > always takes the per-descriptor slow path.
> >
> > The ring is empty after ice_clean_tx_ring(), so reset the counter
> > there, together with next_to_use and next_to_clean.
>
> Has that ever happen on your side?
Nope, but I never use XDP_TX to be honest.
> Maybe to be sure we are not leaking buffers we should teach
> ice_xsk_clean_xdp_ring() to decrement xdp_tx_active for ICE_TX_BUF_XSK_TX
> and on ice_clean_tx_ring() warn if xdp_tx_active is still non-zero?
Sure, but does that belong in this patch?
> Feels a bit rigoristic, but I think I stumbled upon some off-by-one bugs
> where we rely on ntc != ntu loop. non-xsk clean goes 0..count.
>
> >
> > Fixes: 59e92bfe4df7 ("ice: xsk: Borrow xdp_tx_active logic from i40e")
> > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > ---
> > drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > index 35a480a1e172..f26646825a1e 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > @@ -228,6 +228,7 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
> >
> > tx_ring->next_to_use = 0;
> > tx_ring->next_to_clean = 0;
> > + tx_ring->xdp_tx_active = 0;
> >
> > if (!tx_ring->netdev)
> > return;
> > --
> > 2.38.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring
2026-11-18 14:32 ` Magnus Karlsson
@ 2026-11-18 15:48 ` Maciej Fijalkowski
0 siblings, 0 replies; 4+ messages in thread
From: Maciej Fijalkowski @ 2026-11-18 15:48 UTC (permalink / raw)
To: Magnus Karlsson
Cc: Magnus Karlsson, intel-wired-lan, anthony.l.nguyen,
przemyslaw.kitszel
On Wed, Nov 18, 2026 at 03:32:40PM +0100, Magnus Karlsson wrote:
> On Wed, 18 Nov 2026 at 15:18, Maciej Fijalkowski
> <maciej.fijalkowski@intel.com> wrote:
> >
> > On Wed, Nov 18, 2026 at 02:59:20PM +0100, Magnus Karlsson wrote:
> > > xdp_tx_active counts the XDP_TX buffers on an XDP ring, so that
> > > ice_clean_xdp_irq_zc() can complete AF_XDP zero-copy frames in bulk when
> > > there are none. It is incremented for every XDP_TX frame and decremented
> > > when such a frame completes. ice_clean_tx_ring() frees the frames that
> > > are still on the ring, both through ice_xsk_clean_xdp_ring() and through
> > > ice_unmap_and_free_tx_buf(), but leaves the counter as it was.
> > >
> > > After a ring is cleaned with XDP_TX frames in flight, for example when
> > > an AF_XDP socket is bound or unbound, xdp_tx_active therefore stays
> > > non-zero for the lifetime of the ring. ice_clean_xdp_irq_zc() then
> > > always takes the per-descriptor slow path.
> > >
> > > The ring is empty after ice_clean_tx_ring(), so reset the counter
> > > there, together with next_to_use and next_to_clean.
> >
> > Has that ever happen on your side?
>
> Nope, but I never use XDP_TX to be honest.
>
> > Maybe to be sure we are not leaking buffers we should teach
> > ice_xsk_clean_xdp_ring() to decrement xdp_tx_active for ICE_TX_BUF_XSK_TX
> > and on ice_clean_tx_ring() warn if xdp_tx_active is still non-zero?
>
> Sure, but does that belong in this patch?
Yes - i was saying it would be better to decrement it and see if are back
at 0 rather than blindly reset the counter.
I assume you could unbound the socket but keep the pool and when you
attach the pool again you might be lighter leaked buffers.
>
> > Feels a bit rigoristic, but I think I stumbled upon some off-by-one bugs
> > where we rely on ntc != ntu loop. non-xsk clean goes 0..count.
> >
> > >
> > > Fixes: 59e92bfe4df7 ("ice: xsk: Borrow xdp_tx_active logic from i40e")
> > > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > > ---
> > > drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > > index 35a480a1e172..f26646825a1e 100644
> > > --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> > > +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > > @@ -228,6 +228,7 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
> > >
> > > tx_ring->next_to_use = 0;
> > > tx_ring->next_to_clean = 0;
> > > + tx_ring->xdp_tx_active = 0;
> > >
> > > if (!tx_ring->netdev)
> > > return;
> > > --
> > > 2.38.1
> > >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 15:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 13:59 [PATCH iwl-net] ice: reset xdp_tx_active when cleaning a Tx ring Magnus Karlsson
2026-11-18 14:18 ` Maciej Fijalkowski
2026-11-18 14:32 ` Magnus Karlsson
2026-11-18 15:48 ` Maciej Fijalkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox