smp: make wake up idle cpus more generic
Subsystems (3)
PATCH 1/1 smp: make wake up idle cpus more generic
The wake_up_all_idle_cpus API always wake up all the online cpus, but sometimes we only want to wake up a set of cpus.
Use a generic function to wake up a group of cpus that is specified by the cpumask parameter. This generic API can benefit to the cases that only need to wake up a set of cpus.
--- drivers/cpuidle/cpuidle.c | 4 ++-- include/linux/smp.h | 4 ++-- kernel/power/suspend.c | 2 +- kernel/smp.c | 12 +++++++----- 4 files changed, 12 insertions(+), 10 deletions(-)
drivers/cpuidle/cpuidle.c +2 -2
@@ -301,7 +301,7 @@ void cpuidle_uninstall_idle_handler(void) {if (enabled_devices) { initialized =0 ; -wake_up_all_idle_cpus (); +wake_up_idle_cpus (cpu_online_mask); }/*
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register);static int cpuidle_latency_notify (struct notifier_block *b,unsigned long l,void *v) { -wake_up_all_idle_cpus (); + wake_up_idle_cpus((cpu_online_mask);return NOTIFY_OK ; }
include/linux/smp.h +2 -2
@@ -100,7 +100,7 @@ int smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, void *info, int wait);void kick_all_cpus_sync (void ); -void wake_up_all_idle_cpus (void ); +void wake_up_idle_cpus (const struct cpumask *mask);/* * Generic and arch helpers
@@ -149,7 +149,7 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, }static inline void kick_all_cpus_sync (void ) { } -static inline void wake_up_all_idle_cpus (void ) { } +static inline void wake_up_idle_cpus (const struct cpumask *mask) { }#ifdef CONFIG_UP_LATE_INIT extern void __init up_late_init (void );
kernel/power/suspend.c +1 -1
@@ -70,7 +70,7 @@ static void freeze_enter(void)cpuidle_resume ();/* Push all the CPUs into the idle loop. */ -wake_up_all_idle_cpus (); +wake_up_idle_cpus (cpu_online_mask);pr_debug ("PM: suspend-to-idle\n" );/* Make the current CPU wait so it can enter the idle loop too. */ wait_event(suspend_freeze_wait_head,
kernel/smp.c +7 -5
@@ -720,17 +720,19 @@ void kick_all_cpus_sync(void)EXPORT_SYMBOL_GPL (kick_all_cpus_sync);/** -* wake_up_all_idle_cpus - break all cpus out of idle -* wake_up_all_idle_cpus try to break all cpus which is in idle state even +* wake_up_idle_cpus - break a set of cpus out of idle +* @mask: The set of cpus to break out of idle +* +* wake_up_idle_cpus try to break a set of cpus which is in idle state even * including idle polling cpus, for non-idle cpus, we will do nothing * for them. */ -void wake_up_all_idle_cpus (void ) +void wake_up_idle_cpus (const struct cpumask *mask) {int cpu;preempt_disable (); -for_each_online_cpu (cpu) { +for_each_cpu_and (cpu, mask, cpu_online_mask) {if (cpu ==smp_processor_id ())continue ;
@@ -738,4 +740,4 @@ void wake_up_all_idle_cpus(void) }preempt_enable (); } -EXPORT_SYMBOL_GPL (wake_up_all_idle_cpus); +EXPORT_SYMBOL_GPL (wake_up_idle_cpus);
Signature · 1 line
1.9.1
kbuild test robot
build botreproduce:
Hi Lianwei,
[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.6-rc1 next-20160331]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Lianwei-Wang/smp-make-wake-up-idle-cpus-more-generic/20160331-155548 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: i386-randconfig-n0-201613 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386
All error/warnings (new ones prefixed by >>):
drivers/cpuidle/cpuidle.c: In function 'cpuidle_latency_notify':
>> drivers/cpuidle/cpuidle.c:623:37: error: expected ')' before ';' token
wake_up_idle_cpus((cpu_online_mask);
^
>> drivers/cpuidle/cpuidle.c:625:1: error: expected ';' before '}' token
}
^
>> drivers/cpuidle/cpuidle.c:625:1: warning: no return statement in function returning non-void [-Wreturn-type]vim +623 drivers/cpuidle/cpuidle.c
617 * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that
618 * wakes them all right up.
619 */
620 static int cpuidle_latency_notify(struct notifier_block *b,
621 unsigned long l, void *v)
622 {
> 623 wake_up_idle_cpus((cpu_online_mask); 624 return NOTIFY_OK; > 625 }
626
627 static struct notifier_block cpuidle_latency_notifier = {
628 .notifier_call = cpuidle_latency_notify,
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Sorry, my fault. I made a typo mistake when sending the patch. I will fix it and resend the patch.
Quoted 42 lines · kbuild test robot
Hi Lianwei,
[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.6-rc1 next-20160331]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]url: https://github.com/0day-ci/linux/commits/Lianwei-Wang/smp-make-wake-up-idle-cpus-more-generic/20160331-155548 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: i386-randconfig-n0-201613 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386All error/warnings (new ones prefixed by >>):
drivers/cpuidle/cpuidle.c: In function 'cpuidle_latency_notify':Quoted 1 line
Quoted 1 line
drivers/cpuidle/cpuidle.c:623:37: error: expected ')' before ';' tokenwake_up_idle_cpus((cpu_online_mask); ^Quoted 1 line
Quoted 1 line
drivers/cpuidle/cpuidle.c:625:1: error: expected ';' before '}' token} ^Quoted 1 line
Quoted 1 line
drivers/cpuidle/cpuidle.c:625:1: warning: no return statement in function returning non-void [-Wreturn-type]vim +623
drivers/cpuidle/cpuidle.c617 * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that 618 * wakes them all right up. 619 */620 static int cpuidle_latency_notify(struct
notifier_block*b,
621 unsigned long l, void *v)
622 {Quoted 1 line
623 wake_up_idle_cpus((cpu_online_mask);
624 return
NOTIFY_OK;Quoted 1 line
625 }
626
627 static structnotifier_blockcpuidle_latency_notifier= {
628 .notifier_call =cpuidle_latency_notify,---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation