All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
@ 2017-05-11  3:40 ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-05-11  3:40 UTC (permalink / raw)
  To: Paolo Bonzini, kvm; +Cc: kvm-ppc

Commit 7a97cec26b94 ("KVM: mark requests that need synchronization",
2017-04-27) added a variable 'wait' to kvm_make_all_cpus_request(),
which is only consumed in calls to smp_call_function_many.  When the
kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
into a macro which doesn't use the 'wait' argument, leading to a
warning about the variable 'wait' being unused:

/home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
/home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
  bool wait = req & KVM_REQUEST_WAIT;
       ^

Since PPC compiles everything that gets built under arch/powerpc
with -Werror by default, this causes the build to fail.

This fixes it by adding a __maybe_unused annotation to the
declaration of 'wait'.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f0fe9d0..f72b8a0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -192,7 +192,7 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
 	int i, cpu, me;
 	cpumask_var_t cpus;
 	bool called = true;
-	bool wait = req & KVM_REQUEST_WAIT;
+	bool __maybe_unused wait = req & KVM_REQUEST_WAIT;
 	struct kvm_vcpu *vcpu;
 
 	zalloc_cpumask_var(&cpus, GFP_ATOMIC);
-- 
2.7.4

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

* [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
@ 2017-05-11  3:40 ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-05-11  3:40 UTC (permalink / raw)
  To: Paolo Bonzini, kvm; +Cc: kvm-ppc

Commit 7a97cec26b94 ("KVM: mark requests that need synchronization",
2017-04-27) added a variable 'wait' to kvm_make_all_cpus_request(),
which is only consumed in calls to smp_call_function_many.  When the
kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
into a macro which doesn't use the 'wait' argument, leading to a
warning about the variable 'wait' being unused:

/home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
/home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
  bool wait = req & KVM_REQUEST_WAIT;
       ^

Since PPC compiles everything that gets built under arch/powerpc
with -Werror by default, this causes the build to fail.

This fixes it by adding a __maybe_unused annotation to the
declaration of 'wait'.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f0fe9d0..f72b8a0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -192,7 +192,7 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
 	int i, cpu, me;
 	cpumask_var_t cpus;
 	bool called = true;
-	bool wait = req & KVM_REQUEST_WAIT;
+	bool __maybe_unused wait = req & KVM_REQUEST_WAIT;
 	struct kvm_vcpu *vcpu;
 
 	zalloc_cpumask_var(&cpus, GFP_ATOMIC);
-- 
2.7.4


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

* Re: [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
  2017-05-11  3:40 ` Paul Mackerras
@ 2017-05-11  7:44   ` Paolo Bonzini
  -1 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2017-05-11  7:44 UTC (permalink / raw)
  To: Paul Mackerras, kvm; +Cc: kvm-ppc, linux-kernel



On 11/05/2017 05:40, Paul Mackerras wrote:
> When the
> kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
> into a macro which doesn't use the 'wait' argument, leading to a
> warning about the variable 'wait' being unused:
> 
> /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
> /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
>   bool wait = req & KVM_REQUEST_WAIT;

Maybe the macro should not be a macro:

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 8e0cb7a0f836..899c72f0933f 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -128,17 +128,18 @@ static inline void smp_send_stop(void) { }
  *	These macros fold the SMP functionality into a single CPU system
  */
 #define raw_smp_processor_id()			0
-static inline int up_smp_call_function(smp_call_func_t func, void *info)
+static inline void smp_call_function_many(const struct cpumask *mask,
+					  smp_call_func_t func, void *info,
+					  bool wait);
 {
-	return 0;
+}
+
+static inline void smp_call_function(smp_call_func_t func, void *info, bool wait);
+{
 }
-#define smp_call_function(func, info, wait) \
-			(up_smp_call_function(func, info))
 
 static inline void smp_send_reschedule(int cpu) { }
 #define smp_prepare_boot_cpu()			do {} while (0)
-#define smp_call_function_many(mask, func, info, wait) \
-			(up_smp_call_function(func, info))
 static inline void call_function_init(void) { }
 
 static inline int


Paolo

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

* Re: [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
@ 2017-05-11  7:44   ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2017-05-11  7:44 UTC (permalink / raw)
  To: Paul Mackerras, kvm; +Cc: kvm-ppc, linux-kernel



On 11/05/2017 05:40, Paul Mackerras wrote:
> When the
> kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
> into a macro which doesn't use the 'wait' argument, leading to a
> warning about the variable 'wait' being unused:
> 
> /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
> /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
>   bool wait = req & KVM_REQUEST_WAIT;

Maybe the macro should not be a macro:

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 8e0cb7a0f836..899c72f0933f 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -128,17 +128,18 @@ static inline void smp_send_stop(void) { }
  *	These macros fold the SMP functionality into a single CPU system
  */
 #define raw_smp_processor_id()			0
-static inline int up_smp_call_function(smp_call_func_t func, void *info)
+static inline void smp_call_function_many(const struct cpumask *mask,
+					  smp_call_func_t func, void *info,
+					  bool wait);
 {
-	return 0;
+}
+
+static inline void smp_call_function(smp_call_func_t func, void *info, bool wait);
+{
 }
-#define smp_call_function(func, info, wait) \
-			(up_smp_call_function(func, info))
 
 static inline void smp_send_reschedule(int cpu) { }
 #define smp_prepare_boot_cpu()			do {} while (0)
-#define smp_call_function_many(mask, func, info, wait) \
-			(up_smp_call_function(func, info))
 static inline void call_function_init(void) { }
 
 static inline int


Paolo

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

* Re: [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
  2017-05-11  7:44   ` Paolo Bonzini
@ 2017-05-12  6:10     ` Paul Mackerras
  -1 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-05-12  6:10 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, kvm-ppc, linux-kernel

On Thu, May 11, 2017 at 09:44:06AM +0200, Paolo Bonzini wrote:
> 
> 
> On 11/05/2017 05:40, Paul Mackerras wrote:
> > When the
> > kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
> > into a macro which doesn't use the 'wait' argument, leading to a
> > warning about the variable 'wait' being unused:
> > 
> > /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
> > /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
> >   bool wait = req & KVM_REQUEST_WAIT;
> 
> Maybe the macro should not be a macro:

Sounds fair, and with a couple of semicolons removed, it works and
fixes the problem.  Do you want to send it to the appropriate
maintainer(s) or will I?

> diff --git a/include/linux/smp.h b/include/linux/smp.h
> index 8e0cb7a0f836..899c72f0933f 100644
> --- a/include/linux/smp.h
> +++ b/include/linux/smp.h
> @@ -128,17 +128,18 @@ static inline void smp_send_stop(void) { }
>   *	These macros fold the SMP functionality into a single CPU system
>   */
>  #define raw_smp_processor_id()			0
> -static inline int up_smp_call_function(smp_call_func_t func, void *info)
> +static inline void smp_call_function_many(const struct cpumask *mask,
> +					  smp_call_func_t func, void *info,
> +					  bool wait);

No semicolon on the end of this line...

>  {
> -	return 0;
> +}
> +
> +static inline void smp_call_function(smp_call_func_t func, void *info, bool wait);

or this one.

Paul.

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

* Re: [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs
@ 2017-05-12  6:10     ` Paul Mackerras
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-05-12  6:10 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, kvm-ppc, linux-kernel

On Thu, May 11, 2017 at 09:44:06AM +0200, Paolo Bonzini wrote:
> 
> 
> On 11/05/2017 05:40, Paul Mackerras wrote:
> > When the
> > kernel is compiled with CONFIG_SMP=n, smp_call_function_many() turns
> > into a macro which doesn't use the 'wait' argument, leading to a
> > warning about the variable 'wait' being unused:
> > 
> > /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c: In function ‘kvm_make_all_cpus_request’:
> > /home/paulus/kernel/kvm/arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:195:7: error: unused variable ‘wait’ [-Werror=unused-variable]
> >   bool wait = req & KVM_REQUEST_WAIT;
> 
> Maybe the macro should not be a macro:

Sounds fair, and with a couple of semicolons removed, it works and
fixes the problem.  Do you want to send it to the appropriate
maintainer(s) or will I?

> diff --git a/include/linux/smp.h b/include/linux/smp.h
> index 8e0cb7a0f836..899c72f0933f 100644
> --- a/include/linux/smp.h
> +++ b/include/linux/smp.h
> @@ -128,17 +128,18 @@ static inline void smp_send_stop(void) { }
>   *	These macros fold the SMP functionality into a single CPU system
>   */
>  #define raw_smp_processor_id()			0
> -static inline int up_smp_call_function(smp_call_func_t func, void *info)
> +static inline void smp_call_function_many(const struct cpumask *mask,
> +					  smp_call_func_t func, void *info,
> +					  bool wait);

No semicolon on the end of this line...

>  {
> -	return 0;
> +}
> +
> +static inline void smp_call_function(smp_call_func_t func, void *info, bool wait);

or this one.

Paul.

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

end of thread, other threads:[~2017-05-12  6:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-11  3:40 [PATCH] KVM: Eliminate unused variable warning on uniprocessor configs Paul Mackerras
2017-05-11  3:40 ` Paul Mackerras
2017-05-11  7:44 ` Paolo Bonzini
2017-05-11  7:44   ` Paolo Bonzini
2017-05-12  6:10   ` Paul Mackerras
2017-05-12  6:10     ` Paul Mackerras

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.