BPF List
 help / color / mirror / Atom feed
* [PATCH net-next 2/6] igc: Get rid of spurious interrupts
       [not found] <20240830210451.2375215-1-anthony.l.nguyen@intel.com>
@ 2024-08-30 21:04 ` Tony Nguyen
  2024-09-05  6:16   ` Ruinskiy, Dima
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Nguyen @ 2024-08-30 21:04 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Kurt Kanzenbach, anthony.l.nguyen, sasha.neftin, vitaly.lifshits,
	dima.ruinskiy, maciej.fijalkowski, magnus.karlsson, ast, daniel,
	hawk, john.fastabend, bpf, bigeasy, Vinicius Costa Gomes,
	Simon Horman, Mor Bar-Gabay

From: Kurt Kanzenbach <kurt@linutronix.de>

When running the igc with XDP/ZC in busy polling mode with deferral of hard
interrupts, interrupts still happen from time to time. That is caused by
the igc task watchdog which triggers Rx interrupts periodically.

That mechanism has been introduced to overcome skb/memory allocation
failures [1]. So the Rx clean functions stop processing the Rx ring in case
of such failure. The task watchdog triggers Rx interrupts periodically in
the hope that memory became available in the mean time.

The current behavior is undesirable for real time applications, because the
driver induced Rx interrupts trigger also the softirq processing. However,
all real time packets should be processed by the application which uses the
busy polling method.

Therefore, only trigger the Rx interrupts in case of real allocation
failures. Introduce a new flag for signaling that condition.

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=3be507547e6177e5c808544bd6a2efa2c7f1d436

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Mor Bar-Gabay <morx.bar.gabay@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/igc/igc.h      |  1 +
 drivers/net/ethernet/intel/igc/igc_main.c | 30 ++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index 8642d67af6cc..eac0f966e0e4 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -687,6 +687,7 @@ enum igc_ring_flags_t {
 	IGC_RING_FLAG_TX_DETECT_HANG,
 	IGC_RING_FLAG_AF_XDP_ZC,
 	IGC_RING_FLAG_TX_HWTSTAMP,
+	IGC_RING_FLAG_RX_ALLOC_FAILED,
 };
 
 #define ring_uses_large_buffer(ring) \
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 96b2f2a37bc3..da322899e834 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -2191,6 +2191,7 @@ static bool igc_alloc_mapped_page(struct igc_ring *rx_ring,
 	page = dev_alloc_pages(igc_rx_pg_order(rx_ring));
 	if (unlikely(!page)) {
 		rx_ring->rx_stats.alloc_failed++;
+		set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
 		return false;
 	}
 
@@ -2207,6 +2208,7 @@ static bool igc_alloc_mapped_page(struct igc_ring *rx_ring,
 		__free_page(page);
 
 		rx_ring->rx_stats.alloc_failed++;
+		set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
 		return false;
 	}
 
@@ -2658,6 +2660,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget)
 		if (!skb) {
 			rx_ring->rx_stats.alloc_failed++;
 			rx_buffer->pagecnt_bias++;
+			set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
 			break;
 		}
 
@@ -2738,6 +2741,7 @@ static void igc_dispatch_skb_zc(struct igc_q_vector *q_vector,
 	skb = igc_construct_skb_zc(ring, xdp);
 	if (!skb) {
 		ring->rx_stats.alloc_failed++;
+		set_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &ring->flags);
 		return;
 	}
 
@@ -5807,11 +5811,29 @@ static void igc_watchdog_task(struct work_struct *work)
 	if (adapter->flags & IGC_FLAG_HAS_MSIX) {
 		u32 eics = 0;
 
-		for (i = 0; i < adapter->num_q_vectors; i++)
-			eics |= adapter->q_vector[i]->eims_value;
-		wr32(IGC_EICS, eics);
+		for (i = 0; i < adapter->num_q_vectors; i++) {
+			struct igc_q_vector *q_vector = adapter->q_vector[i];
+			struct igc_ring *rx_ring;
+
+			if (!q_vector->rx.ring)
+				continue;
+
+			rx_ring = adapter->rx_ring[q_vector->rx.ring->queue_index];
+
+			if (test_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags)) {
+				eics |= q_vector->eims_value;
+				clear_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
+			}
+		}
+		if (eics)
+			wr32(IGC_EICS, eics);
 	} else {
-		wr32(IGC_ICS, IGC_ICS_RXDMT0);
+		struct igc_ring *rx_ring = adapter->rx_ring[0];
+
+		if (test_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags)) {
+			clear_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
+			wr32(IGC_ICS, IGC_ICS_RXDMT0);
+		}
 	}
 
 	igc_ptp_tx_hang(adapter);
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 2/6] igc: Get rid of spurious interrupts
  2024-08-30 21:04 ` [PATCH net-next 2/6] igc: Get rid of spurious interrupts Tony Nguyen
@ 2024-09-05  6:16   ` Ruinskiy, Dima
  2024-09-05  9:44     ` Kurt Kanzenbach
  0 siblings, 1 reply; 3+ messages in thread
From: Ruinskiy, Dima @ 2024-09-05  6:16 UTC (permalink / raw)
  To: Tony Nguyen, davem, kuba, pabeni, edumazet, netdev
  Cc: Kurt Kanzenbach, sasha.neftin, vitaly.lifshits,
	maciej.fijalkowski, magnus.karlsson, ast, daniel, hawk,
	john.fastabend, bpf, bigeasy, Vinicius Costa Gomes, Simon Horman,
	Mor Bar-Gabay

On 31/08/2024 0:04, Tony Nguyen wrote:
> - wr32(IGC_ICS, IGC_ICS_RXDMT0);
> + struct igc_ring *rx_ring = adapter->rx_ring[0];
> +
> + if (test_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags)) {
> + clear_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
> + wr32(IGC_ICS, IGC_ICS_RXDMT0);
> + }
I have some concerns specifically about this code (Legacy/MSI interrupt 
case). The code only checks the IGC_RING_FLAG_RX_ALLOC_FAILED flag of 
ring 0. What if the failure was on another ring? It seems proper to 
iterate over all Rx rings in the adapter (I believe igc can have up to 4).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 2/6] igc: Get rid of spurious interrupts
  2024-09-05  6:16   ` Ruinskiy, Dima
@ 2024-09-05  9:44     ` Kurt Kanzenbach
  0 siblings, 0 replies; 3+ messages in thread
From: Kurt Kanzenbach @ 2024-09-05  9:44 UTC (permalink / raw)
  To: Ruinskiy, Dima, Tony Nguyen, davem, kuba, pabeni, edumazet,
	netdev
  Cc: sasha.neftin, vitaly.lifshits, maciej.fijalkowski,
	magnus.karlsson, ast, daniel, hawk, john.fastabend, bpf, bigeasy,
	Vinicius Costa Gomes, Simon Horman, Mor Bar-Gabay

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

On Thu Sep 05 2024, Dima Ruinskiy wrote:
> On 31/08/2024 0:04, Tony Nguyen wrote:
>> - wr32(IGC_ICS, IGC_ICS_RXDMT0);
>> + struct igc_ring *rx_ring = adapter->rx_ring[0];
>> +
>> + if (test_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags)) {
>> + clear_bit(IGC_RING_FLAG_RX_ALLOC_FAILED, &rx_ring->flags);
>> + wr32(IGC_ICS, IGC_ICS_RXDMT0);
>> + }
> I have some concerns specifically about this code (Legacy/MSI interrupt 
> case). The code only checks the IGC_RING_FLAG_RX_ALLOC_FAILED flag of 
> ring 0. What if the failure was on another ring? It seems proper to 
> iterate over all Rx rings in the adapter (I believe igc can have up to 4).

In case of Legacy/MSI only one vector, one rx queue and one tx queue is
utilized. The MSI-X code has to check for all rings, which it does.

Thanks,
Kurt

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-05  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20240830210451.2375215-1-anthony.l.nguyen@intel.com>
2024-08-30 21:04 ` [PATCH net-next 2/6] igc: Get rid of spurious interrupts Tony Nguyen
2024-09-05  6:16   ` Ruinskiy, Dima
2024-09-05  9:44     ` Kurt Kanzenbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox