mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
798efc60e4
commit
b004ff4972
3 changed files with 40 additions and 13 deletions
|
@ -611,20 +611,40 @@ EXPORT_SYMBOL(__dynamic_dev_dbg);
|
|||
#ifdef CONFIG_NET
|
||||
|
||||
int __dynamic_netdev_dbg(struct _ddebug *descriptor,
|
||||
const struct net_device *dev, const char *fmt, ...)
|
||||
const struct net_device *dev, const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
int res;
|
||||
char buf[PREFIX_SIZE];
|
||||
|
||||
BUG_ON(!descriptor);
|
||||
BUG_ON(!fmt);
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
res = __netdev_printk(dynamic_emit_prefix(descriptor, buf), dev, &vaf);
|
||||
|
||||
if (dev && dev->dev.parent) {
|
||||
char buf[PREFIX_SIZE];
|
||||
char dict[128];
|
||||
size_t dictlen;
|
||||
|
||||
dictlen = create_syslog_header(dev->dev.parent,
|
||||
dict, sizeof(dict));
|
||||
|
||||
res = printk_emit(0, 7, dictlen ? dict : NULL, dictlen,
|
||||
"%s%s %s: %s: %pV",
|
||||
dynamic_emit_prefix(descriptor, buf),
|
||||
dev_driver_string(dev->dev.parent),
|
||||
dev_name(dev->dev.parent),
|
||||
netdev_name(dev), &vaf);
|
||||
} else if (dev) {
|
||||
res = printk(KERN_DEBUG "%s: %pV", netdev_name(dev), &vaf);
|
||||
} else {
|
||||
res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
|
||||
return res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue