All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] static_call: Fix unused variable warning
@ 2021-04-22  0:33 Guenter Roeck
  2021-04-22  0:41 ` Steven Rostedt
  0 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2021-04-22  0:33 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Josh Poimboeuf, Jason Baron, Steven Rostedt, Ard Biesheuvel,
	linux-kernel, Guenter Roeck

If CONFIG_MODULES=n, the following build warning is reported.

kernel/static_call.c: In function ‘__static_call_update’:
kernel/static_call.c:153:18: warning: unused variable ‘mod’

Mark the variable as __maybe_unused to fix the problem.

Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
Reported-by: Zach Reizner <zachr@google.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 kernel/static_call.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 2c5950b0b90e..8211a34251f8 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -150,7 +150,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
 	for (site_mod = &first; site_mod; site_mod = site_mod->next) {
 		bool init = system_state < SYSTEM_RUNNING;
-		struct module *mod = site_mod->mod;
+		struct module __maybe_unused *mod = site_mod->mod;
 
 		if (!site_mod->sites) {
 			/*
-- 
2.17.1


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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  0:33 [PATCH] static_call: Fix unused variable warning Guenter Roeck
@ 2021-04-22  0:41 ` Steven Rostedt
  2021-04-22  1:24   ` Guenter Roeck
  2021-04-22  7:20   ` Peter Zijlstra
  0 siblings, 2 replies; 11+ messages in thread
From: Steven Rostedt @ 2021-04-22  0:41 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel


Second patch with the exact same update. Perhaps we should take one
before we get more of them ;-)

https://lore.kernel.org/lkml/20210416194300.3952208-1-cmllamas@google.com/

-- Steve


On Wed, 21 Apr 2021 17:33:34 -0700
Guenter Roeck <linux@roeck-us.net> wrote:

> If CONFIG_MODULES=n, the following build warning is reported.
> 
> kernel/static_call.c: In function ‘__static_call_update’:
> kernel/static_call.c:153:18: warning: unused variable ‘mod’
> 
> Mark the variable as __maybe_unused to fix the problem.
> 
> Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
> Reported-by: Zach Reizner <zachr@google.com>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  kernel/static_call.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index 2c5950b0b90e..8211a34251f8 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -150,7 +150,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
>  
>  	for (site_mod = &first; site_mod; site_mod = site_mod->next) {
>  		bool init = system_state < SYSTEM_RUNNING;
> -		struct module *mod = site_mod->mod;
> +		struct module __maybe_unused *mod = site_mod->mod;
>  
>  		if (!site_mod->sites) {
>  			/*


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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  0:41 ` Steven Rostedt
@ 2021-04-22  1:24   ` Guenter Roeck
  2021-04-22  1:33     ` Steven Rostedt
  2021-04-22  7:20   ` Peter Zijlstra
  1 sibling, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2021-04-22  1:24 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On 4/21/21 5:41 PM, Steven Rostedt wrote:
> 
> Second patch with the exact same update. Perhaps we should take one
> before we get more of them ;-)
> 
> https://lore.kernel.org/lkml/20210416194300.3952208-1-cmllamas@google.com/
> 

Sorry, I missed the other one.

Guenter

> -- Steve
> 
> 
> On Wed, 21 Apr 2021 17:33:34 -0700
> Guenter Roeck <linux@roeck-us.net> wrote:
> 
>> If CONFIG_MODULES=n, the following build warning is reported.
>>
>> kernel/static_call.c: In function ‘__static_call_update’:
>> kernel/static_call.c:153:18: warning: unused variable ‘mod’
>>
>> Mark the variable as __maybe_unused to fix the problem.
>>
>> Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
>> Reported-by: Zach Reizner <zachr@google.com>
>> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>  kernel/static_call.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/static_call.c b/kernel/static_call.c
>> index 2c5950b0b90e..8211a34251f8 100644
>> --- a/kernel/static_call.c
>> +++ b/kernel/static_call.c
>> @@ -150,7 +150,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
>>  
>>  	for (site_mod = &first; site_mod; site_mod = site_mod->next) {
>>  		bool init = system_state < SYSTEM_RUNNING;
>> -		struct module *mod = site_mod->mod;
>> +		struct module __maybe_unused *mod = site_mod->mod;
>>  
>>  		if (!site_mod->sites) {
>>  			/*
> 


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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  1:24   ` Guenter Roeck
@ 2021-04-22  1:33     ` Steven Rostedt
  2021-04-22  1:45       ` Guenter Roeck
  0 siblings, 1 reply; 11+ messages in thread
From: Steven Rostedt @ 2021-04-22  1:33 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On Wed, 21 Apr 2021 18:24:15 -0700
Guenter Roeck <linux@roeck-us.net> wrote:

> On 4/21/21 5:41 PM, Steven Rostedt wrote:
> > 
> > Second patch with the exact same update. Perhaps we should take one
> > before we get more of them ;-)
> > 
> > https://lore.kernel.org/lkml/20210416194300.3952208-1-cmllamas@google.com/
> >   
> 
> Sorry, I missed the other one.
> 


That's OK, I just thought you might have been doing some "research" on us.

What? Too soon?

-- Steve

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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  1:33     ` Steven Rostedt
@ 2021-04-22  1:45       ` Guenter Roeck
  2021-04-22  2:38         ` Steven Rostedt
  0 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2021-04-22  1:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On 4/21/21 6:33 PM, Steven Rostedt wrote:
> On Wed, 21 Apr 2021 18:24:15 -0700
> Guenter Roeck <linux@roeck-us.net> wrote:
> 
>> On 4/21/21 5:41 PM, Steven Rostedt wrote:
>>>
>>> Second patch with the exact same update. Perhaps we should take one
>>> before we get more of them ;-)
>>>
>>> https://lore.kernel.org/lkml/20210416194300.3952208-1-cmllamas@google.com/
>>>   
>>
>> Sorry, I missed the other one.
>>
> 
> 
> That's OK, I just thought you might have been doing some "research" on us.
> 

Not amused. I don't play such games.

No, this causes a compile error for us for a build with CONFIG_MODULES=n
in combination with -Werror. The problem was backported to v5.10.y with
the merge of v5.10.28, which makes it worse because it introduced a
regression into that branch. A regression causing a compile error isn't
really improving confidence in the test coverage of stable releases.

Unfortunately there was a miscommunication internally; my understanding
was that no patch was submitted upstream.

Guenter

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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  1:45       ` Guenter Roeck
@ 2021-04-22  2:38         ` Steven Rostedt
  0 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2021-04-22  2:38 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On Wed, 21 Apr 2021 18:45:20 -0700
Guenter Roeck <linux@roeck-us.net> wrote:

> > 
> > That's OK, I just thought you might have been doing some "research" on us.
> >   
> 
> Not amused. I don't play such games.

I know you don't, but I just couldn't resist saying it. You should have
known that I was joking by the part of my reply that you cut off. ;-)

-- Steve

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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  0:41 ` Steven Rostedt
  2021-04-22  1:24   ` Guenter Roeck
@ 2021-04-22  7:20   ` Peter Zijlstra
  2021-04-22 14:01     ` Guenter Roeck
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2021-04-22  7:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Guenter Roeck, Josh Poimboeuf, Jason Baron, Ard Biesheuvel, linux-kernel

On Wed, Apr 21, 2021 at 08:41:39PM -0400, Steven Rostedt wrote:
> 
> Second patch with the exact same update. Perhaps we should take one
> before we get more of them ;-)
> 

I thought we already fixed that...

---
commit 7d95f22798ecea513f37b792b39fec4bcf20fec3
Author: Matthieu Baerts <matthieu.baerts@tessares.net>
Date:   Fri Mar 26 11:50:23 2021 +0100

    static_call: Fix unused variable warn w/o MODULE
    
    Here is the warning converted as error and reported by GCC:
    
      kernel/static_call.c: In function ‘__static_call_update’:
      kernel/static_call.c:153:18: error: unused variable ‘mod’ [-Werror=unused-variable]
        153 |   struct module *mod = site_mod->mod;
            |                  ^~~
      cc1: all warnings being treated as errors
      make[1]: *** [scripts/Makefile.build:271: kernel/static_call.o] Error 1
    
    This is simply because since recently, we no longer use 'mod' variable
    elsewhere if MODULE is unset.
    
    When using 'make tinyconfig' to generate the default kconfig, MODULE is
    unset.
    
    There are different ways to fix this warning. Here I tried to minimised
    the number of modified lines and not add more #ifdef. We could also move
    the declaration of the 'mod' variable inside the if-statement or
    directly use site_mod->mod.
    
    Fixes: 698bacefe993 ("static_call: Align static_call_is_init() patching condition")
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20210326105023.2058860-1-matthieu.baerts@tessares.net

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 2c5950b0b90e..723fcc9d20db 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
 		stop = __stop_static_call_sites;
 
-#ifdef CONFIG_MODULES
 		if (mod) {
+#ifdef CONFIG_MODULES
 			stop = mod->static_call_sites +
 			       mod->num_static_call_sites;
 			init = mod->state == MODULE_STATE_COMING;
-		}
 #endif
+		}
 
 		for (site = site_mod->sites;
 		     site < stop && static_call_key(site) == key; site++) {

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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22  7:20   ` Peter Zijlstra
@ 2021-04-22 14:01     ` Guenter Roeck
  2021-04-22 16:13       ` Peter Zijlstra
  0 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2021-04-22 14:01 UTC (permalink / raw)
  To: Peter Zijlstra, Steven Rostedt
  Cc: Josh Poimboeuf, Jason Baron, Ard Biesheuvel, linux-kernel

On 4/22/21 12:20 AM, Peter Zijlstra wrote:
> On Wed, Apr 21, 2021 at 08:41:39PM -0400, Steven Rostedt wrote:
>>
>> Second patch with the exact same update. Perhaps we should take one
>> before we get more of them ;-)
>>
> 
> I thought we already fixed that...

Not in v5.12-rc8-6-g4bdafe832681, which is ToT right now.

Ah, I do see it in -next, but that doesn't help me in mainline,
nor in stable branches where the patch introducing the problem
has been backported to.

Guenter

> 
> ---
> commit 7d95f22798ecea513f37b792b39fec4bcf20fec3
> Author: Matthieu Baerts <matthieu.baerts@tessares.net>
> Date:   Fri Mar 26 11:50:23 2021 +0100
> 
>     static_call: Fix unused variable warn w/o MODULE
>     
>     Here is the warning converted as error and reported by GCC:
>     
>       kernel/static_call.c: In function ‘__static_call_update’:
>       kernel/static_call.c:153:18: error: unused variable ‘mod’ [-Werror=unused-variable]
>         153 |   struct module *mod = site_mod->mod;
>             |                  ^~~
>       cc1: all warnings being treated as errors
>       make[1]: *** [scripts/Makefile.build:271: kernel/static_call.o] Error 1
>     
>     This is simply because since recently, we no longer use 'mod' variable
>     elsewhere if MODULE is unset.
>     
>     When using 'make tinyconfig' to generate the default kconfig, MODULE is
>     unset.
>     
>     There are different ways to fix this warning. Here I tried to minimised
>     the number of modified lines and not add more #ifdef. We could also move
>     the declaration of the 'mod' variable inside the if-statement or
>     directly use site_mod->mod.
>     
>     Fixes: 698bacefe993 ("static_call: Align static_call_is_init() patching condition")
>     Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
>     Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>     Link: https://lkml.kernel.org/r/20210326105023.2058860-1-matthieu.baerts@tessares.net
> 
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index 2c5950b0b90e..723fcc9d20db 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
>  
>  		stop = __stop_static_call_sites;
>  
> -#ifdef CONFIG_MODULES
>  		if (mod) {
> +#ifdef CONFIG_MODULES
>  			stop = mod->static_call_sites +
>  			       mod->num_static_call_sites;
>  			init = mod->state == MODULE_STATE_COMING;
> -		}
>  #endif
> +		}
>  
>  		for (site = site_mod->sites;
>  		     site < stop && static_call_key(site) == key; site++) {
> 


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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22 14:01     ` Guenter Roeck
@ 2021-04-22 16:13       ` Peter Zijlstra
  2021-04-22 18:01         ` Guenter Roeck
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Zijlstra @ 2021-04-22 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Steven Rostedt, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On Thu, Apr 22, 2021 at 07:01:47AM -0700, Guenter Roeck wrote:
> On 4/22/21 12:20 AM, Peter Zijlstra wrote:
> > On Wed, Apr 21, 2021 at 08:41:39PM -0400, Steven Rostedt wrote:
> >>
> >> Second patch with the exact same update. Perhaps we should take one
> >> before we get more of them ;-)
> >>
> > 
> > I thought we already fixed that...
> 
> Not in v5.12-rc8-6-g4bdafe832681, which is ToT right now.
> 
> Ah, I do see it in -next, but that doesn't help me in mainline,
> nor in stable branches where the patch introducing the problem
> has been backported to.

Given it's a silly warning I didn't figure it was urgent material. I
suppose we can backport it if someone (you apperntly) cares.

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

* Re: [PATCH] static_call: Fix unused variable warning
  2021-04-22 16:13       ` Peter Zijlstra
@ 2021-04-22 18:01         ` Guenter Roeck
  0 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2021-04-22 18:01 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Steven Rostedt, Josh Poimboeuf, Jason Baron, Ard Biesheuvel,
	linux-kernel

On Thu, Apr 22, 2021 at 06:13:32PM +0200, Peter Zijlstra wrote:
> On Thu, Apr 22, 2021 at 07:01:47AM -0700, Guenter Roeck wrote:
> > On 4/22/21 12:20 AM, Peter Zijlstra wrote:
> > > On Wed, Apr 21, 2021 at 08:41:39PM -0400, Steven Rostedt wrote:
> > >>
> > >> Second patch with the exact same update. Perhaps we should take one
> > >> before we get more of them ;-)
> > >>
> > > 
> > > I thought we already fixed that...
> > 
> > Not in v5.12-rc8-6-g4bdafe832681, which is ToT right now.
> > 
> > Ah, I do see it in -next, but that doesn't help me in mainline,
> > nor in stable branches where the patch introducing the problem
> > has been backported to.
> 
> Given it's a silly warning I didn't figure it was urgent material. I
> suppose we can backport it if someone (you apperntly) cares.

We build release images with -Werror, and some of those images have
CONFIG_MODULES=n. So this wasn't silly for us. It was catastrophic
for the affected images. We already applied my proposed fix, so it
isn't specifically urgent for us anymore. However, the presence of
such "silly" warnings in stable releases (and backporting of patches
introducing such warnings into stable releases) gives ammunition
to those arguing that we should not merge stable releases because
they introduce regressions. And your statement that the warning is
"silly" doesn't help either, sorry.

Guenter

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

* [PATCH] static_call: fix unused variable warning
@ 2021-04-16 19:43 Carlos Llamas
  0 siblings, 0 replies; 11+ messages in thread
From: Carlos Llamas @ 2021-04-16 19:43 UTC (permalink / raw)
  To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Steven Rostedt,
	Ard Biesheuvel, Ingo Molnar
  Cc: linux-kernel, Carlos Llamas, kernelci . org bot

'mod' is not used when !CONFIG_MODULES. Mark as __maybe_unused to
fix the following warning:

kernel/static_call.c: In function ‘__static_call_update’:
kernel/static_call.c:153:18: warning: unused variable ‘mod’ [-Wunused-variable]
  153 |   struct module *mod = site_mod->mod;
      |                  ^~~

Fixes: 9183c3f9ed71 ("static_call: Add inline static call infrastructure")
Reported-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
 kernel/static_call.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 2c5950b0b90e..8211a34251f8 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -150,7 +150,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
 	for (site_mod = &first; site_mod; site_mod = site_mod->next) {
 		bool init = system_state < SYSTEM_RUNNING;
-		struct module *mod = site_mod->mod;
+		struct module __maybe_unused *mod = site_mod->mod;
 
 		if (!site_mod->sites) {
 			/*
-- 
2.31.1.368.gbe11c130af-goog


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

end of thread, other threads:[~2021-04-22 18:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22  0:33 [PATCH] static_call: Fix unused variable warning Guenter Roeck
2021-04-22  0:41 ` Steven Rostedt
2021-04-22  1:24   ` Guenter Roeck
2021-04-22  1:33     ` Steven Rostedt
2021-04-22  1:45       ` Guenter Roeck
2021-04-22  2:38         ` Steven Rostedt
2021-04-22  7:20   ` Peter Zijlstra
2021-04-22 14:01     ` Guenter Roeck
2021-04-22 16:13       ` Peter Zijlstra
2021-04-22 18:01         ` Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2021-04-16 19:43 [PATCH] static_call: fix " Carlos Llamas

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.