Re: [PATCH] twist: allow converting pr_devel()/pr_debug() into printk(KERN_DEBUG)

From: Joe Perches
Date: Thu May 28 2020 - 13:08:26 EST


On Thu, 2020-05-28 at 14:14 +0200, Petr Mladek wrote:
> On Thu 2020-05-28 20:33:10, Tetsuo Handa wrote:
> > On 2020/05/28 19:59, Petr Mladek wrote:
> > > 2. Add twist into vprintk_store(). In the current, implementation
> > > it would do:
> > >
> > > #if TWIST
> > > return text_len;
> > > #endif
> > >
> > > return log_output(facility, level, lflags,
> > > dict, dictlen, text, text_len);
> >
> > This part could be possible. But
> >
> > > 1. Add twist into ddebug_add_module() and enable all newly added
> > > entries by default. For example, by calling
> > > ddebug_exec_query("*:+p", const char *modname) or what is the syntax.
> > >
> > > This will cause that any pr_devel() variant will always get called.
> >
> > how to handle
> >
> > > > #define no_printk(fmt, ...) \
> > > > ({ \
> > > > if (0) \
> > > > printk(fmt, ##__VA_ARGS__); \
> > > > 0; \
> > > > })
> >
> > part used by e.g. pr_devel() ? Since this macro is not using dynamic debug
> > interface, vprintk_store() will not be called from the beginning. Are you
> > suggesting that we should convert no_printk() to use dynamic debug interface ?
>
> OK, this is one more path that would need special handling. Two paths
> are much better than 15.

A few more:

$ grep-2.5.4 --include=*.[ch] -rP '\if\s*\(\s*0\s*\)\s*\{?\s*\\?\s*no_printk' *
drivers/platform/x86/thinkpad_acpi.c: do { if (0) no_printk(format, ##arg); } while (0)
fs/ntfs/debug.h: if (0) \
no_printk(fmt, ##__VA_ARGS__); \
include/linux/net.h: if (0) \
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
kernel/cred.c: if (0) \
no_printk("[%-5.5s%5u] " FMT "\n", \