All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] static_key: Improve uninizialized key warning
@ 2017-10-18 10:39 Borislav Petkov
  2017-10-18 11:15 ` Steven Rostedt
  2017-10-18 13:19 ` Ingo Molnar
  0 siblings, 2 replies; 9+ messages in thread
From: Borislav Petkov @ 2017-10-18 10:39 UTC (permalink / raw)
  To: LKML
  Cc: Hannes Frederic Sowa, Ingo Molnar, Juergen Gross,
	Steven Rostedt (VMware), Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

From: Borislav Petkov <bp@suse.de>

Right now it says:

  static_key_disable_cpuslocked used before call to jump_label_init
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:161 static_key_disable_cpuslocked+0x68/0x70
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-rc5+ #1
  Hardware name: SGI.COM C2112-4GP3/X10DRT-P-Series, BIOS 2.0a 05/09/2016
  task: ffffffff81c0e480 task.stack: ffffffff81c00000
  RIP: 0010:static_key_disable_cpuslocked+0x68/0x70
  RSP: 0000:ffffffff81c03ef0 EFLAGS: 00010096 ORIG_RAX: 0000000000000000
  RAX: 0000000000000041 RBX: ffffffff81c32680 RCX: ffffffff81c5cbf8
  RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000002
  RBP: ffff88807fffd240 R08: 726f666562206465 R09: 0000000000000136
  R10: 0000000000000000 R11: 696e695f6c656261 R12: ffffffff82158900
  R13: ffffffff8215f760 R14: 0000000000000001 R15: 0000000000000008
  FS:  0000000000000000(0000) GS:ffff883f7f400000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffff88807ffff000 CR3: 0000000001c09000 CR4: 00000000000606b0
  Call Trace:
   static_key_disable+0x16/0x20
   start_kernel+0x15a/0x45d
   ? load_ucode_intel_bsp+0x11/0x2d
   secondary_startup_64+0xa5/0xb0
  Code: 48 c7 c7 a0 15 cf 81 e9 47 53 4b 00 48 89 df e8 5f fc ff ff eb e8 48 c7 c6 \
	c0 97 83 81 48 c7 c7 d0 ff a2 81 31 c0 e8 c5 9d f5 ff <0f> ff eb a7 0f ff eb \
	b0 e8 eb a2 4b 00 53 48 89 fb e8 42 0e f0

but it doesn't tell me which key it is. So dump its address too:

  static_key_disable_cpuslocked, key ffffffff81c32680 used before call to jump_label_init

so that it can be found:

  $ objdump -D vmlinux | grep ffffffff81c32680
  ffffffff81c32680 <virt_spin_lock_key>:
  ffffffff81c32680:       01 00                   add    %eax,(%rax)

The problem is then obvious:

  smp_prepare_boot_cpu() ->
  native_smp_prepare_boot_cpu()->
  native_pv_lock_init()

which disables that key gets called before jump_label_init().

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Jason Baron <jbaron@akamai.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/jump_label.h           | 14 +++++++-------
 include/linux/jump_label_ratelimit.h |  6 +++---
 kernel/jump_label.c                  | 14 +++++++-------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index cd5861651b17..2c070eeaf1f6 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -81,9 +81,9 @@
 
 extern bool static_key_initialized;
 
-#define STATIC_KEY_CHECK_USE() WARN(!static_key_initialized,		      \
-				    "%s used before call to jump_label_init", \
-				    __func__)
+#define STATIC_KEY_CHECK_USE(key) WARN(!static_key_initialized,		      \
+				    "%s, key %p used before call to jump_label_init", \
+				    __func__, (key))
 
 #ifdef HAVE_JUMP_LABEL
 
@@ -211,13 +211,13 @@ static __always_inline bool static_key_true(struct static_key *key)
 
 static inline void static_key_slow_inc(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_inc(&key->enabled);
 }
 
 static inline void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_dec(&key->enabled);
 }
 
@@ -236,7 +236,7 @@ static inline int jump_label_apply_nops(struct module *mod)
 
 static inline void static_key_enable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -247,7 +247,7 @@ static inline void static_key_enable(struct static_key *key)
 
 static inline void static_key_disable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
index 23da3af459fe..93086df0a847 100644
--- a/include/linux/jump_label_ratelimit.h
+++ b/include/linux/jump_label_ratelimit.h
@@ -24,18 +24,18 @@ struct static_key_deferred {
 };
 static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	static_key_slow_dec(&key->key);
 }
 static inline void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 static inline void
 jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 #endif	/* HAVE_JUMP_LABEL */
 #endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 0bf2e8f5244a..8ff4ca4665ff 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -83,7 +83,7 @@ static void static_key_slow_inc_cpuslocked(struct static_key *key)
 {
 	int v, v1;
 
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	/*
 	 * Careful if we get concurrent static_key_slow_inc() calls;
@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc);
 
 void static_key_enable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) > 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(static_key_enable);
 
 void static_key_disable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
@@ -224,21 +224,21 @@ static void jump_label_update_timeout(struct work_struct *work)
 
 void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(key, 0, NULL);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec);
 
 void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(&key->key, key->timeout, &key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
 
 void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	flush_delayed_work(&key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_deferred_flush);
@@ -246,7 +246,7 @@ EXPORT_SYMBOL_GPL(static_key_deferred_flush);
 void jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	key->timeout = rl;
 	INIT_DELAYED_WORK(&key->work, jump_label_update_timeout);
 }
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] static_key: Improve uninizialized key warning
  2017-10-18 10:39 [PATCH] static_key: Improve uninizialized key warning Borislav Petkov
@ 2017-10-18 11:15 ` Steven Rostedt
  2017-10-18 13:19 ` Ingo Molnar
  1 sibling, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2017-10-18 11:15 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Hannes Frederic Sowa, Ingo Molnar, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

On Wed, 18 Oct 2017 12:39:13 +0200
Borislav Petkov <bp@alien8.de> wrote:

> From: Borislav Petkov <bp@suse.de>
> 
> Right now it says:
> 
>   static_key_disable_cpuslocked used before call to jump_label_init
>   ------------[ cut here ]------------
>   WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:161 static_key_disable_cpuslocked+0x68/0x70
>   Modules linked in:
>   CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-rc5+ #1
>   Hardware name: SGI.COM C2112-4GP3/X10DRT-P-Series, BIOS 2.0a 05/09/2016
>   task: ffffffff81c0e480 task.stack: ffffffff81c00000
>   RIP: 0010:static_key_disable_cpuslocked+0x68/0x70
>   RSP: 0000:ffffffff81c03ef0 EFLAGS: 00010096 ORIG_RAX: 0000000000000000
>   RAX: 0000000000000041 RBX: ffffffff81c32680 RCX: ffffffff81c5cbf8
>   RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000002
>   RBP: ffff88807fffd240 R08: 726f666562206465 R09: 0000000000000136
>   R10: 0000000000000000 R11: 696e695f6c656261 R12: ffffffff82158900
>   R13: ffffffff8215f760 R14: 0000000000000001 R15: 0000000000000008
>   FS:  0000000000000000(0000) GS:ffff883f7f400000(0000) knlGS:0000000000000000
>   CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>   CR2: ffff88807ffff000 CR3: 0000000001c09000 CR4: 00000000000606b0
>   Call Trace:
>    static_key_disable+0x16/0x20
>    start_kernel+0x15a/0x45d
>    ? load_ucode_intel_bsp+0x11/0x2d
>    secondary_startup_64+0xa5/0xb0
>   Code: 48 c7 c7 a0 15 cf 81 e9 47 53 4b 00 48 89 df e8 5f fc ff ff eb e8 48 c7 c6 \
> 	c0 97 83 81 48 c7 c7 d0 ff a2 81 31 c0 e8 c5 9d f5 ff <0f> ff eb a7 0f ff eb \
> 	b0 e8 eb a2 4b 00 53 48 89 fb e8 42 0e f0
> 
> but it doesn't tell me which key it is. So dump its address too:
> 
>   static_key_disable_cpuslocked, key ffffffff81c32680 used before call to jump_label_init
> 
> so that it can be found:
> 
>   $ objdump -D vmlinux | grep ffffffff81c32680
>   ffffffff81c32680 <virt_spin_lock_key>:
>   ffffffff81c32680:       01 00                   add    %eax,(%rax)
> 
> The problem is then obvious:
> 
>   smp_prepare_boot_cpu() ->
>   native_smp_prepare_boot_cpu()->
>   native_pv_lock_init()
> 
> which disables that key gets called before jump_label_init().
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
>


Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] static_key: Improve uninizialized key warning
  2017-10-18 10:39 [PATCH] static_key: Improve uninizialized key warning Borislav Petkov
  2017-10-18 11:15 ` Steven Rostedt
@ 2017-10-18 13:19 ` Ingo Molnar
  2017-10-18 13:27   ` Steven Rostedt
  1 sibling, 1 reply; 9+ messages in thread
From: Ingo Molnar @ 2017-10-18 13:19 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: LKML, Hannes Frederic Sowa, Juergen Gross,
	Steven Rostedt (VMware), Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner


* Borislav Petkov <bp@alien8.de> wrote:

> but it doesn't tell me which key it is. So dump its address too:
> 
>   static_key_disable_cpuslocked, key ffffffff81c32680 used before call to jump_label_init

Is it possible to print out a symbol instead of an absolute address - does that 
work for data symbols?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] static_key: Improve uninizialized key warning
  2017-10-18 13:19 ` Ingo Molnar
@ 2017-10-18 13:27   ` Steven Rostedt
  2017-10-18 15:24     ` [PATCH v2] " Borislav Petkov
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2017-10-18 13:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Borislav Petkov, LKML, Hannes Frederic Sowa, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

On Wed, 18 Oct 2017 15:19:34 +0200
Ingo Molnar <mingo@kernel.org> wrote:

> * Borislav Petkov <bp@alien8.de> wrote:
> 
> > but it doesn't tell me which key it is. So dump its address too:
> > 
> >   static_key_disable_cpuslocked, key ffffffff81c32680 used before call to jump_label_init  
> 
> Is it possible to print out a symbol instead of an absolute address - does that 
> work for data symbols?

It should.

Boris, can you try it with "%pS" ?

-- Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] static_key: Improve uninizialized key warning
  2017-10-18 13:27   ` Steven Rostedt
@ 2017-10-18 15:24     ` Borislav Petkov
  2017-10-18 16:06       ` Steven Rostedt
  2017-10-19  5:52       ` [tip:locking/core] locking/static_keys: Improve uninitialized " tip-bot for Borislav Petkov
  0 siblings, 2 replies; 9+ messages in thread
From: Borislav Petkov @ 2017-10-18 15:24 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, LKML, Hannes Frederic Sowa, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

On Wed, Oct 18, 2017 at 09:27:10AM -0400, Steven Rostedt wrote:
> Boris, can you try it with "%pS" ?

%ps is better, as it doesn't dump offsets:

[    0.000000] static_key_disable_cpuslocked, key virt_spin_lock_key used before call to jump_label_init

Thx.

---
From: Borislav Petkov <bp@suse.de>

Right now it says:

  static_key_disable_cpuslocked used before call to jump_label_init
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:161 static_key_disable_cpuslocked+0x68/0x70
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-rc5+ #1
  Hardware name: SGI.COM C2112-4GP3/X10DRT-P-Series, BIOS 2.0a 05/09/2016
  task: ffffffff81c0e480 task.stack: ffffffff81c00000
  RIP: 0010:static_key_disable_cpuslocked+0x68/0x70
  RSP: 0000:ffffffff81c03ef0 EFLAGS: 00010096 ORIG_RAX: 0000000000000000
  RAX: 0000000000000041 RBX: ffffffff81c32680 RCX: ffffffff81c5cbf8
  RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000002
  RBP: ffff88807fffd240 R08: 726f666562206465 R09: 0000000000000136
  R10: 0000000000000000 R11: 696e695f6c656261 R12: ffffffff82158900
  R13: ffffffff8215f760 R14: 0000000000000001 R15: 0000000000000008
  FS:  0000000000000000(0000) GS:ffff883f7f400000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffff88807ffff000 CR3: 0000000001c09000 CR4: 00000000000606b0
  Call Trace:
   static_key_disable+0x16/0x20
   start_kernel+0x15a/0x45d
   ? load_ucode_intel_bsp+0x11/0x2d
   secondary_startup_64+0xa5/0xb0
  Code: 48 c7 c7 a0 15 cf 81 e9 47 53 4b 00 48 89 df e8 5f fc ff ff eb e8 48 c7 c6 \
	c0 97 83 81 48 c7 c7 d0 ff a2 81 31 c0 e8 c5 9d f5 ff <0f> ff eb a7 0f ff eb \
	b0 e8 eb a2 4b 00 53 48 89 fb e8 42 0e f0

but it doesn't tell me which key it is. So dump the key's name too:

  static_key_disable_cpuslocked, key virt_spin_lock_key used before call to jump_label_init.

And that makes pinpointing which key is causing that, a lot easier.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Jason Baron <jbaron@akamai.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/jump_label.h           | 14 +++++++-------
 include/linux/jump_label_ratelimit.h |  6 +++---
 kernel/jump_label.c                  | 14 +++++++-------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index cd5861651b17..dc126d10a00d 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -81,9 +81,9 @@
 
 extern bool static_key_initialized;
 
-#define STATIC_KEY_CHECK_USE() WARN(!static_key_initialized,		      \
-				    "%s used before call to jump_label_init", \
-				    __func__)
+#define STATIC_KEY_CHECK_USE(key) WARN(!static_key_initialized,		      \
+				    "%s, key %ps used before call to jump_label_init", \
+				    __func__, (key))
 
 #ifdef HAVE_JUMP_LABEL
 
@@ -211,13 +211,13 @@ static __always_inline bool static_key_true(struct static_key *key)
 
 static inline void static_key_slow_inc(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_inc(&key->enabled);
 }
 
 static inline void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_dec(&key->enabled);
 }
 
@@ -236,7 +236,7 @@ static inline int jump_label_apply_nops(struct module *mod)
 
 static inline void static_key_enable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -247,7 +247,7 @@ static inline void static_key_enable(struct static_key *key)
 
 static inline void static_key_disable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
index 23da3af459fe..93086df0a847 100644
--- a/include/linux/jump_label_ratelimit.h
+++ b/include/linux/jump_label_ratelimit.h
@@ -24,18 +24,18 @@ struct static_key_deferred {
 };
 static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	static_key_slow_dec(&key->key);
 }
 static inline void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 static inline void
 jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 #endif	/* HAVE_JUMP_LABEL */
 #endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 0bf2e8f5244a..8ff4ca4665ff 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -83,7 +83,7 @@ static void static_key_slow_inc_cpuslocked(struct static_key *key)
 {
 	int v, v1;
 
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	/*
 	 * Careful if we get concurrent static_key_slow_inc() calls;
@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc);
 
 void static_key_enable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) > 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(static_key_enable);
 
 void static_key_disable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
@@ -224,21 +224,21 @@ static void jump_label_update_timeout(struct work_struct *work)
 
 void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(key, 0, NULL);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec);
 
 void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(&key->key, key->timeout, &key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
 
 void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	flush_delayed_work(&key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_deferred_flush);
@@ -246,7 +246,7 @@ EXPORT_SYMBOL_GPL(static_key_deferred_flush);
 void jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	key->timeout = rl;
 	INIT_DELAYED_WORK(&key->work, jump_label_update_timeout);
 }
-- 
2.13.0

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] static_key: Improve uninizialized key warning
  2017-10-18 15:24     ` [PATCH v2] " Borislav Petkov
@ 2017-10-18 16:06       ` Steven Rostedt
  2017-10-18 16:08         ` Steven Rostedt
  2017-10-19  5:52       ` [tip:locking/core] locking/static_keys: Improve uninitialized " tip-bot for Borislav Petkov
  1 sibling, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2017-10-18 16:06 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Ingo Molnar, LKML, Hannes Frederic Sowa, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

On Wed, 18 Oct 2017 17:24:28 +0200
Borislav Petkov <bp@alien8.de> wrote:

> On Wed, Oct 18, 2017 at 09:27:10AM -0400, Steven Rostedt wrote:
> > Boris, can you try it with "%pS" ?  
> 
> %ps is better, as it doesn't dump offsets:

Sometimes offsets are helpful even for variables.

But regardless...

> 
> [    0.000000] static_key_disable_cpuslocked, key virt_spin_lock_key used before call to jump_label_init
> 
> Thx.
> 
> ---
> From: Borislav Petkov <bp@suse.de>
> 
> Right now it says:
> 
>   static_key_disable_cpuslocked used before call to jump_label_init
>   ------------[ cut here ]------------
>   WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:161 static_key_disable_cpuslocked+0x68/0x70
>   Modules linked in:
>   CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-rc5+ #1
>   Hardware name: SGI.COM C2112-4GP3/X10DRT-P-Series, BIOS 2.0a 05/09/2016
>   task: ffffffff81c0e480 task.stack: ffffffff81c00000
>   RIP: 0010:static_key_disable_cpuslocked+0x68/0x70
>   RSP: 0000:ffffffff81c03ef0 EFLAGS: 00010096 ORIG_RAX: 0000000000000000
>   RAX: 0000000000000041 RBX: ffffffff81c32680 RCX: ffffffff81c5cbf8
>   RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000002
>   RBP: ffff88807fffd240 R08: 726f666562206465 R09: 0000000000000136
>   R10: 0000000000000000 R11: 696e695f6c656261 R12: ffffffff82158900
>   R13: ffffffff8215f760 R14: 0000000000000001 R15: 0000000000000008
>   FS:  0000000000000000(0000) GS:ffff883f7f400000(0000) knlGS:0000000000000000
>   CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>   CR2: ffff88807ffff000 CR3: 0000000001c09000 CR4: 00000000000606b0
>   Call Trace:
>    static_key_disable+0x16/0x20
>    start_kernel+0x15a/0x45d
>    ? load_ucode_intel_bsp+0x11/0x2d
>    secondary_startup_64+0xa5/0xb0
>   Code: 48 c7 c7 a0 15 cf 81 e9 47 53 4b 00 48 89 df e8 5f fc ff ff eb e8 48 c7 c6 \
> 	c0 97 83 81 48 c7 c7 d0 ff a2 81 31 c0 e8 c5 9d f5 ff <0f> ff eb a7 0f ff eb \
> 	b0 e8 eb a2 4b 00 53 48 89 fb e8 42 0e f0
> 
> but it doesn't tell me which key it is. So dump the key's name too:
> 
>   static_key_disable_cpuslocked, key virt_spin_lock_key used before call to jump_label_init.
> 
> And that makes pinpointing which key is causing that, a lot easier.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> Cc: Jason Baron <jbaron@akamai.com>
> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
>  include/linux/jump_label.h           | 14 +++++++-------
>  include/linux/jump_label_ratelimit.h |  6 +++---
>  kernel/jump_label.c                  | 14 +++++++-------
>  3 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> index cd5861651b17..dc126d10a00d 100644
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -81,9 +81,9 @@
>  
>  extern bool static_key_initialized;
>  
> -#define STATIC_KEY_CHECK_USE() WARN(!static_key_initialized,		      \
> -				    "%s used before call to jump_label_init", \
> -				    __func__)
> +#define STATIC_KEY_CHECK_USE(key) WARN(!static_key_initialized,		      \
> +				    "%s, key %ps used before call to jump_label_init", \
> +				    __func__, (key))
>  
>  #ifdef HAVE_JUMP_LABEL
>  
> @@ -211,13 +211,13 @@ static __always_inline bool static_key_true(struct static_key *key)
>  
>  static inline void static_key_slow_inc(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	atomic_inc(&key->enabled);
>  }
>  
>  static inline void static_key_slow_dec(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	atomic_dec(&key->enabled);
>  }
>  
> @@ -236,7 +236,7 @@ static inline int jump_label_apply_nops(struct module *mod)
>  
>  static inline void static_key_enable(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  
>  	if (atomic_read(&key->enabled) != 0) {
>  		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
> @@ -247,7 +247,7 @@ static inline void static_key_enable(struct static_key *key)
>  
>  static inline void static_key_disable(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  
>  	if (atomic_read(&key->enabled) != 1) {
>  		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
> diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
> index 23da3af459fe..93086df0a847 100644
> --- a/include/linux/jump_label_ratelimit.h
> +++ b/include/linux/jump_label_ratelimit.h
> @@ -24,18 +24,18 @@ struct static_key_deferred {
>  };
>  static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	static_key_slow_dec(&key->key);
>  }
>  static inline void static_key_deferred_flush(struct static_key_deferred *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  }
>  static inline void
>  jump_label_rate_limit(struct static_key_deferred *key,
>  		unsigned long rl)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  }
>  #endif	/* HAVE_JUMP_LABEL */
>  #endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index 0bf2e8f5244a..8ff4ca4665ff 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -83,7 +83,7 @@ static void static_key_slow_inc_cpuslocked(struct static_key *key)
>  {
>  	int v, v1;
>  
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  
>  	/*
>  	 * Careful if we get concurrent static_key_slow_inc() calls;
> @@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc);
>  
>  void static_key_enable_cpuslocked(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  
>  	if (atomic_read(&key->enabled) > 0) {
>  		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
> @@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(static_key_enable);
>  
>  void static_key_disable_cpuslocked(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  
>  	if (atomic_read(&key->enabled) != 1) {
>  		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
> @@ -224,21 +224,21 @@ static void jump_label_update_timeout(struct work_struct *work)
>  
>  void static_key_slow_dec(struct static_key *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	__static_key_slow_dec(key, 0, NULL);
>  }
>  EXPORT_SYMBOL_GPL(static_key_slow_dec);
>  
>  void static_key_slow_dec_deferred(struct static_key_deferred *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	__static_key_slow_dec(&key->key, key->timeout, &key->work);
>  }
>  EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
>  
>  void static_key_deferred_flush(struct static_key_deferred *key)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	flush_delayed_work(&key->work);
>  }
>  EXPORT_SYMBOL_GPL(static_key_deferred_flush);
> @@ -246,7 +246,7 @@ EXPORT_SYMBOL_GPL(static_key_deferred_flush);
>  void jump_label_rate_limit(struct static_key_deferred *key,
>  		unsigned long rl)
>  {
> -	STATIC_KEY_CHECK_USE();
> +	STATIC_KEY_CHECK_USE(key);
>  	key->timeout = rl;
>  	INIT_DELAYED_WORK(&key->work, jump_label_update_timeout);
>  }

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] static_key: Improve uninizialized key warning
  2017-10-18 16:06       ` Steven Rostedt
@ 2017-10-18 16:08         ` Steven Rostedt
  2017-10-19  5:33           ` Ingo Molnar
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2017-10-18 16:08 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Ingo Molnar, LKML, Hannes Frederic Sowa, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner

On Wed, 18 Oct 2017 12:06:59 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> > Signed-off-by: Borislav Petkov <bp@suse.de>
> > Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Juergen Gross <jgross@suse.com>
> > Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>  
> 
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 


Ingo, you may want to fix the typo in the subject "uninitialized".

-- Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] static_key: Improve uninizialized key warning
  2017-10-18 16:08         ` Steven Rostedt
@ 2017-10-19  5:33           ` Ingo Molnar
  0 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2017-10-19  5:33 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Borislav Petkov, LKML, Hannes Frederic Sowa, Juergen Gross,
	Jason Baron, Peter Zijlstra (Intel),
	Boris Ostrovsky, Paolo Bonzini, Thomas Gleixner


* Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 18 Oct 2017 12:06:59 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > > Signed-off-by: Borislav Petkov <bp@suse.de>
> > > Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > > Cc: Ingo Molnar <mingo@kernel.org>
> > > Cc: Juergen Gross <jgross@suse.com>
> > > Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>  
> > 
> > Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > 
> 
> 
> Ingo, you may want to fix the typo in the subject "uninitialized".

Yeah, I also changed it to %pS to help debug arrays, or cases where somehow a 
non-data symbol ends up being passed to it. Plus I changed the message from:

  static_key_disable_cpuslocked, key virt_spin_lock_key used before call to jump_label_init.

to:

  static_key_disable_cpuslocked() static key 'virt_spin_lock_key' used before call to jump_label_init()

to make it all obviously readable. I mean, what if the symbol is named 'key' and 
we'd get confusing printouts like:

  static_key_disable_cpuslocked, key key used before call to jump_label_init.

Plus functions should be referred to with () to disambiguate them from other 
symbol names. Also, proper use of punctuation symbols.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [tip:locking/core] locking/static_keys: Improve uninitialized key warning
  2017-10-18 15:24     ` [PATCH v2] " Borislav Petkov
  2017-10-18 16:06       ` Steven Rostedt
@ 2017-10-19  5:52       ` tip-bot for Borislav Petkov
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Borislav Petkov @ 2017-10-19  5:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, boris.ostrovsky, pbonzini, jbaron, jgross,
	rostedt, hannes, torvalds, linux-kernel, bp, tglx, hpa

Commit-ID:  5cdda5117e125e0dbb020425cc55a4c143c6febc
Gitweb:     https://git.kernel.org/tip/5cdda5117e125e0dbb020425cc55a4c143c6febc
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Wed, 18 Oct 2017 17:24:28 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 19 Oct 2017 07:49:14 +0200

locking/static_keys: Improve uninitialized key warning

Right now it says:

  static_key_disable_cpuslocked used before call to jump_label_init
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:161 static_key_disable_cpuslocked+0x68/0x70
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-rc5+ #1
  Hardware name: SGI.COM C2112-4GP3/X10DRT-P-Series, BIOS 2.0a 05/09/2016
  task: ffffffff81c0e480 task.stack: ffffffff81c00000
  RIP: 0010:static_key_disable_cpuslocked+0x68/0x70
  RSP: 0000:ffffffff81c03ef0 EFLAGS: 00010096 ORIG_RAX: 0000000000000000
  RAX: 0000000000000041 RBX: ffffffff81c32680 RCX: ffffffff81c5cbf8
  RDX: 0000000000000001 RSI: 0000000000000092 RDI: 0000000000000002
  RBP: ffff88807fffd240 R08: 726f666562206465 R09: 0000000000000136
  R10: 0000000000000000 R11: 696e695f6c656261 R12: ffffffff82158900
  R13: ffffffff8215f760 R14: 0000000000000001 R15: 0000000000000008
  FS:  0000000000000000(0000) GS:ffff883f7f400000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffff88807ffff000 CR3: 0000000001c09000 CR4: 00000000000606b0
  Call Trace:
   static_key_disable+0x16/0x20
   start_kernel+0x15a/0x45d
   ? load_ucode_intel_bsp+0x11/0x2d
   secondary_startup_64+0xa5/0xb0
  Code: 48 c7 c7 a0 15 cf 81 e9 47 53 4b 00 48 89 df e8 5f fc ff ff eb e8 48 c7 c6 \
	c0 97 83 81 48 c7 c7 d0 ff a2 81 31 c0 e8 c5 9d f5 ff <0f> ff eb a7 0f ff eb \
	b0 e8 eb a2 4b 00 53 48 89 fb e8 42 0e f0

but it doesn't tell me which key it is. So dump the key's name too:

  static_key_disable_cpuslocked(): static key 'virt_spin_lock_key' used before call to jump_label_init()

And that makes pinpointing which key is causing that a lot easier.

 include/linux/jump_label.h           |   14 +++++++-------
 include/linux/jump_label_ratelimit.h |    6 +++---
 kernel/jump_label.c                  |   14 +++++++-------
 3 files changed, 17 insertions(+), 17 deletions(-)

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20171018152428.ffjgak4o25f7ept6@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/jump_label.h           | 14 +++++++-------
 include/linux/jump_label_ratelimit.h |  6 +++---
 kernel/jump_label.c                  | 14 +++++++-------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index cd58616..979a2f2 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -81,9 +81,9 @@
 
 extern bool static_key_initialized;
 
-#define STATIC_KEY_CHECK_USE() WARN(!static_key_initialized,		      \
-				    "%s used before call to jump_label_init", \
-				    __func__)
+#define STATIC_KEY_CHECK_USE(key) WARN(!static_key_initialized,		      \
+				    "%s(): static key '%pS' used before call to jump_label_init()", \
+				    __func__, (key))
 
 #ifdef HAVE_JUMP_LABEL
 
@@ -211,13 +211,13 @@ static __always_inline bool static_key_true(struct static_key *key)
 
 static inline void static_key_slow_inc(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_inc(&key->enabled);
 }
 
 static inline void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	atomic_dec(&key->enabled);
 }
 
@@ -236,7 +236,7 @@ static inline int jump_label_apply_nops(struct module *mod)
 
 static inline void static_key_enable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -247,7 +247,7 @@ static inline void static_key_enable(struct static_key *key)
 
 static inline void static_key_disable(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
index 23da3af..93086df 100644
--- a/include/linux/jump_label_ratelimit.h
+++ b/include/linux/jump_label_ratelimit.h
@@ -24,18 +24,18 @@ struct static_key_deferred {
 };
 static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	static_key_slow_dec(&key->key);
 }
 static inline void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 static inline void
 jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 }
 #endif	/* HAVE_JUMP_LABEL */
 #endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 0bf2e8f5..8ff4ca4 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -83,7 +83,7 @@ static void static_key_slow_inc_cpuslocked(struct static_key *key)
 {
 	int v, v1;
 
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	/*
 	 * Careful if we get concurrent static_key_slow_inc() calls;
@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc);
 
 void static_key_enable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) > 0) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 1);
@@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(static_key_enable);
 
 void static_key_disable_cpuslocked(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 
 	if (atomic_read(&key->enabled) != 1) {
 		WARN_ON_ONCE(atomic_read(&key->enabled) != 0);
@@ -224,21 +224,21 @@ static void jump_label_update_timeout(struct work_struct *work)
 
 void static_key_slow_dec(struct static_key *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(key, 0, NULL);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec);
 
 void static_key_slow_dec_deferred(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec(&key->key, key->timeout, &key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_slow_dec_deferred);
 
 void static_key_deferred_flush(struct static_key_deferred *key)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	flush_delayed_work(&key->work);
 }
 EXPORT_SYMBOL_GPL(static_key_deferred_flush);
@@ -246,7 +246,7 @@ EXPORT_SYMBOL_GPL(static_key_deferred_flush);
 void jump_label_rate_limit(struct static_key_deferred *key,
 		unsigned long rl)
 {
-	STATIC_KEY_CHECK_USE();
+	STATIC_KEY_CHECK_USE(key);
 	key->timeout = rl;
 	INIT_DELAYED_WORK(&key->work, jump_label_update_timeout);
 }

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-19  5:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-18 10:39 [PATCH] static_key: Improve uninizialized key warning Borislav Petkov
2017-10-18 11:15 ` Steven Rostedt
2017-10-18 13:19 ` Ingo Molnar
2017-10-18 13:27   ` Steven Rostedt
2017-10-18 15:24     ` [PATCH v2] " Borislav Petkov
2017-10-18 16:06       ` Steven Rostedt
2017-10-18 16:08         ` Steven Rostedt
2017-10-19  5:33           ` Ingo Molnar
2017-10-19  5:52       ` [tip:locking/core] locking/static_keys: Improve uninitialized " tip-bot for Borislav Petkov

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.