Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753449AbcLIWuJ (ORCPT ); Fri, 9 Dec 2016 17:50:09 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48046 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbcLIWuI (ORCPT ); Fri, 9 Dec 2016 17:50:08 -0500 Date: Sat, 10 Dec 2016 09:50:09 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Greg Ungerer , Sam Creasey , Joshua Thompson , linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 18/22] m68k/mm: kmap - Modernize printing of kernel messages In-Reply-To: Message-ID: References: <1481123360-10978-1-git-send-email-geert@linux-m68k.org> <1481123360-10978-19-git-send-email-geert@linux-m68k.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1886 Lines: 64 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. --