smp_call_function: use inline helpers instead of macros

Message ID 20170511151418.2700143-1-arnd@arndb.de
State New
Headers show

Commit Message

Arnd Bergmann May 11, 2017, 3:13 p.m.
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(-)

-- 
2.9.0

Comments

Paolo Bonzini May 11, 2017, 3:34 p.m. | #1
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

>
kbuild test robot May 11, 2017, 6:53 p.m. | #2
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

Patch hide | download patch | download mbox

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