From: Joe Perches <joe@perches.com>
To: Huang Ying <ying.huang@intel.com>
Cc: Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
Tony Luck <tony.luck@intel.com>,
linux-acpi@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH -v3 1/4] printk, Add pr_pfx for library functions
Date: Thu, 02 Dec 2010 00:37:15 -0800 [thread overview]
Message-ID: <1291279035.1761.58.camel@Joe-Laptop> (raw)
In-Reply-To: <1291277105-31758-2-git-send-email-ying.huang@intel.com>
On Thu, 2010-12-02 at 16:05 +0800, Huang Ying wrote:
> For library functions doing printk, the log level and line prefix
> usually need to be specified by the caller. So this patch adds
> "pr_pfx" to make the life of these library functions easier.
[]
> +#define pr_pfx(pfx, fmt, ...) \
> + printk("%s" fmt, pfx, ##__VA_ARGS__)
I think this would be a very error prone style.
pr_<foo> uses are log levels.
For an casual reader, is pfx a new log level or
is it a prefix or is it both? I do understand
what you intend.
Mutability of the KERN_<level> is pretty unusual.
Most all of the uses are ?: style
Here are the first uses in each file that has them:
There aren't many.
$ grep -rP -m1 --include=*.[ch] "KERN_[A-Z]+\s*:\s*KERN" *
arch/avr32/mm/fault.c: is_global_init(tsk) ? KERN_EMERG : KERN_INFO,
arch/sparc/kernel/traps_64.c: (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
arch/sparc/mm/fault_64.c: task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/sparc/mm/fault_32.c: task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/x86/kernel/signal.c: task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
arch/x86/mm/fault.c: task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/parisc/kernel/traps.c: level = user ? KERN_DEBUG : KERN_CRIT;
drivers/pci/pcie/aer/aerdrv_errprint.c: KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
include/linux/arcdevice.h: : x < D_DURING ? KERN_INFO : KERN_DEBUG, \
mm/internal.h: printk(level <= MMINIT_WARNING ? KERN_WARNING : KERN_DEBUG); \
sound/core/misc.c: const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT;
I don't see why you can't use something like that
with a simpler flag for level.
You also miss a chance to use pr_pfx in ghes_print_estatus:
+ if (__ratelimit(&ratelimit)) {
+ printk(
+ "%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
+ pfx, ghes->generic->header.source_id);
+ apei_estatus_print(pfx, ghes->estatus);
+
ghes_print_estatus is only called with a NULL first argument.
so the code use of pr_pfx seems dubious in any case.
next prev parent reply other threads:[~2010-12-02 8:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 8:05 [PATCH -v3 0/4] ACPI, APEI, Report GHES error information via printk Huang Ying
2010-12-02 8:05 ` [PATCH -v3 1/4] printk, Add pr_pfx for library functions Huang Ying
2010-12-02 8:37 ` Joe Perches [this message]
2010-12-02 8:54 ` Huang Ying
2010-12-02 8:05 ` [PATCH -v3 2/4] Add CPER PCIe error section structure and constants definition Huang Ying
2010-12-02 8:05 ` [PATCH -v3 3/4] ACPI, APEI, Add APEI generic error status printing support Huang Ying
2010-12-02 8:05 ` [PATCH -v3 4/4] ACPI, APEI, Report GHES error information via printk Huang Ying
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291279035.1761.58.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox