2021-01-19 15:05:03

by Yejune Deng

[permalink] [raw]
Subject: [PATCH] smp: Modify 'int' to 'bool' in smp_call_function_single()

In smp_call_function_single() and its caller,the 'wait' variable is only
0 and 1,a bool is a more appropriate definition.

Signed-off-by: Yejune Deng <[email protected]>
---
include/linux/smp.h | 10 +++++-----
kernel/smp.c | 8 ++++----
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 70c6f6284dcf..5f27ebd504e2 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -48,12 +48,12 @@ extern void __smp_call_single_queue(int cpu, struct llist_node *node);
extern unsigned int total_cpus;

int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
- int wait);
+ bool wait);

/*
* Call a function on all processors
*/
-void on_each_cpu(smp_call_func_t func, void *info, int wait);
+void on_each_cpu(smp_call_func_t func, void *info, bool wait);

/*
* Call a function on processors specified by mask, which might include
@@ -117,12 +117,12 @@ extern void smp_cpus_done(unsigned int max_cpus);
/*
* Call a function on all other processors
*/
-void smp_call_function(smp_call_func_t func, void *info, int wait);
+void smp_call_function(smp_call_func_t func, void *info, bool wait);
void smp_call_function_many(const struct cpumask *mask,
smp_call_func_t func, void *info, bool wait);

int smp_call_function_any(const struct cpumask *mask,
- smp_call_func_t func, void *info, int wait);
+ smp_call_func_t func, void *info, bool wait);

void kick_all_cpus_sync(void);
void wake_up_all_idle_cpus(void);
@@ -174,7 +174,7 @@ static inline void call_function_init(void) { }

static inline int
smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
- void *info, int wait)
+ void *info, bool wait)
{
return smp_call_function_single(0, func, info, wait);
}
diff --git a/kernel/smp.c b/kernel/smp.c
index 1b6070bf97bb..c72e474d53ab 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -461,7 +461,7 @@ void flush_smp_call_function_from_idle(void)
* Returns 0 on success, else a negative status code.
*/
int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
- int wait)
+ bool wait)
{
call_single_data_t *csd;
call_single_data_t csd_stack = {
@@ -576,7 +576,7 @@ EXPORT_SYMBOL_GPL(smp_call_function_single_async);
* 3) any other online cpu in @mask
*/
int smp_call_function_any(const struct cpumask *mask,
- smp_call_func_t func, void *info, int wait)
+ smp_call_func_t func, void *info, bool wait)
{
unsigned int cpu;
const struct cpumask *nodemask;
@@ -727,7 +727,7 @@ EXPORT_SYMBOL(smp_call_function_many);
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
*/
-void smp_call_function(smp_call_func_t func, void *info, int wait)
+void smp_call_function(smp_call_func_t func, void *info, bool wait)
{
preempt_disable();
smp_call_function_many(cpu_online_mask, func, info, wait);
@@ -824,7 +824,7 @@ void __init smp_init(void)
* early_boot_irqs_disabled is set. Use local_irq_save/restore() instead
* of local_irq_disable/enable().
*/
-void on_each_cpu(smp_call_func_t func, void *info, int wait)
+void on_each_cpu(smp_call_func_t func, void *info, bool wait)
{
unsigned long flags;

--
2.29.0


2021-01-20 22:09:23

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] smp: Modify 'int' to 'bool' in smp_call_function_single()

Hi Yejune,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc4 next-20210120]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Yejune-Deng/smp-Modify-int-to-bool-in-smp_call_function_single/20210120-154807
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 45dfb8a5659ad286c28fa59008271dbc4e5e3f2d
config: nds32-defconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/856e1f8de78bcf1c02ffa0f33a5047172bd0d0c9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yejune-Deng/smp-Modify-int-to-bool-in-smp_call_function_single/20210120-154807
git checkout 856e1f8de78bcf1c02ffa0f33a5047172bd0d0c9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> kernel/up.c:12:5: error: conflicting types for 'smp_call_function_single'
12 | int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/percpu.h:7,
from include/linux/context_tracking_state.h:5,
from include/linux/hardirq.h:5,
from include/linux/interrupt.h:11,
from kernel/up.c:6:
include/linux/smp.h:50:5: note: previous declaration of 'smp_call_function_single' was here
50 | int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:7,
from include/linux/interrupt.h:6,
from kernel/up.c:6:
kernel/up.c:26:15: error: conflicting types for 'smp_call_function_single'
26 | EXPORT_SYMBOL(smp_call_function_single);
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
98 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL'
158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
| ^~~~~~~~~~~~~~
kernel/up.c:26:1: note: in expansion of macro 'EXPORT_SYMBOL'
26 | EXPORT_SYMBOL(smp_call_function_single);
| ^~~~~~~~~~~~~
In file included from include/linux/percpu.h:7,
from include/linux/context_tracking_state.h:5,
from include/linux/hardirq.h:5,
from include/linux/interrupt.h:11,
from kernel/up.c:6:
include/linux/smp.h:50:5: note: previous declaration of 'smp_call_function_single' was here
50 | int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/up.c:39:6: error: conflicting types for 'on_each_cpu'
39 | void on_each_cpu(smp_call_func_t func, void *info, int wait)
| ^~~~~~~~~~~
In file included from include/linux/percpu.h:7,
from include/linux/context_tracking_state.h:5,
from include/linux/hardirq.h:5,
from include/linux/interrupt.h:11,
from kernel/up.c:6:
include/linux/smp.h:56:6: note: previous declaration of 'on_each_cpu' was here
56 | void on_each_cpu(smp_call_func_t func, void *info, bool wait);
| ^~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/kernel.h:7,
from include/linux/interrupt.h:6,
from kernel/up.c:6:
kernel/up.c:47:15: error: conflicting types for 'on_each_cpu'
47 | EXPORT_SYMBOL(on_each_cpu);
| ^~~~~~~~~~~
include/linux/export.h:98:21: note: in definition of macro '___EXPORT_SYMBOL'
98 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL'
155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "")
| ^~~~~~~~~~~~~~~
include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL'
158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
| ^~~~~~~~~~~~~~
kernel/up.c:47:1: note: in expansion of macro 'EXPORT_SYMBOL'
47 | EXPORT_SYMBOL(on_each_cpu);
| ^~~~~~~~~~~~~
In file included from include/linux/percpu.h:7,
from include/linux/context_tracking_state.h:5,
from include/linux/hardirq.h:5,
from include/linux/interrupt.h:11,
from kernel/up.c:6:
include/linux/smp.h:56:6: note: previous declaration of 'on_each_cpu' was here
56 | void on_each_cpu(smp_call_func_t func, void *info, bool wait);
| ^~~~~~~~~~~


vim +/smp_call_function_single +12 kernel/up.c

53ce3d956490879 Andrew Morton 2009-01-09 11
53ce3d956490879 Andrew Morton 2009-01-09 @12 int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
53ce3d956490879 Andrew Morton 2009-01-09 13 int wait)
53ce3d956490879 Andrew Morton 2009-01-09 14 {
081192b25c2d462 David Daney 2013-09-11 15 unsigned long flags;
081192b25c2d462 David Daney 2013-09-11 16
1e474b28e78897d Paul E. McKenney 2020-02-05 17 if (cpu != 0)
1e474b28e78897d Paul E. McKenney 2020-02-05 18 return -ENXIO;
93423b8665f43a0 Ingo Molnar 2009-01-11 19
081192b25c2d462 David Daney 2013-09-11 20 local_irq_save(flags);
081192b25c2d462 David Daney 2013-09-11 21 func(info);
081192b25c2d462 David Daney 2013-09-11 22 local_irq_restore(flags);
93423b8665f43a0 Ingo Molnar 2009-01-11 23
53ce3d956490879 Andrew Morton 2009-01-09 24 return 0;
53ce3d956490879 Andrew Morton 2009-01-09 25 }
53ce3d956490879 Andrew Morton 2009-01-09 26 EXPORT_SYMBOL(smp_call_function_single);
fa688207c9db48b David Daney 2013-09-11 27
966a967116e6997 Ying Huang 2017-08-08 28 int smp_call_function_single_async(int cpu, call_single_data_t *csd)
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 29 {
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 30 unsigned long flags;
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 31
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 32 local_irq_save(flags);
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 33 csd->func(csd->info);
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 34 local_irq_restore(flags);
08eed44c7249d38 Jan Kara 2014-02-24 35 return 0;
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 36 }
c46fff2a3b29794 Frederic Weisbecker 2014-02-24 37 EXPORT_SYMBOL(smp_call_function_single_async);
40c01e8bd5575e3 Christoph Hellwig 2013-11-14 38
caa759323c73676 Nadav Amit 2019-06-12 @39 void on_each_cpu(smp_call_func_t func, void *info, int wait)
bff2dc42bcafdd7 David Daney 2013-09-11 40 {
bff2dc42bcafdd7 David Daney 2013-09-11 41 unsigned long flags;
bff2dc42bcafdd7 David Daney 2013-09-11 42
bff2dc42bcafdd7 David Daney 2013-09-11 43 local_irq_save(flags);
bff2dc42bcafdd7 David Daney 2013-09-11 44 func(info);
bff2dc42bcafdd7 David Daney 2013-09-11 45 local_irq_restore(flags);
bff2dc42bcafdd7 David Daney 2013-09-11 46 }
bff2dc42bcafdd7 David Daney 2013-09-11 47 EXPORT_SYMBOL(on_each_cpu);
bff2dc42bcafdd7 David Daney 2013-09-11 48

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (8.60 kB)
.config.gz (10.56 kB)
Download all attachments