igc: Fix Tx hangs after NETDEV_TX_BUSY with TSO
Subsystems (3)
cover igc: Fix Tx hangs after NETDEV_TX_BUSY with TSO
Since commit db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit"), igc_xmit_frame_ring() requires count + 5 free descriptors, while the queue is only stopped in advance below DESC_NEEDED = MAX_SKB_FRAGS + 4. TSO skbs with 16 or 17 fragments then hit NETDEV_TX_BUSY. That return skips the tail write deferred by xmit_more, so the queue can stay stopped with descriptors the hardware never saw, until the Tx watchdog resets the adapter.
Patch 1 aligns DESC_NEEDED with the admission check. Patch 2 writes the tail before returning NETDEV_TX_BUSY, which remains reachable for skbs with buffers larger than IGC_MAX_DATA_PER_TXD. Each patch was tested alone; together they keep the queue stop logic consistent and the remaining busy path safe.
Setup: CWWK router, Pentium Gold 8505, six I226-V (8086:125c rev 04, NVM 2017:888d), 7.2.8, default MAX_SKB_FRAGS = 17. Load: CPU saturated with busy loops, a remote build routed through the port, two SSH bulk streams in each direction and short TCP bursts, 180 seconds of load per run observed during a 195-second probe window, TSO enabled on the egress port. bpftrace probes on igc_xmit_frame, __igc_maybe_stop_tx and igc_poll recorded NETDEV_TX_BUSY returns, the inferred last tail write and next_to_clean stalls.
runs Tx timeouts NETDEV_TX_BUSY TX_OK returns
unpatched 7.2.8 3 25 10890 7.3M patch 2 only 3 0 10751 9.5M patch 1 only 3 0 0 8.8M both patches 3 0 0 9.4M unpatched, TSO off 1 0 0 21.5M
In all 25 timeout episodes, the stalled queue had pending descriptors after a NETDEV_TX_BUSY return. The probes inferred at least 214 descriptors beyond the last tail write. For that queue, the hardware register dump showed TDH = TDT = the next_to_clean value recorded by the probe.
With both patches applied, no NETDEV_TX_BUSY occurred, so the flush path of patch 2 was not exercised in that run; its effect is shown by the patch 2 only runs.
TX_OK returns count igc_xmit_frame() calls returning NETDEV_TX_OK, excluding NETDEV_TX_BUSY retries. These are software call counts, not hardware packet counters; with TSO disabled, segmentation occurs before the driver.
Related code, not addressed in this series and not tested:
- bnxt: commit e8d8c5d80f5e ("bnxt: make sure xmit_more + errors does not miss doorbells") rings a pending doorbell on the drop paths. It leaves the busy path alone, reasoning that busy can only happen if start_xmit races with completions that both enable the queue, in which case no kick can be pending; the current code warns "ring busy w/ flush pending!" if that assumption breaks. In igc, patch 1 restores that property for skbs whose buffers each fit in one descriptor, and patch 2 covers the remaining case.
- igc drop paths (skb_put_padto() failure in igc_xmit_frame(), out_drop in igc_xmit_frame_ring(), the DMA mapping error path of igc_tx_map()) also return without writing a pending tail, the case bnxt fixed in e8d8c5d80f5e and 00eeab0c644a ("bnxt_en: Write doorbell when linearizing skb fails"). The queue is not stopped there, so pending descriptors are delayed until the next transmit on that queue rather than stranded.
- igb, ixgbe, fm10k, i40e, iavf, ice, e1000e and e1000 also defer the tail write with xmit_more and return NETDEV_TX_BUSY from their admission check without writing it. Their stop thresholds match their admission checks, so this should only be reachable for skbs needing more descriptors than the stop threshold assumes.
Not done:
- runtime test on a kernel built from this tree; the patches were tested on 7.2.8, where the affected code is identical, and apply cleanly here;
- launch time (ETF/taprio) and XDP/AF_XDP traffic, which share the ring and the wake threshold;
- longer runs and other I226/I225 boards;
- only the igc objects were built with W=1 under allmodconfig, not the full tree.
The analysis and the patches were prepared with an LLM-based coding assistant, which also wrote the bpftrace probes; the results above come from those probes and the kernel log on real hardware.
Benoit DE RANCOURT (2):
igc: Fix Tx stop threshold to cover empty frame descriptors
igc: Flush pending Tx descriptors before returning NETDEV_TX_BUSY
drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-)
base-commit: a83267db14681b3be481e02a4d5a38177507006c
Signature · 1 line
2.55.0
PATCH 1/2 igc: Fix Tx stop threshold to cover empty frame descriptors
Commit db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") raised the number of free descriptors that igc_xmit_frame_ring() requires before mapping a packet from count + 3 to count + 5, to leave room for the empty frame (one context and one data descriptor) that may be inserted ahead of a launch time packet. DESC_NEEDED was left at MAX_SKB_FRAGS + 4. igc_tx_map() uses it to stop the queue in advance, and TX_WAKE_THRESHOLD is derived from it.
A queue left running after a transmit therefore only guarantees MAX_SKB_FRAGS + 4 free descriptors, while the next skb with a linear part and MAX_SKB_FRAGS fragments, each fitting in one data descriptor, requires MAX_SKB_FRAGS + 6. igc_xmit_frame_ring() then returns NETDEV_TX_BUSY, which the queue stop logic is meant to prevent.
With TSO this happens routinely. On an I226-V (8086:125c) running 7.2.8 with MAX_SKB_FRAGS = 17, routed and locally generated TCP traffic on a CPU-saturated router produced 10890 NETDEV_TX_BUSY returns in three runs of 180 seconds, all for TSO skbs with 16 or 17 fragments, with 21 or 22 free descriptors in all but 5 cases. Together with deferred tail writes (xmit_more), these returns led to 25 Tx timeouts and adapter resets in the same runs:
igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2 timed out 5353 ms igc 0000:08:00.0 terra: Reset adapter
The following patch addresses the lost tail write itself.
Raise DESC_NEEDED to MAX_SKB_FRAGS + 6 to match the admission check. The additional reservation is currently unconditional, including when launch time is disabled; match that existing admission policy in the proactive stop threshold. With MAX_SKB_FRAGS = 17, the queue is now stopped below 23 free descriptors instead of 21. This also raises the completion-based wake threshold from 42 to 46 free descriptors, preserving the existing two-times-stop-threshold policy. Throughput and latency effects were not measured.
With this change alone, three runs of the same test on 7.2.8 produced no NETDEV_TX_BUSY and no Tx timeout over 8.8M NETDEV_TX_OK returns, including 613k TSO skbs with 17 fragments.
As before commit db0b124f02ba, an skb whose linear part or fragments exceed IGC_MAX_DATA_PER_TXD may still need more descriptors than DESC_NEEDED accounts for.
--- drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +6 -2
@@ -575,9 +575,13 @@ enum igc_boards {#define IGC_MAX_TXD_PWR 15#define IGC_MAX_DATA_PER_TXD BIT(IGC_MAX_TXD_PWR) -/* Tx Descriptors needed, worst case */ #define TXD_USE_COUNT (S ) DIV_ROUND_UP((S), IGC_MAX_DATA_PER_TXD) -#define DESC_NEEDED (MAX_SKB_FRAGS + 4) + +/* Tx descriptor budget for a head and MAX_SKB_FRAGS fragments, +* each fitting in one data descriptor: one context descriptor, +* two descriptors for an optional empty frame, and two spare entries. +*/ +#define DESC_NEEDED (MAX_SKB_FRAGS + 6) struct igc_rx_buffer { union {
base-commit: a83267db14681b3be481e02a4d5a38177507006c
Signature · 1 line
2.55.0
RE: [PATCH iwl-net 1/2] igc: Fix Tx stop threshold to cover empty frame descriptors
Quoted 95 lines
-----Original Message-----
From: Benoit DE RANCOURT <[email protected]>
Sent: Sunday, October 4, 2026 5:29 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; intel-wired- [email protected]
Cc: [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Gomes, Vinicius <[email protected]>; Sasha Neftin <[email protected]>; [email protected]; Benoit DE RANCOURT <[email protected]>
Subject: [PATCH iwl-net 1/2] igc: Fix Tx stop threshold to cover empty frame descriptorsCommit
db0b124f02ba("igc: Enhance Qbv scheduling by using first flag bit") raised the number of free descriptors thatigc_xmit_frame_ring()requires before mapping a packet from count + 3 to count + 5, to leave room for the empty frame (one context and one data descriptor) that may be inserted ahead of a launch time packet.DESC_NEEDEDwas left atMAX_SKB_FRAGS+ 4.igc_tx_map()uses it to stop the queue in advance, andTX_WAKE_THRESHOLDis derived from it.A queue left running after a transmit therefore only guarantees
MAX_SKB_FRAGS+ 4 free descriptors, while the next skb with a linear part andMAX_SKB_FRAGSfragments, each fitting in one data descriptor, requiresMAX_SKB_FRAGS+ 6.igc_xmit_frame_ring()then returnsNETDEV_TX_BUSY, which the queue stop logic is meant to prevent.With TSO this happens routinely. On an I226-V (8086:125c) running 7.2.8 with
MAX_SKB_FRAGS= 17, routed and locally generated TCP traffic on a CPU-saturated router produced 10890NETDEV_TX_BUSYreturns in three runs of 180 seconds, all for TSO skbs with 16 or 17 fragments, with
21 or 22 free descriptors in all but 5 cases. Together with deferred tail writes (xmit_more), these returns led to 25 Tx timeouts and adapter resets in the same runs:igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2
timed out 5353 ms
igc 0000:08:00.0 terra: Reset adapterThe following patch addresses the lost tail write itself.
Raise
DESC_NEEDEDtoMAX_SKB_FRAGS+ 6 to match the admission check. The additional reservation is currently unconditional, including when launch time is disabled; match that existing admission policy in the proactive stop threshold. WithMAX_SKB_FRAGS= 17, the queue is now stopped below 23 free descriptors instead of 21. This also raises the completion-based wake threshold from 42 to 46 free descriptors, preserving the existing two-times-stop-threshold policy. Throughput and latency effects were not measured.With this change alone, three runs of the same test on 7.2.8 produced no
NETDEV_TX_BUSYand no Tx timeout over 8.8MNETDEV_TX_OKreturns, including 613k TSO skbs with 17 fragments.As before commit
db0b124f02ba, an skb whose linear part or fragments exceedIGC_MAX_DATA_PER_TXDmay still need more descriptors thanDESC_NEEDEDaccounts for.Fixes db0b124f02ba ("igc: Enhance Qbv scheduling by using first flagbit")
--- drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/igc/igc.h +4
-2@@ -575,9 +575,13 @@ enum igc_boards {#define IGC_MAX_TXD_PWR 15#define IGC_MAX_DATA_PER_TXD BIT(IGC_MAX_TXD_PWR) -/* Tx Descriptors needed, worst case */ #define TXD_USE_COUNT (S ) DIV_ROUND_UP((S), IGC_MAX_DATA_PER_TXD) -#define DESC_NEEDED (MAX_SKB_FRAGS + 4) + +/* Tx descriptor budget for a head and MAX_SKB_FRAGS fragments, +* each fitting in one data descriptor: one context descriptor, +* two descriptors for an optional empty frame, and two spare entries.
+ */drivers/net/ethernet/intel/igc/igc.h +1
-0+#define DESC_NEEDED (MAX_SKB_FRAGS + 6) struct igc_rx_buffer { union {
Quoted 3 lines
base-commit:
a83267db14681b3be481e02a4d5a38177507006c--
2.55.0
Ruinskiy, Dima
Reviewed-byRe: [PATCH iwl-net 1/2] igc: Fix Tx stop threshold to cover empty frame descriptors
Quoted 92 lines · Aleksandr
Quoted 92 lines
-----Original Message-----
From: Benoit DE RANCOURT <[email protected]>
Sent: Sunday, October 4, 2026 5:29 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; intel-wired- [email protected]
Cc: [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Gomes, Vinicius <[email protected]>; Sasha Neftin <[email protected]>; [email protected]; Benoit DE RANCOURT <[email protected]>
Subject: [PATCH iwl-net 1/2] igc: Fix Tx stop threshold to cover empty frame descriptorsCommit
db0b124f02ba("igc: Enhance Qbv scheduling by using first flag bit") raised the number of free descriptors thatigc_xmit_frame_ring()requires before mapping a packet from count + 3 to count + 5, to leave room for the empty frame (one context and one data descriptor) that may be inserted ahead of a launch time packet.DESC_NEEDEDwas left atMAX_SKB_FRAGS+ 4.igc_tx_map()uses it to stop the queue in advance, andTX_WAKE_THRESHOLDis derived from it.A queue left running after a transmit therefore only guarantees
MAX_SKB_FRAGS+ 4 free descriptors, while the next skb with a linear part andMAX_SKB_FRAGSfragments, each fitting in one data descriptor, requiresMAX_SKB_FRAGS+ 6.igc_xmit_frame_ring()then returnsNETDEV_TX_BUSY, which the queue stop logic is meant to prevent.With TSO this happens routinely. On an I226-V (8086:125c) running 7.2.8 with
MAX_SKB_FRAGS= 17, routed and locally generated TCP traffic on a CPU-saturated router produced 10890NETDEV_TX_BUSYreturns in three runs of 180 seconds, all for TSO skbs with 16 or 17 fragments, with
21 or 22 free descriptors in all but 5 cases. Together with deferred tail writes (xmit_more), these returns led to 25 Tx timeouts and adapter resets in the same runs:igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2
timed out 5353 ms
igc 0000:08:00.0 terra: Reset adapterThe following patch addresses the lost tail write itself.
Raise
DESC_NEEDEDtoMAX_SKB_FRAGS+ 6 to match the admission check. The additional reservation is currently unconditional, including when launch time is disabled; match that existing admission policy in the proactive stop threshold. WithMAX_SKB_FRAGS= 17, the queue is now stopped below 23 free descriptors instead of 21. This also raises the completion-based wake threshold from 42 to 46 free descriptors, preserving the existing two-times-stop-threshold policy. Throughput and latency effects were not measured.With this change alone, three runs of the same test on 7.2.8 produced no
NETDEV_TX_BUSYand no Tx timeout over 8.8MNETDEV_TX_OKreturns, including 613k TSO skbs with 17 fragments.As before commit
db0b124f02ba, an skb whose linear part or fragments exceedIGC_MAX_DATA_PER_TXDmay still need more descriptors thanDESC_NEEDEDaccounts for.Fixes db0b124f02ba ("igc: Enhance Qbv scheduling by using first flagbit")
--- drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/igc/igc.h +4
-2@@ -575,9 +575,13 @@ enum igc_boards {#define IGC_MAX_TXD_PWR 15#define IGC_MAX_DATA_PER_TXD BIT(IGC_MAX_TXD_PWR) -/* Tx Descriptors needed, worst case */ #define TXD_USE_COUNT (S ) DIV_ROUND_UP((S), IGC_MAX_DATA_PER_TXD) -#define DESC_NEEDED (MAX_SKB_FRAGS + 4) + +/* Tx descriptor budget for a head and MAX_SKB_FRAGS fragments, +* each fitting in one data descriptor: one context descriptor, +* two descriptors for an optional empty frame, and two spare entries.
+ */
+#defineDESC_NEEDED(MAX_SKB_FRAGS+ 6)
Quoted 8 lines
Quoted 6 lines
struct igc_rx_buffer { union {base-commit:
a83267db14681b3be481e02a4d5a38177507006c--
2.55.0Reviewed-by Aleksandr Loktionov <[email protected]>
Re: [PATCH iwl-net 1/2] igc: Fix Tx stop threshold to cover empty frame descriptors
In reply to Benoit DE RANCOURTQuoted 44 lines · Benoit DE RANCOURT
Commit
db0b124f02ba("igc: Enhance Qbv scheduling by using first flag bit") raised the number of free descriptors thatigc_xmit_frame_ring()requires before mapping a packet from count + 3 to count + 5, to leave room for the empty frame (one context and one data descriptor) that may be inserted ahead of a launch time packet.DESC_NEEDEDwas left atMAX_SKB_FRAGS+ 4.igc_tx_map()uses it to stop the queue in advance, andTX_WAKE_THRESHOLDis derived from it.A queue left running after a transmit therefore only guarantees
MAX_SKB_FRAGS+ 4 free descriptors, while the next skb with a linear part andMAX_SKB_FRAGSfragments, each fitting in one data descriptor, requiresMAX_SKB_FRAGS+ 6.igc_xmit_frame_ring()then returnsNETDEV_TX_BUSY, which the queue stop logic is meant to prevent.With TSO this happens routinely. On an I226-V (8086:125c) running 7.2.8 with
MAX_SKB_FRAGS= 17, routed and locally generated TCP traffic on a CPU-saturated router produced 10890NETDEV_TX_BUSYreturns in three runs of 180 seconds, all for TSO skbs with 16 or 17 fragments, with 21 or 22 free descriptors in all but 5 cases. Together with deferred tail writes (xmit_more), these returns led to 25 Tx timeouts and adapter resets in the same runs:igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2 timed out 5353 ms igc 0000:08:00.0 terra: Reset adapter
The following patch addresses the lost tail write itself.
Raise
DESC_NEEDEDtoMAX_SKB_FRAGS+ 6 to match the admission check. The additional reservation is currently unconditional, including when launch time is disabled; match that existing admission policy in the proactive stop threshold. WithMAX_SKB_FRAGS= 17, the queue is now stopped below 23 free descriptors instead of 21. This also raises the completion-based wake threshold from 42 to 46 free descriptors, preserving the existing two-times-stop-threshold policy. Throughput and latency effects were not measured.With this change alone, three runs of the same test on 7.2.8 produced no
NETDEV_TX_BUSYand no Tx timeout over 8.8MNETDEV_TX_OKreturns, including 613k TSO skbs with 17 fragments.As before commit
db0b124f02ba, an skb whose linear part or fragments exceedIGC_MAX_DATA_PER_TXDmay still need more descriptors thanDESC_NEEDEDaccounts for.
Quoted 8 lines
Fixes db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit")Assisted-by LLM bpftraceSigned-off-by Benoit DE RANCOURT <[email protected]>--- drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
PATCH 2/2 igc: Flush pending Tx descriptors before returning NETDEV_TX_BUSY
In reply to Benoit DE RANCOURTWhen the stack sends a burst with xmit_more set, igc_tx_map() defers the tail register write until the last skb of the burst or until the queue is stopped. If igc_xmit_frame_ring() then refuses an skb with NETDEV_TX_BUSY, it returns without flushing any pending tail write. Descriptors of packets already accepted in the burst can therefore remain unexposed to the hardware.
The queue is stopped at that point and igc_clean_tx_irq() only wakes it once TX_WAKE_THRESHOLD descriptors are free. The hardware can only complete what the tail exposes, so if the unsignalled descriptors keep the free count below the threshold, the queue is never woken and the Tx watchdog resets the adapter.
On an I226-V running 7.2.8, in all 25 Tx timeout episodes of the test described in the previous patch, the stalled queue had pending descriptors after a NETDEV_TX_BUSY return: the probes inferred at least 214 of the 256 ring descriptors beyond the last tail write. For that queue, the register dump showed TDH = TDT = the next_to_clean value recorded by the probe: the hardware had completed everything it had been given. For example, with queue 2 stopped, next_to_clean = 190 and next_to_use = 167:
igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2 timed out 5353 ms
igc 0000:08:00.0 terra: TDH[0-3] 00000099 00000091 000000be 000000f5
igc 0000:08:00.0 terra: TDT[0-3] 00000099 00000091 000000be 000000f5
Write the tail before returning NETDEV_TX_BUSY. The refused skb is left untouched; only descriptors of already accepted packets are exposed to the hardware. Those packets have already been accounted to BQL, so flushing their descriptors lets completion processing progress; the refused skb is neither mapped nor accounted here.
The previous patch makes this path rare again for common skbs, but it remains reachable, for instance when the linear part or a fragment of an skb exceeds IGC_MAX_DATA_PER_TXD.
With this change alone (without the previous patch), three runs of the same test on 7.2.8 still produced 10751 NETDEV_TX_BUSY returns, but no Tx timeout, against 25 on the unpatched kernel.
--- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +5 -1
@@ -1621,7 +1621,11 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, &skb_shinfo(skb)->frags[f]));if (igc_maybe_stop_tx (tx_ring, count +5 )) { -/* this is a hard error */ +/* This is a hard error. Write the tail for packets deferred +* by xmit_more before returning busy, otherwise the stopped +* queue may never get enough completions to be woken. +*/ +igc_flush_tx_descriptors (tx_ring);return NETDEV_TX_BUSY ; }
Signature · 1 line
2.55.0
RE: [PATCH iwl-net 2/2] igc: Flush pending Tx descriptors before returning NETDEV_TX_BUSY
Quoted 91 lines
-----Original Message-----
From: Benoit DE RANCOURT <[email protected]>
Sent: Sunday, October 4, 2026 5:29 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; intel-wired- [email protected]
Cc: [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Gomes, Vinicius <[email protected]>; Sasha Neftin <[email protected]>; [email protected]; Benoit DE RANCOURT <[email protected]>
Subject: [PATCH iwl-net 2/2] igc: Flush pending Tx descriptors before returningNETDEV_TX_BUSYWhen the stack sends a burst with
xmit_moreset,igc_tx_map()defers the tail register write until the last skb of the burst or until the queue is stopped. Ifigc_xmit_frame_ring()then refuses an skb withNETDEV_TX_BUSY, it returns without flushing any pending tail write. Descriptors of packets already accepted in the burst can therefore remain unexposed to the hardware.The queue is stopped at that point and
igc_clean_tx_irq()only wakes it onceTX_WAKE_THRESHOLDdescriptors are free. The hardware can only complete what the tail exposes, so if the unsignalled descriptors keep the free count below the threshold, the queue is never woken and the Tx watchdog resets the adapter.On an I226-V running 7.2.8, in all 25 Tx timeout episodes of the test described in the previous patch, the stalled queue had pending descriptors after a
NETDEV_TX_BUSYreturn: the probes inferred at least 214 of the 256 ring descriptors beyond the last tail write. For that queue, the register dump showed TDH = TDT = thenext_to_cleanvalue recorded by the probe: the hardware had completed everything it had been given. For example, with queue 2 stopped,next_to_clean= 190 andnext_to_use= 167:igc 0000:08:00.0 terra: NETDEV WATCHDOG: CPU: 1: transmit queue 2
timed out 5353 ms
igc 0000:08:00.0 terra: TDH[0-3] 00000099 00000091000000be000000f5
igc 0000:08:00.0 terra: TDT[0-3] 00000099 00000091000000be000000f5Write the tail before returning
NETDEV_TX_BUSY. The refused skb is left untouched; only descriptors of already accepted packets are exposed to the hardware. Those packets have already been accounted to BQL, so flushing their descriptors lets completion processing progress; the refused skb is neither mapped nor accounted here.The previous patch makes this path rare again for common skbs, but it remains reachable, for instance when the linear part or a fragment of an skb exceeds
IGC_MAX_DATA_PER_TXD.With this change alone (without the previous patch), three runs of the same test on 7.2.8 still produced 10751
NETDEV_TX_BUSYreturns, but no Tx timeout, against 25 on the unpatched kernel.Fixes 0507ef8a0372 ("igc: Add transmit and receive fastpath andinterrupt handlers")
--- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igc/igc_main.c +1
-1@@ -1621,7 +1621,11 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, &skb_shinfo(skb)->frags[f]));if (igc_maybe_stop_tx (tx_ring, count +5 )) { -/* this is a hard error */ +/* This is a hard error. Write the tail for packets deferred
drivers/net/ethernet/intel/igc/igc_main.c +1
-0+* by xmit_more before returning busy, otherwise the stopped
drivers/net/ethernet/intel/igc/igc_main.c +3
-1+* queue may never get enough completions to be woken. +*/ +igc_flush_tx_descriptors (tx_ring);return NETDEV_TX_BUSY ; } --
Quoted 1 line
2.55.0
Quoted 88 lines · Benoit DE RANCOURT
Since commit
db0b124f02ba("igc: Enhance Qbv scheduling by using first flag bit"),igc_xmit_frame_ring()requires count + 5 free descriptors, while the queue is only stopped in advance belowDESC_NEEDED=MAX_SKB_FRAGS+ 4. TSO skbs with 16 or 17 fragments then hitNETDEV_TX_BUSY. That return skips the tail write deferred byxmit_more, so the queue can stay stopped with descriptors the hardware never saw, until the Tx watchdog resets the adapter.Patch 1 aligns
DESC_NEEDEDwith the admission check. Patch 2 writes the tail before returningNETDEV_TX_BUSY, which remains reachable for skbs with buffers larger thanIGC_MAX_DATA_PER_TXD. Each patch was tested alone; together they keep the queue stop logic consistent and the remaining busy path safe.Setup: CWWK router, Pentium Gold 8505, six I226-V (8086:125c rev 04, NVM 2017:888d), 7.2.8, default
MAX_SKB_FRAGS= 17. Load: CPU saturated with busy loops, a remote build routed through the port, two SSH bulk streams in each direction and short TCP bursts, 180 seconds of load per run observed during a 195-second probe window, TSO enabled on the egress port. bpftrace probes onigc_xmit_frame,__igc_maybe_stop_txandigc_pollrecordedNETDEV_TX_BUSYreturns, the inferred last tail write andnext_to_cleanstalls.runs Tx timeouts
NETDEV_TX_BUSYTX_OKreturnsunpatched 7.2.8 3 25 10890 7.3M patch 2 only 3 0 10751 9.5M patch 1 only 3 0 0 8.8M both patches 3 0 0 9.4M unpatched, TSO off 1 0 0 21.5MIn all 25 timeout episodes, the stalled queue had pending descriptors after a
NETDEV_TX_BUSYreturn. The probes inferred at least 214 descriptors beyond the last tail write. For that queue, the hardware register dump showed TDH = TDT = thenext_to_cleanvalue recorded by the probe.With both patches applied, no
NETDEV_TX_BUSYoccurred, so the flush path of patch 2 was not exercised in that run; its effect is shown by the patch 2 only runs.
TX_OKreturns countigc_xmit_frame()calls returningNETDEV_TX_OK, excludingNETDEV_TX_BUSYretries. These are software call counts, not hardware packet counters; with TSO disabled, segmentation occurs before the driver.Related code, not addressed in this series and not tested:
- bnxt: commit
e8d8c5d80f5e("bnxt: make surexmit_more+ errors does not miss doorbells") rings a pending doorbell on the drop paths. It leaves the busy path alone, reasoning that busy can only happen ifstart_xmitraces with completions that both enable the queue, in which case no kick can be pending; the current code warns "ring busy w/ flush pending!" if that assumption breaks. In igc, patch 1 restores that property for skbs whose buffers each fit in one descriptor, and patch 2 covers the remaining case.- igc drop paths (
skb_put_padto()failure inigc_xmit_frame(),out_dropinigc_xmit_frame_ring(), the DMA mapping error path ofigc_tx_map()) also return without writing a pending tail, the case bnxt fixed ine8d8c5d80f5eand00eeab0c644a("bnxt_en: Write doorbell when linearizing skb fails"). The queue is not stopped there, so pending descriptors are delayed until the next transmit on that queue rather than stranded.- igb, ixgbe, fm10k, i40e, iavf, ice, e1000e and e1000 also defer the tail write with
xmit_moreand returnNETDEV_TX_BUSYfrom their admission check without writing it. Their stop thresholds match their admission checks, so this should only be reachable for skbs needing more descriptors than the stop threshold assumes.Not done:
- runtime test on a kernel built from this tree; the patches were tested on 7.2.8, where the affected code is identical, and apply cleanly here;
- launch time (ETF/taprio) and XDP/AF_XDP traffic, which share the ring and the wake threshold;
- longer runs and other I226/I225 boards;
- only the igc objects were built with W=1 under allmodconfig, not the full tree.The analysis and the patches were prepared with an LLM-based coding assistant, which also wrote the bpftrace probes; the results above come from those probes and the kernel log on real hardware.
Benoit DE RANCOURT (2):
igc: Fix Tx stop threshold to cover empty frame descriptors
igc: Flush pending Tx descriptors before returningNETDEV_TX_BUSY
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-)base-commit:
a83267db14681b3be481e02a4d5a38177507006c
Hi Benoit,
Thank you for this fix. Much appreciated.
I wonder if we can go just with patch 1 for now. Reasons:
- As per the analysis, just Patch 1 resolves all the issues encountered (the corner case resolved by patch 2 is not reached anymore, although it remains theoretically possible)
- As explained in the cover letter, Patch 2 changes the behavior in a way that makes it inconsistent with what other drivers are doing. Maybe the new behavior is more correct in all cases, maybe not, but in general I prefer to avoid introducing inconsistencies, especially when I don't fully understand the effects.
Best,
Dima
Hi Dima,
Thank you for the review and for the explanation.
Yes, going with patch 1 only is fine with me. It is the actual fix for the problem I hit: in my tests, it removed every NETDEV_TX_BUSY return and every Tx timeout on its own.
I agree that patch 2 is a broader question. The same pattern exists in other Intel drivers, so it makes more sense for your team to decide whether and how to handle it consistently across them. I'm happy to leave that to you.
Thanks again for taking care of my contribution.
Best regards,
Benoit
Quoted 112 lines · Dima
Quoted 88 lines · Benoit DE RANCOURT
Since commit
db0b124f02ba("igc: Enhance Qbv scheduling by using first flag bit"),igc_xmit_frame_ring()requires count + 5 free descriptors, while the queue is only stopped in advance belowDESC_NEEDED=MAX_SKB_FRAGS+ 4. TSO skbs with 16 or 17 fragments then hitNETDEV_TX_BUSY. That return skips the tail write deferred byxmit_more, so the queue can stay stopped with descriptors the hardware never saw, until the Tx watchdog resets the adapter.Patch 1 aligns
DESC_NEEDEDwith the admission check. Patch 2 writes the tail before returningNETDEV_TX_BUSY, which remains reachable for skbs with buffers larger thanIGC_MAX_DATA_PER_TXD. Each patch was tested alone; together they keep the queue stop logic consistent and the remaining busy path safe.Setup: CWWK router, Pentium Gold 8505, six I226-V (8086:125c rev 04, NVM 2017:888d), 7.2.8, default
MAX_SKB_FRAGS= 17. Load: CPU saturated with busy loops, a remote build routed through the port, two SSH bulk streams in each direction and short TCP bursts, 180 seconds of load per run observed during a 195-second probe window, TSO enabled on the egress port. bpftrace probes onigc_xmit_frame,__igc_maybe_stop_txandigc_pollrecordedNETDEV_TX_BUSYreturns, the inferred last tail write andnext_to_cleanstalls.runs Tx timeouts
NETDEV_TX_BUSYTX_OKreturnsunpatched 7.2.8 3 25 10890 7.3M patch 2 only 3 0 10751 9.5M patch 1 only 3 0 0 8.8M both patches 3 0 0 9.4M unpatched, TSO off 1 0 0 21.5MIn all 25 timeout episodes, the stalled queue had pending descriptors after a
NETDEV_TX_BUSYreturn. The probes inferred at least 214 descriptors beyond the last tail write. For that queue, the hardware register dump showed TDH = TDT = thenext_to_cleanvalue recorded by the probe.With both patches applied, no
NETDEV_TX_BUSYoccurred, so the flush path of patch 2 was not exercised in that run; its effect is shown by the patch 2 only runs.
TX_OKreturns countigc_xmit_frame()calls returningNETDEV_TX_OK, excludingNETDEV_TX_BUSYretries. These are software call counts, not hardware packet counters; with TSO disabled, segmentation occurs before the driver.Related code, not addressed in this series and not tested:
- bnxt: commit
e8d8c5d80f5e("bnxt: make surexmit_more+ errors does not miss doorbells") rings a pending doorbell on the drop paths. It leaves the busy path alone, reasoning that busy can only happen ifstart_xmitraces with completions that both enable the queue, in which case no kick can be pending; the current code warns "ring busy w/ flush pending!" if that assumption breaks. In igc, patch 1 restores that property for skbs whose buffers each fit in one descriptor, and patch 2 covers the remaining case.- igc drop paths (
skb_put_padto()failure inigc_xmit_frame(),out_dropinigc_xmit_frame_ring(), the DMA mapping error path ofigc_tx_map()) also return without writing a pending tail, the case bnxt fixed ine8d8c5d80f5eand00eeab0c644a("bnxt_en: Write doorbell when linearizing skb fails"). The queue is not stopped there, so pending descriptors are delayed until the next transmit on that queue rather than stranded.- igb, ixgbe, fm10k, i40e, iavf, ice, e1000e and e1000 also defer the tail write with
xmit_moreand returnNETDEV_TX_BUSYfrom their admission check without writing it. Their stop thresholds match their admission checks, so this should only be reachable for skbs needing more descriptors than the stop threshold assumes.Not done:
- runtime test on a kernel built from this tree; the patches were tested on 7.2.8, where the affected code is identical, and apply cleanly here;
- launch time (ETF/taprio) and XDP/AF_XDP traffic, which share the ring and the wake threshold;
- longer runs and other I226/I225 boards;
- only the igc objects were built with W=1 under allmodconfig, not the full tree.The analysis and the patches were prepared with an LLM-based coding assistant, which also wrote the bpftrace probes; the results above come from those probes and the kernel log on real hardware.
Benoit DE RANCOURT (2):
igc: Fix Tx stop threshold to cover empty frame descriptors
igc: Flush pending Tx descriptors before returningNETDEV_TX_BUSYQuoted 6 lines
drivers/net/ethernet/intel/igc/igc.h | 8 ++++++-- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-)base-commit:
a83267db14681b3be481e02a4d5a38177507006cHi Benoit,
Thank you for this fix. Much appreciated.I wonder if we can go just with patch 1 for now. Reasons:
- As per the analysis, just Patch 1 resolves all the issues encountered (the corner case resolved by patch 2 is not reached anymore, although it remains theoretically possible)
- As explained in the cover letter, Patch 2 changes the behavior in a way that makes it inconsistent with what other drivers are doing. Maybe the new behavior is more correct in all cases, maybe not, but in general I prefer to avoid introducing inconsistencies, especially when I don't fully understand the effects.Best,
Dima