From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] printk: Convert pr_<level> macros to functions
Date: Thu, 4 Mar 2010 12:49:43 -0800 [thread overview]
Message-ID: <20100304124943.ce7c1a63.akpm@linux-foundation.org> (raw)
In-Reply-To: <1267629618.8926.73.camel@Joe-Laptop.home>
On Wed, 03 Mar 2010 07:20:18 -0800
Joe Perches <joe@perches.com> wrote:
> printk is defined asmlinkage (extern "C")
> For this RFC patch, pr_<level> calls are as well.
> Is this declaration style really necessary?
> Maybe moving printed_len to file scope is racy somehow?
Yes, printed_len will get corrupted when multiple CPU's are running
printk/vprintk simultaneously. That'll need to be fixed.
> Save 3 bytes per pr_<level> use after printk overhead
>
> Does not store the KERN_<level> string as constant string
> when using pr_<level> calls
>
> printk.o increases ~200 bytes
> defconfig decreases ~700 bytes
>
> Minor printk neatening, moving comments above function declaration
> Renamed vprint to __vprintk, added vprintk wrapper
> Moved automatic printed_len to file static
> Moved EXPORT_SYMBOL after functions
>
Looks good at the first peek. Is it possible to reduce the amount of
code movement in the patch, make it a bit easier to follow? Maybe do
it as two patches, with the move-stuff-around patch being [1/2]?
>
> ...
>
> +asmlinkage int pr_emerg(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('0', fmt, args);
> + r = __vprintk(fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_emerg);
> +
> +asmlinkage int pr_alert(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('1', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_alert);
> +
> +asmlinkage int pr_crit(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('2', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_crit);
> +
> +asmlinkage int pr_err(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('3', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_err);
> +
> +asmlinkage int pr_warning(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('4', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_warning);
> +
> +asmlinkage int pr_notice(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('5', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_notice);
> +
> +asmlinkage int pr_info(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('6', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_info);
> +
> +asmlinkage int pr_cont(const char *fmt, ...)
> +{
> + va_list args;
> + int r;
> +
> + va_start(args, fmt);
> + r = pr_printk('c', fmt, args);
> + va_end(args);
> +
> + return r;
> +}
> +EXPORT_SYMBOL(pr_cont);
I think it would be justifiable to cook up a freaky macro and expand it
eight times to avoid this duplication. Ugly, but better than lots of
duplication.
Or perhaps we can do it via a helper function which takes the
additional argument?
asmlinkage int pr_everything(char levelchar, const char *fmt, ...)
?
next prev parent reply other threads:[~2010-03-04 20:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 15:20 [RFC PATCH] printk: Convert pr_<level> macros to functions Joe Perches
2010-03-04 20:49 ` Andrew Morton [this message]
2010-03-04 21:29 ` Joe Perches
2010-03-04 21:34 ` Andrew Morton
2010-03-04 21:40 ` Joe Perches
2010-03-04 22:00 ` Andrew Morton
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=20100304124943.ce7c1a63.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.