Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dynamic_debug: make netdev_dbg() call __netdev_printk()

Previously, if dynamic debug was enabled netdev_dbg() was using
dynamic_dev_dbg() to print out the underlying msg. Fix this by making
sure netdev_dbg() uses __netdev_printk().

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jason Baron and committed by
Greg Kroah-Hartman
ffa10cb4 ac0ac38f

+48 -3
+17
include/linux/dynamic_debug.h
··· 47 47 const char *fmt, ...) 48 48 __attribute__ ((format (printf, 3, 4))); 49 49 50 + struct net_device; 51 + 52 + extern int __dynamic_netdev_dbg(struct _ddebug *descriptor, 53 + const struct net_device *dev, 54 + const char *fmt, ...) 55 + __attribute__ ((format (printf, 3, 4))); 56 + 50 57 #define dynamic_pr_debug(fmt, ...) do { \ 51 58 static struct _ddebug descriptor \ 52 59 __used \ ··· 72 65 _DPRINTK_FLAGS_DEFAULT }; \ 73 66 if (unlikely(descriptor.enabled)) \ 74 67 __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \ 68 + } while (0) 69 + 70 + #define dynamic_netdev_dbg(dev, fmt, ...) do { \ 71 + static struct _ddebug descriptor \ 72 + __used \ 73 + __attribute__((section("__verbose"), aligned(8))) = \ 74 + { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 75 + _DPRINTK_FLAGS_DEFAULT }; \ 76 + if (unlikely(descriptor.enabled)) \ 77 + __dynamic_netdev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);\ 75 78 } while (0) 76 79 77 80 #else
+4 -2
include/linux/netdevice.h
··· 2617 2617 return dev->name; 2618 2618 } 2619 2619 2620 + extern int __netdev_printk(const char *level, const struct net_device *dev, 2621 + struct va_format *vaf); 2622 + 2620 2623 extern int netdev_printk(const char *level, const struct net_device *dev, 2621 2624 const char *format, ...) 2622 2625 __attribute__ ((format (printf, 3, 4))); ··· 2647 2644 #elif defined(CONFIG_DYNAMIC_DEBUG) 2648 2645 #define netdev_dbg(__dev, format, args...) \ 2649 2646 do { \ 2650 - dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ 2651 - netdev_name(__dev), ##args); \ 2647 + dynamic_netdev_dbg(__dev, format, ##args); \ 2652 2648 } while (0) 2653 2649 #else 2654 2650 #define netdev_dbg(__dev, format, args...) \
+25
lib/dynamic_debug.c
··· 33 33 #include <linux/hardirq.h> 34 34 #include <linux/sched.h> 35 35 #include <linux/device.h> 36 + #include <linux/netdevice.h> 36 37 37 38 extern struct _ddebug __start___verbose[]; 38 39 extern struct _ddebug __stop___verbose[]; ··· 503 502 return res; 504 503 } 505 504 EXPORT_SYMBOL(__dynamic_dev_dbg); 505 + 506 + int __dynamic_netdev_dbg(struct _ddebug *descriptor, 507 + const struct net_device *dev, const char *fmt, ...) 508 + { 509 + struct va_format vaf; 510 + va_list args; 511 + int res; 512 + 513 + BUG_ON(!descriptor); 514 + BUG_ON(!fmt); 515 + 516 + va_start(args, fmt); 517 + 518 + vaf.fmt = fmt; 519 + vaf.va = &args; 520 + 521 + res = dynamic_emit_prefix(descriptor); 522 + res += __netdev_printk(KERN_CONT, dev, &vaf); 523 + 524 + va_end(args); 525 + 526 + return res; 527 + } 528 + EXPORT_SYMBOL(__dynamic_netdev_dbg); 506 529 507 530 static __initdata char ddebug_setup_string[1024]; 508 531 static __init int ddebug_setup_query(char *str)
+2 -1
net/core/dev.c
··· 6290 6290 return empty; 6291 6291 } 6292 6292 6293 - static int __netdev_printk(const char *level, const struct net_device *dev, 6293 + int __netdev_printk(const char *level, const struct net_device *dev, 6294 6294 struct va_format *vaf) 6295 6295 { 6296 6296 int r; ··· 6305 6305 6306 6306 return r; 6307 6307 } 6308 + EXPORT_SYMBOL(__netdev_printk); 6308 6309 6309 6310 int netdev_printk(const char *level, const struct net_device *dev, 6310 6311 const char *format, ...)