Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1539722

Re: [PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel messages

From Finn Thain <fthain@telegraphics.com.au>
Newsgroups linux.kernel
Subject Re: [PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel messages
Date 2016-12-10 00:00 +0100
Message-ID <sMCiZ-Cg-17@gated-at.bofh.it> (permalink)
References <sLMaJ-1Ll-5@gated-at.bofh.it> <sLMaK-1Ll-31@gated-at.bofh.it> <sLTOW-6J2-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 8 Dec 2016, I wrote:

> 
> On Wed, 7 Dec 2016, Geert Uytterhoeven wrote:
> 
> >   - Convert from printk() to pr_*(),
> >   - Add missing continuations,
> >   - Remove #undef DEBUG.
> > 
> > Note that "#ifdef DEBUG" is sometimes retained because pr_cont() is 
> > not optimized away when debugging is disabled.
> > 
> 
> I think that argues for using printk(KERN_DEBUG ...) and print(KERN_CONT 
> ...) inside #ifdef DEBUG, which would need no explanation.
> 
> If instead you use a combination of pr_debug and pr_cont and #ifdef 
> DEBUG, perhaps the explanation should be moved from the commit log to a 
> comment in the code?
> 

Perhaps a better solution than these alternatives would be,

#if defined(DEBUG)
#define pr_debug_cont pr_cont
#else
#define pr_debug_cont no_printk
#endif

But this API is still surprising and ugly. It doesn't work with 
CONFIG_DYNAMIC_DEBUG but that's not so important.

IMO, a far better linux/printk.h would have provided us with these 
definitions:

#define pr_emerg(fmt, ...) \
        printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
/* ... */
#define pr_debug(fmt, ...) \
        printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont(fmt, ...) \
        printk(KERN_CONT fmt, ##__VA_ARGS__)

#if defined(CONFIG_DYNAMIC_DEBUG)
#define pr_debug_cond(fmt, ...) \
        dynamic_pr_debug(fmt, ##__VA_ARGS__)
#define pr_cont_cond(fmt, ...) \
        dynamic_pr_cont(fmt, ##__VA_ARGS__)
#elif defined(DEBUG)
#define pr_debug_cond(fmt, ...) \
        printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont_cond(fmt, ...) \
        no_printk(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_debug_cond(fmt, ...) \
        no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont_cond(fmt, ...) \
        no_printk(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
#endif

Which have the virtues of symmetry and least surprise.

-- 

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel messages Geert Uytterhoeven <geert@linux-m68k.org> - 2016-12-07 16:20 +0100
  Re: [PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel  messages Finn Thain <fthain@telegraphics.com.au> - 2016-12-08 00:30 +0100
    Re: [PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel  messages Finn Thain <fthain@telegraphics.com.au> - 2016-12-10 00:00 +0100

csiph-web