From: Joe Perches <joe@perches.com>
To: Borislav Petkov <bp@alien8.de>, LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>, X86 ML <x86@kernel.org>
Subject: Re: [PATCH 2/3] printk: Make the printk*once() variants return a value
Date: Fri, 24 Jun 2016 06:43:04 -0700 [thread overview]
Message-ID: <1466775784.1847.60.camel@perches.com> (raw)
In-Reply-To: <20160624083020.26871-3-bp@alien8.de>
On Fri, 2016-06-24 at 10:30 +0200, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
>
> Have printk*once() return a bool which denotes whether the string was
> printed or not so that calling code can react accordingly.
I expected object size to either increase or stay the
same with just this change.
Oddly, at least with gcc 5.3, some defconfig x86-64
objects _decrease_ in size.
for example: drivers/gpu/drm/i915/intel_opregion.o
I presume there's some curiosity in the gcc optimizer
with the evaluation of statement expression macros that
don't return a value.
Perhaps the printk_once macros should end with
unlikely(__ret_print_once);
like the WARN_ONCE variants.
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
> include/linux/printk.h | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index f4da695fd615..464fcdddb359 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -108,11 +108,14 @@ struct va_format {
> * Dummy printk for disabled debugging statements to use whilst maintaining
> * gcc's format checking.
> */
> -#define no_printk(fmt, ...) \
> -do { \
> - if (0) \
> - printk(fmt, ##__VA_ARGS__); \
> -} while (0)
> +#define no_printk(fmt, ...) \
> +({ \
> + do { \
> + if (0) \
> + printk(fmt, ##__VA_ARGS__); \
> + } while (0); \
> + 0; \
> +})
>
> #ifdef CONFIG_EARLY_PRINTK
> extern asmlinkage __printf(1, 2)
> @@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold;
> #define printk_once(fmt, ...) \
> ({ \
> static bool __print_once __read_mostly; \
> + bool __ret_print_once = !__print_once; \
> \
> if (!__print_once) { \
> __print_once = true; \
> printk(fmt, ##__VA_ARGS__); \
> } \
> + __ret_print_once; \
> })
> #define printk_deferred_once(fmt, ...) \
> ({ \
> static bool __print_once __read_mostly; \
> + bool __ret_print_once = !__print_once; \
> \
> if (!__print_once) { \
> __print_once = true; \
> printk_deferred(fmt, ##__VA_ARGS__); \
> } \
> + __ret_print_once; \
> })
> #else
> #define printk_once(fmt, ...) \
next prev parent reply other threads:[~2016-06-24 13:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 8:30 [PATCH 0/3] x86/MSR: Improve unhandled MSR access error message Borislav Petkov
2016-06-24 8:30 ` [PATCH 1/3] x86/dumpstack: Honor supplied @regs arg Borislav Petkov
2016-06-24 8:30 ` [PATCH 2/3] printk: Make the printk*once() variants return a value Borislav Petkov
2016-06-24 13:43 ` Joe Perches [this message]
2016-06-25 11:01 ` Borislav Petkov
2016-06-27 9:15 ` [PATCH -v2 " Borislav Petkov
2016-06-24 8:30 ` [PATCH 3/3] x86/dumpstack: Add show_stack_regs() and use it Borislav Petkov
2016-06-25 20:54 ` Andy Lutomirski
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=1466775784.1847.60.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).