Skip to contentSkip to conversation

CONFIG_NET_HW_FLOWCONTROL and SMP

BUG/PATCH Andrew Morton 4 participants 9 messages Sep 29, 2003 – Oct 3, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Begin forwarded message:

Date: Mon, 29 Sep 2003 14:08:54 +0200
From: [email protected]
To: [email protected]
Subject: [BUG/PATCH] CONFIG_NET_HW_FLOWCONTROL and SMP

Hi,
by testing the CONFIG_NET_HW_FLOWCONTROL (NIC Hardware throttling) on a SMP system, I found a bug in net/core/dev.c : the netdev_dropping variable can be set to a negative value (the result is that a CPU can be locked in "throttle" state).
This bug seems to exist in 2.4 and in 2.6 kernels.

Here's a typical scenario :

- Throttling --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1

     && netdev_dropping == 2
- 1st packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1
     && netdev_dropping == 1
- 2nd packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==1
     && netdev_dropping == 0
- 3nd packet Unthrottle ( in net_rx_action() ), received by CPU 1
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==0
     && netdev_dropping == -1

and so on...

The problem is that the (CPU)queue->throttle should be set to zero every time the netdev_dropping variable is decremented.

Here's a patch for the 2.4.19 kernel (tested with success) :

net/core/dev.c Tue Sep 23 18:35:35 2003 renamed from net/core/dev.c.orig Mon Sep 29 12:49:14 2003 +1 -1
@@ -1519,8 +1519,8 @@
 
 #ifdef CONFIG_NET_HW_FLOWCONTROL
     if (queue->throttle && queue->input_pkt_queue.qlen < no_cong_thresh ) {
+         queue->throttle = 0;
          if (atomic_dec_and_test(&netdev_dropping)) {
-              queue->throttle = 0;
               netdev_wakeup();
               goto softnet_break;
          }

I haven't done a patch for 2.4.22 (as we currently use 2.4.19) but the same modification should be applied around lines 1572 to 1577 of net/core/dev.c

For 2.6.0-test5, the lines to modified are arount 1631 to 1637.

Regards,
---
Daniel FAGES
ARKOON Network Security http://www.arkoon.net

#1 lore raw

Hello!

IMO HW_FLOWCONTROL is now outdated. It has served very well and encouraged people to use for Linux production networking. With a 2 tulip NIC's on a UP system as a typical system. Only tulip has code for it. This option was added by Alexey in 2.1.63 something...

Cheers.

						--ro
Quoted 74 lines · Andrew Morton

Begin forwarded message:

Date: Mon, 29 Sep 2003 14:08:54 +0200
From: [email protected]
To: [email protected]
Subject: [BUG/PATCH] CONFIG_NET_HW_FLOWCONTROL and SMP

Hi,
by testing the CONFIG_NET_HW_FLOWCONTROL (NIC Hardware throttling) on a SMP system, I found a bug in net/core/dev.c : the netdev_dropping variable can be set to a negative value (the result is that a CPU can be locked in "throttle" state).
This bug seems to exist in 2.4 and in 2.6 kernels.

Here's a typical scenario :

- Throttling --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1

     && netdev_dropping == 2
- 1st packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1
     && netdev_dropping == 1
- 2nd packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==1
     && netdev_dropping == 0
- 3nd packet Unthrottle ( in net_rx_action() ), received by CPU 1
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==0
     && netdev_dropping == -1

and so on...

The problem is that the (CPU)queue->throttle should be set to zero every time the netdev_dropping variable is decremented.

Here's a patch for the 2.4.19 kernel (tested with success) :

net/core/dev.c Tue Sep 23 18:35:35 2003 renamed from net/core/dev.c.orig Mon Sep 29 12:49:14 2003 +1 -1
@@ -1519,8 +1519,8 @@
 
 #ifdef CONFIG_NET_HW_FLOWCONTROL
     if (queue->throttle && queue->input_pkt_queue.qlen < no_cong_thresh ) {
+         queue->throttle = 0;
          if (atomic_dec_and_test(&netdev_dropping)) {
-              queue->throttle = 0;
               netdev_wakeup();
               goto softnet_break;
          }

I haven't done a patch for 2.4.22 (as we currently use 2.4.19) but the same modification should be applied around lines 1572 to 1577 of net/core/dev.c

For 2.6.0-test5, the lines to modified are arount 1631 to 1637.

Regards,
---
Daniel FAGES
ARKOON Network Security http://www.arkoon.net

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 3 lines · Robert Olsson

Hello!

IMO HW_FLOWCONTROL is now outdated. It has served very well and encouraged people to use for Linux production networking. With a 2 tulip NIC's on a UP system as a typical system. Only tulip has code for it. This option was added by Alexey in 2.1.63 something...

If someone had a NAPI patch for tulip, we could remove HW_FLOWCONTROL option altogether :)

Jeff

#3 lore raw
Quoted 2 lines · Jeff Garzik

If someone had a NAPI patch for tulip, we could remove HW_FLOWCONTROL option altogether :)

Hello!

I sent you one some time ago. Well I'll try dig it up see if it still works. Unfortunely the test-bed is busy with other stuff.

Cheers.

						--ro
#4 lore raw
In reply to Jeff Garzik
Quoted 3 lines · Jeff Garzik

If someone had a NAPI patch for tulip, we could remove HW_FLOWCONTROL option altogether :)

Hello!
Here is something for 2.6.0-test6:

* ifdef's to keep current non-NAPI tulip intact

* Port based on Alexey's orig NAPI tulip design
(Only RX handled by dev->poll)

* tulip HW_FLOW removed

* NAPI and HW-mitigation options in Kconfig

Cheers

						--ro
net/tulip/Kconfig renamed from net/tulip.orig/Kconfig +20 -0
@@ -68,6 +68,26 @@
 	  obscure bugs if your mainboard has memory controller timing issues.
 	  If in doubt, say N.
 
+config TULIP_NAPI
+	bool "Use NAPI RX polling "
+	depends on TULIP
+	---help---
+	  This is of useful for servers and routers dealing with high network loads.
+ 
+	  See <file:Documentation/networking/NAPI_HOWTO.txt>.
+
+	  If in doubt, say N.
+
+config TULIP_NAPI_HW_MITIGATION
+	bool "Use Interrupt Mitigation "
+	depends on TULIP_NAPI
+	---help---
+	  Use HW to reduce RX interrupts. Not strict necessary since NAPI reduces
+	  RX interrupts but itself. Although this reduces RX interrupts even at
+	  low levels traffic at the cost of a small latency.
+
+	  If in doubt, say Y.
+
 config DE4X5
 	tristate "Generic DECchip & DIGITAL EtherWORKS PCI/EISA"
 	depends on NET_TULIP && (PCI || EISA)
net/tulip/tulip.h renamed from net/tulip.orig/tulip.h +11 -7
@@ -126,6 +126,7 @@
 	CFDD_Snooze = (1 << 30),
 };
 
+#define RxPollInt (RxIntr|RxNoBuf|RxDied|RxJabber)
 
 /* The bits in the CSR5 status registers, mostly interrupt sources. */
 enum status_bits {
@@ -251,9 +252,9 @@
    Making the Tx ring too large decreases the effectiveness of channel
    bonding and packet priority.
    There are no ill effects from too-large receive rings. */
-#define TX_RING_SIZE	16
-#define RX_RING_SIZE	32
 
+#define TX_RING_SIZE	32
+#define RX_RING_SIZE	128 
 #define MEDIA_MASK     31
 
 #define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer. */
@@ -343,17 +344,15 @@
 	int flags;
 	struct net_device_stats stats;
 	struct timer_list timer;	/* Media selection timer. */
+	struct timer_list oom_timer;    /* Out of memory timer. */
 	u32 mc_filter[2];
 	spinlock_t lock;
 	spinlock_t mii_lock;
 	unsigned int cur_rx, cur_tx;	/* The next free ring entry */
 	unsigned int dirty_rx, dirty_tx;	/* The ring entries to be free()ed. */
 
-#ifdef CONFIG_NET_HW_FLOWCONTROL
-#define RX_A_NBF_STOP 0xffffff3f /* To disable RX and RX-NOBUF ints. */
-        int fc_bit;
-        int mit_sel;
-        int mit_change; /* Signal for Interrupt Mitigtion */
+#ifdef 	CONFIG_TULIP_NAPI_HW_MITIGATION
+        int mit_on;
 #endif
 	unsigned int full_duplex:1;	/* Full-duplex operation requested. */
 	unsigned int full_duplex_lock:1;
@@ -415,6 +414,10 @@
 extern int tulip_rx_copybreak;
 irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 int tulip_refill_rx(struct net_device *dev);
+#ifdef CONFIG_TULIP_NAPI
+int tulip_poll(struct net_device *dev, int *budget);
+#endif
+
 
 /* media.c */
 int tulip_mdio_read(struct net_device *dev, int phy_id, int location);
@@ -438,6 +441,7 @@
 extern const char * const medianame[];
 extern const char tulip_media_cap[];
 extern struct tulip_chip_table tulip_tbl[];
+void oom_timer(unsigned long data);
 extern u8 t21040_csr13[];
 
 #ifndef USE_IO_OPS
net/tulip/tulip_core.c renamed from net/tulip.orig/tulip_core.c +20 -35

106 lines not on this page · raw message

net/tulip/interrupt.c renamed from net/tulip.orig/interrupt.c +296 -110

526 lines not on this page · raw message

#5 lore raw
Quoted 9 lines · Robert Olsson
Quoted 3 lines · Jeff Garzik

If someone had a NAPI patch for tulip, we could remove HW_FLOWCONTROL option altogether :)

Hello!
Here is something for 2.6.0-test6:

Quoted 8 lines

* ifdef's to keep current non-NAPI tulip intact

* Port based on Alexey's orig NAPI tulip design
(Only RX handled by dev->poll)

* tulip HW_FLOW removed

* NAPI and HW-mitigation options in Kconfig

Looks great to me. I'll give it some testing here, and 99% likely will apply it.

Andrew, would you be willing to merge this into -mm for some simultaneous netwide testing?

FWIW, I seem to recall that the older NAPI patch you sent didn't apply for some reason. But forget about that, this one looks good.

Jeff

#6 lore raw
Quoted 3 lines · Jeff Garzik

Andrew, would you be willing to merge this into -mm for some simultaneous netwide testing?

Sure.

#7 lore raw
In reply to Jeff Garzik
Quoted 6 lines · Jeff Garzik

Looks great to me. I'll give it some testing here, and 99% likely will apply it.

Andrew, would you be willing to merge this into -mm for some simultaneous netwide testing?

Fine!

Here is a additional patch to active disable poll so we don't have to wait in dev_close() for traffic to disappear.

Cheers.

						--ro
net/tulip/interrupt.c renamed from net/tulip/interrupt.c.03103 +3 -1
@@ -116,6 +116,8 @@
 	tp->stats_poll_starts++;
 #endif
 
+	if(!netif_running(dev)) goto done;
+
 	if (rx_work_limit > dev->quota)
 		rx_work_limit = dev->quota;
 
@@ -241,7 +243,7 @@
 		 * finally: amount of IO did not increase at all. */
 	} while ((inl(dev->base_addr + CSR5) & RxIntr));
 
-/* done: */
+done: 
 
 
 #ifdef USE_MITIGATION
#8 lore raw
In reply to Andrew Morton

Actually this is a known bug. Ive had a patch for a long time. Only problem is noone cares about CONFIG_NET_HW_FLOWCONTROL anymore. Summary, apply the patch for legacy reasons. The patch i had is slightly different; but this one looks sane too.

cheers,
jamal

Quoted 74 lines · Andrew Morton

Begin forwarded message:

Date: Mon, 29 Sep 2003 14:08:54 +0200
From: [email protected]
To: [email protected]
Subject: [BUG/PATCH] CONFIG_NET_HW_FLOWCONTROL and SMP

Hi,
by testing the CONFIG_NET_HW_FLOWCONTROL (NIC Hardware throttling) on a SMP system, I found a bug in net/core/dev.c : the netdev_dropping variable can be set to a negative value (the result is that a CPU can be locked in "throttle" state).
This bug seems to exist in 2.4 and in 2.6 kernels.

Here's a typical scenario :

- Throttling --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1

     && netdev_dropping == 2
- 1st packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==1 && (CPU 1)queue->throttle==1
     && netdev_dropping == 1
- 2nd packet Unthrottle ( in net_rx_action() ), received by CPU 0
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==1
     && netdev_dropping == 0
- 3nd packet Unthrottle ( in net_rx_action() ), received by CPU 1
     --> (CPU 0)queue->throttle==0 && (CPU 1)queue->throttle==0
     && netdev_dropping == -1

and so on...

The problem is that the (CPU)queue->throttle should be set to zero every time the netdev_dropping variable is decremented.

Here's a patch for the 2.4.19 kernel (tested with success) :

net/core/dev.c Tue Sep 23 18:35:35 2003 renamed from net/core/dev.c.orig Mon Sep 29 12:49:14 2003 +1 -1
@@ -1519,8 +1519,8 @@
 
 #ifdef CONFIG_NET_HW_FLOWCONTROL
     if (queue->throttle && queue->input_pkt_queue.qlen < no_cong_thresh ) {
+         queue->throttle = 0;
          if (atomic_dec_and_test(&netdev_dropping)) {
-              queue->throttle = 0;
               netdev_wakeup();
               goto softnet_break;
          }

I haven't done a patch for 2.4.22 (as we currently use 2.4.19) but the same modification should be applied around lines 1572 to 1577 of net/core/dev.c

For 2.6.0-test5, the lines to modified are arount 1631 to 1637.

Regards,
---
Daniel FAGES
ARKOON Network Security http://www.arkoon.net

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/