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


Groups > linux.kernel > #1436625 > unrolled thread

[PATCH -v2 2/3] printk: Make the printk*once() variants return a value

Started byBorislav Petkov <bp@alien8.de>
First post2016-07-05 00:40 +0200
Last post2016-07-10 14:40 +0200
Articles 9 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH -v2 2/3] printk: Make the printk*once() variants return a value Borislav Petkov <bp@alien8.de> - 2016-07-05 00:40 +0200
    [tip:x86/debug] printk: Make the printk*once() variants return a  value tip-bot for Borislav Petkov <tipbot@zytor.com> - 2016-07-08 14:10 +0200
      Re: [tip:x86/debug] printk: Make the printk*once() variants return  a value Joe Perches <joe@perches.com> - 2016-07-09 04:50 +0200
        Re: [tip:x86/debug] printk: Make the printk*once() variants return a  value Borislav Petkov <bp@alien8.de> - 2016-07-09 10:00 +0200
          Re: [tip:x86/debug] printk: Make the printk*once() variants return  a value Joe Perches <joe@perches.com> - 2016-07-09 20:00 +0200
            Re: [tip:x86/debug] printk: Make the printk*once() variants return a  value Borislav Petkov <bp@alien8.de> - 2016-07-10 09:00 +0200
              Re: [tip:x86/debug] printk: Make the printk*once() variants return  a value Joe Perches <joe@perches.com> - 2016-07-10 10:30 +0200
                Re: [tip:x86/debug] printk: Make the printk*once() variants return a  value Borislav Petkov <bp@alien8.de> - 2016-07-10 14:10 +0200
                  Re: [tip:x86/debug] printk: Make the printk*once() variants return  a value Joe Perches <joe@perches.com> - 2016-07-10 14:40 +0200

#1436625 — [PATCH -v2 2/3] printk: Make the printk*once() variants return a value

FromBorislav Petkov <bp@alien8.de>
Date2016-07-05 00:40 +0200
Subject[PATCH -v2 2/3] printk: Make the printk*once() variants return a value
Message-ID<rRkGZ-2Z3-3@gated-at.bofh.it>
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.

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..f136b22c7772 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__);			\
 	}							\
+	unlikely(__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__);		\
 	}							\
+	unlikely(__ret_print_once);				\
 })
 #else
 #define printk_once(fmt, ...)					\
-- 
2.7.3

[toc] | [next] | [standalone]


#1439377 — [tip:x86/debug] printk: Make the printk*once() variants return a value

Fromtip-bot for Borislav Petkov <tipbot@zytor.com>
Date2016-07-08 14:10 +0200
Subject[tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rSCLw-4Br-57@gated-at.bofh.it>
In reply to#1436625
Commit-ID:  069f0cd00df0abfb9252e0dbdc355e40e6ab75fc
Gitweb:     http://git.kernel.org/tip/069f0cd00df0abfb9252e0dbdc355e40e6ab75fc
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Tue, 5 Jul 2016 00:31:26 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 8 Jul 2016 11:33:18 +0200

printk: Make the printk*once() variants return a value

Have printk*once() return a bool which denotes whether the string was
printed or not so that calling code can react accordingly.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1467671487-10344-3-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.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 f4da695..f136b22 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__);			\
 	}							\
+	unlikely(__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__);		\
 	}							\
+	unlikely(__ret_print_once);				\
 })
 #else
 #define printk_once(fmt, ...)					\

[toc] | [prev] | [next] | [standalone]


#1439877 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromJoe Perches <joe@perches.com>
Date2016-07-09 04:50 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rSQv7-5aV-3@gated-at.bofh.it>
In reply to#1439377
On Fri, 2016-07-08 at 05:08 -0700, tip-bot for Borislav Petkov wrote:
> printk: Make the printk*once() variants return a value
[]
> diff --git 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;						\
> +})

This change isn't described in the commit message and there
doesn't seem to be a need to change this.

And as statement expressions these no longer need
"do { <foo> } while (0)" this could have been be simplified to

#define no_printk(fmt, ...)
({
	if (0)
		printk(fmt, ##__VA_ARGS__);
})

[toc] | [prev] | [next] | [standalone]


#1439909 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromBorislav Petkov <bp@alien8.de>
Date2016-07-09 10:00 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rSVl7-8qY-11@gated-at.bofh.it>
In reply to#1439877
On Fri, Jul 08, 2016 at 07:40:48PM -0700, Joe Perches wrote:
> This change isn't described in the commit message and there
> doesn't seem to be a need to change this.

How do *you* know? Did *you* actually sit down and build a kernel with
your proposed change before sending a reply?

I'm pretty sure you didn't.

Well, there is a very good reason why I made that change but I'm not
going to tell you.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [next] | [standalone]


#1439974 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromJoe Perches <joe@perches.com>
Date2016-07-09 20:00 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rT4HM-65B-23@gated-at.bofh.it>
In reply to#1439909
On Sat, 2016-07-09 at 09:50 +0200, Borislav Petkov wrote:
> On Fri, Jul 08, 2016 at 07:40:48PM -0700, Joe Perches wrote:
> > This change isn't described in the commit message and there
> > doesn't seem to be a need to change this.
> How do *you* know? Did *you* actually sit down and build a kernel with
> your proposed change before sending a reply?
> I'm pretty sure you didn't.

defconfigs both with and without CONFIG_PRINTK build
properly with the proposed change to this specific patch.

> Well, there is a very good reason why I made that change but I'm not
> going to tell you.

Borislav, your delightful personality always impresses.
Never change.

If there is a specific reason you know why this 0; value
must be added to a do {} while (0) to statement expression
macro conversion, it'd be good to write that in the
commit message.  It'd also be good to remove the useless
"do {} while (0);" surrounding a single statement.

[toc] | [prev] | [next] | [standalone]


#1440038 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromBorislav Petkov <bp@alien8.de>
Date2016-07-10 09:00 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rTgSC-5ug-7@gated-at.bofh.it>
In reply to#1439974
On Sat, Jul 09, 2016 at 10:56:55AM -0700, Joe Perches wrote:
> defconfigs both with and without CONFIG_PRINTK build
> properly with the proposed change to this specific patch.

Did you try latest tip/master?

> Borislav, your delightful personality always impresses.
> Never change.

What goes around comes around.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

[toc] | [prev] | [next] | [standalone]


#1440050 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromJoe Perches <joe@perches.com>
Date2016-07-10 10:30 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rTihH-6xD-3@gated-at.bofh.it>
In reply to#1440038
On Sun, 2016-07-10 at 08:49 +0200, Borislav Petkov wrote:
> On Sat, Jul 09, 2016 at 10:56:55AM -0700, Joe Perches wrote:
> > 
> > defconfigs both with and without CONFIG_PRINTK build
> > properly with the proposed change to this specific patch.
> Did you try latest tip/master?

Assuming tip is included in linux-next as of july 8, yes.

http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=a379b037c5f3bcd0475ab2743b1f8a57fa970e22
[]
+tip		2c387f55aabaf88b6ee6857192a8f778bee05523

[toc] | [prev] | [next] | [standalone]


#1440089 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromBorislav Petkov <bp@alien8.de>
Date2016-07-10 14:10 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rTlIB-sV-13@gated-at.bofh.it>
In reply to#1440050
On Sun, Jul 10, 2016 at 01:23:51AM -0700, Joe Perches wrote:
> Assuming tip is included in linux-next as of july 8, yes.

Try one which has http://git.kernel.org/tip/81c2949f7fdcf8ff681326669afde24962232670

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

[toc] | [prev] | [next] | [standalone]


#1440098 — Re: [tip:x86/debug] printk: Make the printk*once() variants return a value

FromJoe Perches <joe@perches.com>
Date2016-07-10 14:40 +0200
SubjectRe: [tip:x86/debug] printk: Make the printk*once() variants return a value
Message-ID<rTmbD-EX-5@gated-at.bofh.it>
In reply to#1440089
On Sun, 2016-07-10 at 14:06 +0200, Borislav Petkov wrote:
> On Sun, Jul 10, 2016 at 01:23:51AM -0700, Joe Perches wrote:
> > 
> > Assuming tip is included in linux-next as of july 8, yes.
> Try one which has http://git.kernel.org/tip/81c2949f7fdcf8ff681326669a
> fde24962232670

That commit isn't in -next and this change to add a return
value to no_printk in _this_ patch is, as I wrote, not
required here.

It's fine that no_printk return a 0 value, but it should
be introduced in a separate patch that introduces that
requirement or at least mentioned in the changelog of
this patch _why_ it's it to be changed.  Otherwise, the
change just appears spurious.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web