diff options
author | Joe Perches <joe@perches.com> | 2012-09-12 23:12:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-17 09:08:30 -0400 |
commit | b004ff4972e2a42aa4512c90cc6a9e4dc1bb36b6 (patch) | |
tree | 13d68f77aeb0db8cf32ff81f7fc6931640c13f70 /lib | |
parent | 798efc60e4276825df34af0e91ecbe0781237834 (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 'lib')
-rw-r--r-- | lib/dynamic_debug.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 29ff2e4cfb75..2a29f4e04bdf 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -611,20 +611,40 @@ EXPORT_SYMBOL(__dynamic_dev_dbg); | |||
611 | #ifdef CONFIG_NET | 611 | #ifdef CONFIG_NET |
612 | 612 | ||
613 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | 613 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, |
614 | const struct net_device *dev, const char *fmt, ...) | 614 | const struct net_device *dev, const char *fmt, ...) |
615 | { | 615 | { |
616 | struct va_format vaf; | 616 | struct va_format vaf; |
617 | va_list args; | 617 | va_list args; |
618 | int res; | 618 | int res; |
619 | char buf[PREFIX_SIZE]; | ||
620 | 619 | ||
621 | BUG_ON(!descriptor); | 620 | BUG_ON(!descriptor); |
622 | BUG_ON(!fmt); | 621 | BUG_ON(!fmt); |
623 | 622 | ||
624 | va_start(args, fmt); | 623 | va_start(args, fmt); |
624 | |||
625 | vaf.fmt = fmt; | 625 | vaf.fmt = fmt; |
626 | vaf.va = &args; | 626 | vaf.va = &args; |
627 | res = __netdev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf); | 627 | |
628 | if (dev && dev->dev.parent) { | ||
629 | char buf[PREFIX_SIZE]; | ||
630 | char dict[128]; | ||
631 | size_t dictlen; | ||
632 | |||
633 | dictlen = create_syslog_header(dev->dev.parent, | ||
634 | dict, sizeof(dict)); | ||
635 | |||
636 | res = printk_emit(0, 7, dictlen ? dict : NULL, dictlen, | ||
637 | "%s%s %s: %s: %pV", | ||
638 | dynamic_emit_prefix(descriptor, buf), | ||
639 | dev_driver_string(dev->dev.parent), | ||
640 | dev_name(dev->dev.parent), | ||
641 | netdev_name(dev), &vaf); | ||
642 | } else if (dev) { | ||
643 | res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf); | ||
644 | } else { | ||
645 | res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); | ||
646 | } | ||
647 | |||
628 | va_end(args); | 648 | va_end(args); |
629 | 649 | ||
630 | return res; | 650 | return res; |