aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-09-12 23:12:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-17 09:08:30 -0400
commitb004ff4972e2a42aa4512c90cc6a9e4dc1bb36b6 (patch)
tree13d68f77aeb0db8cf32ff81f7fc6931640c13f70 /net/core/dev.c
parent798efc60e4276825df34af0e91ecbe0781237834 (diff)
netdev_printk/dynamic_netdev_dbg: Directly call printk_emit
A lot of stack is used in recursive printks with %pV. Using multiple levels of %pV (a logging function with %pV that calls another logging function with %pV) can consume more stack than necessary. Avoid excessive stack use by not calling dev_printk from netdev_printk and dynamic_netdev_dbg. Duplicate the logic and form of dev_printk instead. Make __netdev_printk static. Remove EXPORT_SYMBOL(__netdev_printk) Whitespace and brace style neatening. Signed-off-by: Joe Perches <joe@perches.com> Acked-by: David S. Miller <davem@davemloft.net> Tested-by: Jim Cromie <jim.cromie@gmail.com> Acked-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index d7fe32c946c1..ac890f14613a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6423,22 +6423,30 @@ const char *netdev_drivername(const struct net_device *dev)
6423 return empty; 6423 return empty;
6424} 6424}
6425 6425
6426int __netdev_printk(const char *level, const struct net_device *dev, 6426static int __netdev_printk(const char *level, const struct net_device *dev,
6427 struct va_format *vaf) 6427 struct va_format *vaf)
6428{ 6428{
6429 int r; 6429 int r;
6430 6430
6431 if (dev && dev->dev.parent) 6431 if (dev && dev->dev.parent) {
6432 r = dev_printk(level, dev->dev.parent, "%s: %pV", 6432 char dict[128];
6433 netdev_name(dev), vaf); 6433 size_t dictlen = create_syslog_header(dev->dev.parent,
6434 else if (dev) 6434 dict, sizeof(dict));
6435
6436 r = printk_emit(0, level[1] - '0',
6437 dictlen ? dict : NULL, dictlen,
6438 "%s %s: %s: %pV",
6439 dev_driver_string(dev->dev.parent),
6440 dev_name(dev->dev.parent),
6441 netdev_name(dev), vaf);
6442 } else if (dev) {
6435 r = printk("%s%s: %pV", level, netdev_name(dev), vaf); 6443 r = printk("%s%s: %pV", level, netdev_name(dev), vaf);
6436 else 6444 } else {
6437 r = printk("%s(NULL net_device): %pV", level, vaf); 6445 r = printk("%s(NULL net_device): %pV", level, vaf);
6446 }
6438 6447
6439 return r; 6448 return r;
6440} 6449}
6441EXPORT_SYMBOL(__netdev_printk);
6442 6450
6443int netdev_printk(const char *level, const struct net_device *dev, 6451int netdev_printk(const char *level, const struct net_device *dev,
6444 const char *format, ...) 6452 const char *format, ...)
@@ -6453,6 +6461,7 @@ int netdev_printk(const char *level, const struct net_device *dev,
6453 vaf.va = &args; 6461 vaf.va = &args;
6454 6462
6455 r = __netdev_printk(level, dev, &vaf); 6463 r = __netdev_printk(level, dev, &vaf);
6464
6456 va_end(args); 6465 va_end(args);
6457 6466
6458 return r; 6467 return r;
@@ -6472,6 +6481,7 @@ int func(const struct net_device *dev, const char *fmt, ...) \
6472 vaf.va = &args; \ 6481 vaf.va = &args; \
6473 \ 6482 \
6474 r = __netdev_printk(level, dev, &vaf); \ 6483 r = __netdev_printk(level, dev, &vaf); \
6484 \
6475 va_end(args); \ 6485 va_end(args); \
6476 \ 6486 \
6477 return r; \ 6487 return r; \