diff options
| author | Chuansheng Liu <chuansheng.liu@intel.com> | 2014-09-04 03:17:54 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-09-19 06:35:15 -0400 |
| commit | c6f4459fc3ba532e896cb678e29b45cb985f82bf (patch) | |
| tree | 11037e966375b9929a8fd2005bc1e38ae3750122 | |
| parent | f6be8af1c95de4a46e325e728900a70ceadb52cf (diff) | |
smp: Add new wake_up_all_idle_cpus() function
Currently kick_all_cpus_sync() can break non-polling idle cpus
thru IPI interrupts.
But sometimes we need to break the polling idle cpus immediately
to reselect the suitable c-state, also for non-idle cpus, we need
to do nothing if we try to wake up them.
Here adding one new function wake_up_all_idle_cpus() to let all cpus
out of idle based on function wake_up_if_idle().
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: daniel.lezcano@linaro.org
Cc: rjw@rjwysocki.net
Cc: linux-pm@vger.kernel.org
Cc: changcheng.liu@intel.com
Cc: xiaoming.wang@intel.com
Cc: souvik.k.chakravarty@intel.com
Cc: luto@amacapital.net
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@fb.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Roman Gushchin <klamm@yandex-team.ru>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1409815075-4180-2-git-send-email-chuansheng.liu@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | include/linux/smp.h | 2 | ||||
| -rw-r--r-- | kernel/smp.c | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/smp.h b/include/linux/smp.h index 34347f26be9b..93dff5fff524 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h | |||
| @@ -100,6 +100,7 @@ int smp_call_function_any(const struct cpumask *mask, | |||
| 100 | smp_call_func_t func, void *info, int wait); | 100 | smp_call_func_t func, void *info, int wait); |
| 101 | 101 | ||
| 102 | void kick_all_cpus_sync(void); | 102 | void kick_all_cpus_sync(void); |
| 103 | void wake_up_all_idle_cpus(void); | ||
| 103 | 104 | ||
| 104 | /* | 105 | /* |
| 105 | * Generic and arch helpers | 106 | * Generic and arch helpers |
| @@ -148,6 +149,7 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, | |||
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | static inline void kick_all_cpus_sync(void) { } | 151 | static inline void kick_all_cpus_sync(void) { } |
| 152 | static inline void wake_up_all_idle_cpus(void) { } | ||
| 151 | 153 | ||
| 152 | #endif /* !SMP */ | 154 | #endif /* !SMP */ |
| 153 | 155 | ||
diff --git a/kernel/smp.c b/kernel/smp.c index aff8aa14f547..9e0d0b289118 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
| 14 | #include <linux/smp.h> | 14 | #include <linux/smp.h> |
| 15 | #include <linux/cpu.h> | 15 | #include <linux/cpu.h> |
| 16 | #include <linux/sched.h> | ||
| 16 | 17 | ||
| 17 | #include "smpboot.h" | 18 | #include "smpboot.h" |
| 18 | 19 | ||
| @@ -699,3 +700,24 @@ void kick_all_cpus_sync(void) | |||
| 699 | smp_call_function(do_nothing, NULL, 1); | 700 | smp_call_function(do_nothing, NULL, 1); |
| 700 | } | 701 | } |
| 701 | EXPORT_SYMBOL_GPL(kick_all_cpus_sync); | 702 | EXPORT_SYMBOL_GPL(kick_all_cpus_sync); |
| 703 | |||
| 704 | /** | ||
| 705 | * wake_up_all_idle_cpus - break all cpus out of idle | ||
| 706 | * wake_up_all_idle_cpus try to break all cpus which is in idle state even | ||
| 707 | * including idle polling cpus, for non-idle cpus, we will do nothing | ||
| 708 | * for them. | ||
| 709 | */ | ||
| 710 | void wake_up_all_idle_cpus(void) | ||
| 711 | { | ||
| 712 | int cpu; | ||
| 713 | |||
| 714 | preempt_disable(); | ||
| 715 | for_each_online_cpu(cpu) { | ||
| 716 | if (cpu == smp_processor_id()) | ||
| 717 | continue; | ||
| 718 | |||
| 719 | wake_up_if_idle(cpu); | ||
| 720 | } | ||
| 721 | preempt_enable(); | ||
| 722 | } | ||
| 723 | EXPORT_SYMBOL_GPL(wake_up_all_idle_cpus); | ||
