Skip to contentSkip to conversation

netpoll: Introduce netpoll_carrier_timeout kernel option

PATCH Superseded Anton Vorontsov 4 participants 6 messages Jul 8, 2009

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

PATCH 1/1 netpoll: Introduce netpoll_carrier_timeout kernel option

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

---
 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |   11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)
Documentation/kernel-parameters.txt +5 -0
index d77fbd8..9eac5bd 100644
@@ -1531,6 +1531,11 @@ and is between 256 and 4096 characters. It is defined in the file
 			symbolic names: lapic and ioapic
 			Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
 
+	netpoll_carrier_timeout=
+			[NET] Specifies amount of time (in seconds) that
+			netpoll should wait for a carrier. By default netpoll
+			waits 4 seconds.
+
 	no387		[BUGS=X86-32] Tells the kernel to use the 387 maths
 			emulation library even if a 387 maths coprocessor
 			is present.
net/core/netpoll.c +10 -1
index 9675f31..4371da2 100644
@@ -50,6 +50,15 @@ static atomic_t trapped;
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
+static unsigned int carrier_timeout = 4;
+
+static int __init carrier_timeout_setup(char *str)
+{
+	carrier_timeout = simple_strtoul(str, NULL, 0);
+	return 1;
+}
+__setup("netpoll_carrier_timeout=", carrier_timeout_setup);
+
 static void queue_process(struct work_struct *work)
 {
 	struct netpoll_info *npinfo =
@@ -732,7 +741,7 @@ int netpoll_setup(struct netpoll *np)
 		}
 
 		atleast = jiffies + HZ/10;
-		atmost = jiffies + 4*HZ;
+		atmost = jiffies + carrier_timeout * HZ;
 		while (!netif_carrier_ok(ndev)) {
 			if (time_after(jiffies, atmost)) {
 				printk(KERN_NOTICE
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 11 lines · On Wed, 8 Jul 2009 05:00:30 +0400 Anton Vorontsov <[email protected]>…

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

---
 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |   11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

A sysctl (or module option) is a less awkward interface for something like this. Kernel command line parameters are ugly step children loved only by embedded developers.

#2 lore raw

PATCH v2 1/1 netpoll: Introduce netpoll_carrier_timeout kernel option

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

Since we're using module_param(), the option also can be changed in runtime.

---

Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Wed, 8 Jul 2009 05:00:30 +0400 Anton Vorontsov <[email protected]>…

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

Quoted 8 lines
Quoted 5 lines
---
 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |   11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

A sysctl (or module option) is a less awkward interface for something like this.

Right you are, and it's less code. Wasn't sure if it makes sense to use module_param() for non-modular code, but afterall it makes sense indeed, since with it we can change the timeout in runtime.

Quoted 2 lines

Kernel command line parameters are ugly step children loved only by embedded developers.

So true! ;-)

How about this patch?

Thanks,

 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
Documentation/kernel-parameters.txt +5 -0
index d77fbd8..9347f4a 100644
@@ -1531,6 +1531,11 @@ and is between 256 and 4096 characters. It is defined in the file
 			symbolic names: lapic and ioapic
 			Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
 
+	netpoll.carrier_timeout=
+			[NET] Specifies amount of time (in seconds) that
+			netpoll should wait for a carrier. By default netpoll
+			waits 4 seconds.
+
 	no387		[BUGS=X86-32] Tells the kernel to use the 387 maths
 			emulation library even if a 387 maths coprocessor
 			is present.
net/core/netpoll.c +5 -1
index 9675f31..3afe381 100644
@@ -9,6 +9,7 @@
  * Copyright (C) 2002  Red Hat, Inc.
  */
 
+#include <linux/moduleparam.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -50,6 +51,9 @@ static atomic_t trapped;
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
+static unsigned int carrier_timeout = 4;
+module_param(carrier_timeout, uint, 0644);
+
 static void queue_process(struct work_struct *work)
 {
 	struct netpoll_info *npinfo =
@@ -732,7 +736,7 @@ int netpoll_setup(struct netpoll *np)
 		}
 
 		atleast = jiffies + HZ/10;
-		atmost = jiffies + 4*HZ;
+		atmost = jiffies + carrier_timeout * HZ;
 		while (!netif_carrier_ok(ndev)) {
 			if (time_after(jiffies, atmost)) {
 				printk(KERN_NOTICE
Signature · 1 line
1.6.3.3
#3 lore raw
Quoted 53 lines · Anton Vorontsov

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

Since we're using module_param(), the option also can be changed in runtime.

---

Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Wed, 8 Jul 2009 05:00:30 +0400 Anton Vorontsov <[email protected]>…

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

Quoted 8 lines
Quoted 5 lines
---
 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |   11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

A sysctl (or module option) is a less awkward interface for something like this.

Right you are, and it's less code. Wasn't sure if it makes sense to use module_param() for non-modular code, but afterall it makes sense indeed, since with it we can change the timeout in runtime.

Quoted 2 lines

Kernel command line parameters are ugly step children loved only by embedded developers.

So true! ;-)

How about this patch?

Thanks,

 Documentation/kernel-parameters.txt |    5 +++++
 net/core/netpoll.c                  |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
Documentation/kernel-parameters.txt +0 -0
index d77fbd8..9347f4a 100644

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1538

Quoted 8 lines
Documentation/kernel-parameters.txt +5 -0
@@ -1531,6 +1531,11 @@ and is between 256 and 4096 characters. It is defined in the file
 			symbolic names: lapic and ioapic
 			Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
 
+	netpoll.carrier_timeout=
+			[NET] Specifies amount of time (in seconds) that
+			netpoll should wait for a carrier. By default netpoll
+			waits 4 seconds.
+

I'm not sure the documentation still belongs in kernel-parameters.txt if you make this a module options, but thats just a nit.

Quoted 27 lines
Documentation/kernel-parameters.txt +5 -1
+#include <linux/moduleparam.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -50,6 +51,9 @@ static atomic_t trapped;
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
+static unsigned int carrier_timeout = 4;
+module_param(carrier_timeout, uint, 0644);
+
 static void queue_process(struct work_struct *work)
 {
 	struct netpoll_info *npinfo =
@@ -732,7 +736,7 @@ int netpoll_setup(struct netpoll *np)
 		}
 
 		atleast = jiffies + HZ/10;
-		atmost = jiffies + 4*HZ;
+		atmost = jiffies + carrier_timeout * HZ;
 		while (!netif_carrier_ok(ndev)) {
 			if (time_after(jiffies, atmost)) {
 				printk(KERN_NOTICE
Signature · 1 line
1.6.3.3

I don't mind this functionality at all, but I'm looking at the code, and I have a hard time understanding why we bring up an interface here at all. I get that we might want early netpoll access for netconsole or something like that, but looking at the console code I don't see where we buffer anything other than the standard dmesg log. I don't see much reason why we can't just let normal early interface initalization from an initramfs bring up an interface like it normally does.

Neil

Quoted 5 lines

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

#4 lore raw

On Wed, Jul 08, 2009 at 06:59:02AM -0400, Neil Horman wrote:
[...]

Quoted 8 lines
Quoted 8 lines
Documentation/kernel-parameters.txt +0 -0
index d77fbd8..9347f4a 100644
@@ -1531,6 +1531,11 @@ and is between 256 and 4096 characters. It is defined in the file
 			symbolic names: lapic and ioapic
 			Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
 
Quoted 7 lines

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 1538

Quoted 5 lines
Documentation/kernel-parameters.txt +5 -0
+	netpoll.carrier_timeout=
+			[NET] Specifies amount of time (in seconds) that
+			netpoll should wait for a carrier. By default netpoll
+			waits 4 seconds.
+

I'm not sure the documentation still belongs in kernel-parameters.txt if you make this a module options, but thats just a nit.

There are other module options described in the kernel-parameters.txt. Plus it's really a kernel parameter. ;-)

Quoted 18 lines
Quoted 18 lines
Documentation/kernel-parameters.txt +4 -0
+#include <linux/moduleparam.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -50,6 +51,9 @@ static atomic_t trapped;
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
 
+static unsigned int carrier_timeout = 4;
+module_param(carrier_timeout, uint, 0644);
+
 static void queue_process(struct work_struct *work)
 {
 	struct netpoll_info *npinfo =
@@ -732,7 +736,7 @@ int netpoll_setup(struct netpoll *np)
 		}
 
Quoted 16 lines
Quoted 9 lines
Documentation/kernel-parameters.txt +1 -1
 		atleast = jiffies + HZ/10;
-		atmost = jiffies + 4*HZ;
+		atmost = jiffies + carrier_timeout * HZ;
 		while (!netif_carrier_ok(ndev)) {
 			if (time_after(jiffies, atmost)) {
 				printk(KERN_NOTICE
Signature · 1 line
1.6.3.3

I don't mind this functionality at all, but I'm looking at the code, and I have a hard time understanding why we bring up an interface here at all. I get that we might want early netpoll access for netconsole or something like that, but looking at the console code I don't see where we buffer anything other than the standard dmesg log. I don't see much reason why we can't just let normal early interface initalization from an initramfs bring up an interface like it normally does.

The earlier you bring the interface up, the earlier you'll able to catch kernel oopses. netconsole is quite useful when you don't have serial ports. The same applies for KGDBoE -- you might want to start debugging the kernel as soon as possible.

Sure, netconsole starts at module_init(), but looking at my dmesg, netconsole initialization starts closer to the top of the log, so it'll catch > 60% of oopses, i.e. all oopses in subsystems that are below net/ in drivers/Makefile.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
maintainer
#5 lore raw
In reply to Anton Vorontsov

From: Anton Vorontsov <[email protected]>
Date: Wed, 8 Jul 2009 05:30:11 +0400

Quoted 10 lines

Some PHYs require longer timeouts for carrier detection, and auto-negotiation process may take indefinite amount of time.

It may be inconvenient to force longer timeouts for sane PHYs, so let's introduce a kernel command line option.

Since we're using module_param(), the option also can be changed in runtime.

Seems reasonable, applied to net-next-2.6, thanks.