netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: netdev@vger.kernel.org, davem@davemloft.net
Subject: Printing the driver name as part of the netdev watchdog message
Date: Sun, 6 Jul 2008 13:08:01 -0700	[thread overview]
Message-ID: <20080706130801.6bc36cf7@infradead.org> (raw)

Hi Dave and co,

a few weeks ago you suggested to print the driver name as part of the WARN_ON for the 
watchdog timeout message; the patch below will do this.

The patch depends on the patch to add WARN(), a WARN_ON() variant taking printk arguments.
With WARN(), the actual message is part of the ==[ cut here ]== so that tools and humans
pick up the message as well when reporting the bugs.

Does this patch look like the right approach for achieving the goal?
If so... on the logistics side, how should we do this, since the WARN() patch is
not in mainline yet. I have a patch series adding it / users of it, and could just fold this patch
into that series assuming you ack the patch. Obviously I'm also open to other ways
of dealing with the logistics


From: Arjan van de Ven <arjan@linux.intel.com>
Subject: Use WARN_ONCE() in the netdev timeout handler (and print module name)

As suggested by Dave:

This patch adds a function to get the driver name from a struct net_device,
and consequently uses this in the watchdog timeout handler to print as 
part of the message. To make this useful, use WARN_ONCE() so that the
message is part of the ===[ cut here ]=== section, meaning that people
are more likely to report it, and automated warning collection will pick it up.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 include/linux/netdevice.h |    3 +++
 net/core/dev.c            |   22 +++++++++++++++++++---
 net/sched/sch_generic.c   |    9 +++++----
 3 files changed, 27 insertions(+), 7 deletions(-)

Index: linux.trees.git/include/linux/netdevice.h
===================================================================
--- linux.trees.git.orig/include/linux/netdevice.h
+++ linux.trees.git/include/linux/netdevice.h
@@ -1514,6 +1514,9 @@ extern void dev_seq_stop(struct seq_file
 extern int netdev_class_create_file(struct class_attribute *class_attr);
 extern void netdev_class_remove_file(struct class_attribute *class_attr);
 
+extern void netdev_drivername(struct net_device *dev, char *buffer, int len);
+
+
 extern void linkwatch_run_queue(void);
 
 extern int netdev_compute_features(unsigned long all, unsigned long one);
Index: linux.trees.git/net/core/dev.c
===================================================================
--- linux.trees.git.orig/net/core/dev.c
+++ linux.trees.git/net/core/dev.c
@@ -3706,10 +3706,8 @@ static void rollback_registered(struct n
 
 	/* Some devices call without registering for initialization unwind. */
 	if (dev->reg_state == NETREG_UNINITIALIZED) {
-		printk(KERN_DEBUG "unregister_netdevice: device %s/%p never "
+		WARN(1, KERN_DEBUG "unregister_netdevice: device %s/%p never "
 				  "was registered\n", dev->name, dev);
-
-		WARN_ON(1);
 		return;
 	}
 
@@ -4554,6 +4552,24 @@ err_name:
 	return -ENOMEM;
 }
 
+void netdev_drivername(struct net_device *dev, char *buffer, int len)
+{
+	struct device_driver *driver;
+	struct device *parent;
+	if (len <= 0)
+		return;
+	buffer[0] = 0;
+
+	parent = dev->dev.parent;
+
+	if (!parent)
+		return;
+
+	driver = parent->driver;
+	if (driver && driver->name)
+		strlcpy(buffer, driver->name, len);
+}
+
 static void __net_exit netdev_exit(struct net *net)
 {
 	kfree(net->dev_name_head);
Index: linux.trees.git/net/sched/sch_generic.c
===================================================================
--- linux.trees.git.orig/net/sched/sch_generic.c
+++ linux.trees.git/net/sched/sch_generic.c
@@ -215,11 +215,12 @@ static void dev_watchdog(unsigned long a
 		    netif_carrier_ok(dev)) {
 			if (netif_queue_stopped(dev) &&
 			    time_after(jiffies, dev->trans_start + dev->watchdog_timeo)) {
-
-				printk(KERN_INFO "NETDEV WATCHDOG: %s: transmit timed out\n",
-				       dev->name);
+				char drivername[64];
+				netdev_drivername(dev, drivername, 64);
+				WARN_ONCE(1, KERN_INFO
+					"NETDEV WATCHDOG: %s (%s): transmit timed out\n",
+					dev->name, drivername);
 				dev->tx_timeout(dev);
-				WARN_ON_ONCE(1);
 			}
 			if (!mod_timer(&dev->watchdog_timer, round_jiffies(jiffies + dev->watchdog_timeo)))
 				dev_hold(dev);

             reply	other threads:[~2008-07-06 20:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-06 20:08 Arjan van de Ven [this message]
2008-07-06 22:53 ` Printing the driver name as part of the netdev watchdog message David Miller
2008-07-06 23:56   ` Arjan van de Ven
2008-07-07  1:51     ` Wang Chen
2008-07-07  3:59       ` David Miller
2008-07-07  4:34         ` Arjan van de Ven
2008-07-07  4:49           ` David Miller
2008-07-07  4:57             ` Arjan van de Ven
2008-07-07  6:44               ` David Miller
2008-07-07 15:23                 ` Arjan van de Ven
2008-07-07  1:08   ` Stephen Hemminger
2008-07-07  1:22     ` David Miller
2008-07-07  1:53       ` Jeff Garzik
2008-07-07 17:05         ` Stephen Hemminger
2008-07-07 22:45       ` Roland Dreier
2008-07-07 22:57         ` David Miller
2008-07-07 23:14           ` Roland Dreier
2008-07-07 23:44             ` Stephen Hemminger
2008-07-08  0:10               ` Arjan van de Ven
2008-07-08 19:13             ` Steve Wise
2008-07-08 21:31               ` David Miller
2008-07-08 21:47                 ` Arjan van de Ven
2008-07-08 21:57                   ` David Miller
2008-07-08 23:48                     ` Arjan van de Ven
2008-07-08 23:53                       ` David Miller
2008-07-09  0:17                         ` Arjan van de Ven
2008-07-09  1:44                         ` Arjan van de Ven
2008-07-09  3:16                           ` Stephen Hemminger
2008-07-09 17:20                             ` Joe Perches
2008-07-09 17:56                               ` Arjan van de Ven
2008-07-09 18:20                                 ` Joe Perches
2008-07-09 18:50                                   ` Arjan van de Ven
2008-07-09 18:28                                 ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080706130801.6bc36cf7@infradead.org \
    --to=arjan@infradead.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).