Skip to content

Commit ffa10cb

Browse files
jibarongregkh
authored andcommitted
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>
1 parent ac0ac38 commit ffa10cb

4 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎include/linux/dynamic_debug.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
4747
const char *fmt, ...)
4848
__attribute__ ((format (printf, 3, 4)));
4949

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+
5057
#define dynamic_pr_debug(fmt, ...) do { \
5158
static struct _ddebug descriptor \
5259
__used \
@@ -67,6 +74,16 @@ extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
6774
__dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \
6875
} while (0)
6976

77+
#define dynamic_netdev_dbg(dev, fmt, ...) do { \
78+
static struct _ddebug descriptor \
79+
__used \
80+
__attribute__((section("__verbose"), aligned(8))) = \
81+
{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
82+
_DPRINTK_FLAGS_DEFAULT }; \
83+
if (unlikely(descriptor.enabled)) \
84+
__dynamic_netdev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);\
85+
} while (0)
86+
7087
#else
7188

7289
static inline int ddebug_remove_module(const char *mod)

‎include/linux/netdevice.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,9 @@ static inline const char *netdev_name(const struct net_device *dev)
26172617
return dev->name;
26182618
}
26192619

2620+
extern int __netdev_printk(const char *level, const struct net_device *dev,
2621+
struct va_format *vaf);
2622+
26202623
extern int netdev_printk(const char *level, const struct net_device *dev,
26212624
const char *format, ...)
26222625
__attribute__ ((format (printf, 3, 4)));
@@ -2644,8 +2647,7 @@ extern int netdev_info(const struct net_device *dev, const char *format, ...)
26442647
#elif defined(CONFIG_DYNAMIC_DEBUG)
26452648
#define netdev_dbg(__dev, format, args...) \
26462649
do { \
2647-
dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \
2648-
netdev_name(__dev), ##args); \
2650+
dynamic_netdev_dbg(__dev, format, ##args); \
26492651
} while (0)
26502652
#else
26512653
#define netdev_dbg(__dev, format, args...) \

‎lib/dynamic_debug.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/hardirq.h>
3434
#include <linux/sched.h>
3535
#include <linux/device.h>
36+
#include <linux/netdevice.h>
3637

3738
extern struct _ddebug __start___verbose[];
3839
extern struct _ddebug __stop___verbose[];
@@ -503,6 +504,30 @@ int __dynamic_dev_dbg(struct _ddebug *descriptor,
503504
}
504505
EXPORT_SYMBOL(__dynamic_dev_dbg);
505506

507+
int __dynamic_netdev_dbg(struct _ddebug *descriptor,
508+
const struct net_device *dev, const char *fmt, ...)
509+
{
510+
struct va_format vaf;
511+
va_list args;
512+
int res;
513+
514+
BUG_ON(!descriptor);
515+
BUG_ON(!fmt);
516+
517+
va_start(args, fmt);
518+
519+
vaf.fmt = fmt;
520+
vaf.va = &args;
521+
522+
res = dynamic_emit_prefix(descriptor);
523+
res += __netdev_printk(KERN_CONT, dev, &vaf);
524+
525+
va_end(args);
526+
527+
return res;
528+
}
529+
EXPORT_SYMBOL(__dynamic_netdev_dbg);
530+
506531
static __initdata char ddebug_setup_string[1024];
507532
static __init int ddebug_setup_query(char *str)
508533
{

‎net/core/dev.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6290,7 +6290,7 @@ const char *netdev_drivername(const struct net_device *dev)
62906290
return empty;
62916291
}
62926292

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,
62946294
struct va_format *vaf)
62956295
{
62966296
int r;
@@ -6305,6 +6305,7 @@ static int __netdev_printk(const char *level, const struct net_device *dev,
63056305

63066306
return r;
63076307
}
6308+
EXPORT_SYMBOL(__netdev_printk);
63086309

63096310
int netdev_printk(const char *level, const struct net_device *dev,
63106311
const char *format, ...)

0 commit comments

Comments
 (0)