All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smp_call_function: use inline helpers instead of macros
@ 2017-05-11 15:13 Arnd Bergmann
  2017-05-11 15:34 ` Paolo Bonzini
  2017-05-11 18:53 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-05-11 15:13 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Paolo Bonzini, Ingo Molnar, Peter Zijlstra, linux-kernel

A new caller of smp_call_function() passes a local variable as the 'wait'
argument, and that variable is otherwise unused, so we get a warning
in non-SMP configurations:

virt/kvm/kvm_main.c: In function 'kvm_make_all_cpus_request':
virt/kvm/kvm_main.c:195:7: error: unused variable 'wait' [-Werror=unused-variable]
  bool wait = req & KVM_REQUEST_WAIT;

This addresses the warning by changing the two macros into inline functions.

Fixes: 7a97cec26b94 ("KVM: mark requests that need synchronization")
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/smp.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/linux/smp.h b/include/linux/smp.h
index e978ec742103..acd401c0c77d 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -144,13 +144,20 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info)
 {
 	return 0;
 }
-#define smp_call_function(func, info, wait) \
-			(up_smp_call_function(func, info))
+static inline int smp_call_function(smp_call_func_t func, void *info, int wait)
+{
+	return 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 smp_call_function_many(const struct cpumask *mask,
+			    smp_call_func_t func, void *info, bool wait)
+{
+	up_smp_call_function(func, info);
+}
+
 static inline void call_function_init(void) { }
 
 static inline int
-- 
2.9.0

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

* Re: [PATCH] smp_call_function: use inline helpers instead of macros
  2017-05-11 15:13 [PATCH] smp_call_function: use inline helpers instead of macros Arnd Bergmann
@ 2017-05-11 15:34 ` Paolo Bonzini
  2017-05-11 18:53 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2017-05-11 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, Andrew Morton; +Cc: Ingo Molnar, Peter Zijlstra, linux-kernel



On 11/05/2017 17:13, Arnd Bergmann wrote:
> A new caller of smp_call_function() passes a local variable as the 'wait'
> argument, and that variable is otherwise unused, so we get a warning
> in non-SMP configurations:
> 
> virt/kvm/kvm_main.c: In function 'kvm_make_all_cpus_request':
> virt/kvm/kvm_main.c:195:7: error: unused variable 'wait' [-Werror=unused-variable]
>   bool wait = req & KVM_REQUEST_WAIT;
> 
> This addresses the warning by changing the two macros into inline functions.
> 
> Fixes: 7a97cec26b94 ("KVM: mark requests that need synchronization")
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/smp.h | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/smp.h b/include/linux/smp.h
> index e978ec742103..acd401c0c77d 100644
> --- a/include/linux/smp.h
> +++ b/include/linux/smp.h
> @@ -144,13 +144,20 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info)
>  {
>  	return 0;
>  }
> -#define smp_call_function(func, info, wait) \
> -			(up_smp_call_function(func, info))
> +static inline int smp_call_function(smp_call_func_t func, void *info, int wait)
> +{
> +	return up_smp_call_function(func, info);
> +}

You can just delete up_smp_call_function and return 0.  The purpose of
up_smp_call_function was only to eat warnings about those two arguments,
as far as I could see.

(I sent almost exactly the same patch to Paul this morning).

Paolo

>  
>  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 smp_call_function_many(const struct cpumask *mask,
> +			    smp_call_func_t func, void *info, bool wait)
> +{
> +	up_smp_call_function(func, info);
> +}
> +
>  static inline void call_function_init(void) { }
>  
>  static inline int
> 

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

* Re: [PATCH] smp_call_function: use inline helpers instead of macros
  2017-05-11 15:13 [PATCH] smp_call_function: use inline helpers instead of macros Arnd Bergmann
  2017-05-11 15:34 ` Paolo Bonzini
@ 2017-05-11 18:53 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-05-11 18:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild-all, Andrew Morton, Arnd Bergmann, Paolo Bonzini,
	Ingo Molnar, Peter Zijlstra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3167 bytes --]

Hi Arnd,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.11 next-20170511]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/smp_call_function-use-inline-helpers-instead-of-macros/20170512-004338
config: mips-ip32_defconfig (attached as .config)
compiler: mips64-linux-gnuabi64-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   arch/mips/mm/c-r4k.c: In function 'r4k_on_each_cpu':
>> arch/mips/mm/c-r4k.c:101:27: error: 'cpu_foreign_map' undeclared (first use in this function)
      smp_call_function_many(&cpu_foreign_map[smp_processor_id()],
                              ^~~~~~~~~~~~~~~
   arch/mips/mm/c-r4k.c:101:27: note: each undeclared identifier is reported only once for each function it appears in

vim +/cpu_foreign_map +101 arch/mips/mm/c-r4k.c

d374d9374 James Hogan  2016-07-13   85  }
d374d9374 James Hogan  2016-07-13   86  
d374d9374 James Hogan  2016-07-13   87  /*
7f3f1d01a Ralf Baechle 2006-05-12   88   * Special Variant of smp_call_function for use by cache functions:
7f3f1d01a Ralf Baechle 2006-05-12   89   *
7f3f1d01a Ralf Baechle 2006-05-12   90   *  o No return value
7f3f1d01a Ralf Baechle 2006-05-12   91   *  o collapses to normal function call on UP kernels
7f3f1d01a Ralf Baechle 2006-05-12   92   *  o collapses to normal function call on systems with a single shared
7f3f1d01a Ralf Baechle 2006-05-12   93   *    primary cache.
c8c5f3fd9 Ralf Baechle 2010-10-29   94   *  o doesn't disable interrupts on the local CPU
7f3f1d01a Ralf Baechle 2006-05-12   95   */
d374d9374 James Hogan  2016-07-13   96  static inline void r4k_on_each_cpu(unsigned int type,
d374d9374 James Hogan  2016-07-13   97  				   void (*func)(void *info), void *info)
7f3f1d01a Ralf Baechle 2006-05-12   98  {
7f3f1d01a Ralf Baechle 2006-05-12   99  	preempt_disable();
d374d9374 James Hogan  2016-07-13  100  	if (r4k_op_needs_ipi(type))
640511ae9 James Hogan  2016-07-13 @101  		smp_call_function_many(&cpu_foreign_map[smp_processor_id()],
640511ae9 James Hogan  2016-07-13  102  				       func, info, 1);
7f3f1d01a Ralf Baechle 2006-05-12  103  	func(info);
7f3f1d01a Ralf Baechle 2006-05-12  104  	preempt_enable();
7f3f1d01a Ralf Baechle 2006-05-12  105  }
7f3f1d01a Ralf Baechle 2006-05-12  106  
ec74e361f Ralf Baechle 2005-07-13  107  /*
ec74e361f Ralf Baechle 2005-07-13  108   * Must die.
ec74e361f Ralf Baechle 2005-07-13  109   */

:::::: The code at line 101 was first introduced by commit
:::::: 640511ae92466800c75da77a3c7f72b8488c93a1 MIPS: c-r4k: Exclude sibling CPUs in SMP calls

:::::: TO: James Hogan <james.hogan@imgtec.com>
:::::: CC: Ralf Baechle <ralf@linux-mips.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 14423 bytes --]

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

end of thread, other threads:[~2017-05-11 18:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-11 15:13 [PATCH] smp_call_function: use inline helpers instead of macros Arnd Bergmann
2017-05-11 15:34 ` Paolo Bonzini
2017-05-11 18:53 ` kbuild test robot

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.