linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuansheng Liu <chuansheng.liu@intel.com>
To: luto@amacapital.net, peterz@infradead.org,
	daniel.lezcano@linaro.org, rjw@rjwysocki.net, mingo@redhat.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	changcheng.liu@intel.com, xiaoming.wang@intel.com,
	souvik.k.chakravarty@intel.com, chuansheng.liu@intel.com
Subject: [PATCH 2/3] smp: Adding new function wake_up_all_cpus()
Date: Mon, 18 Aug 2014 16:37:31 +0800	[thread overview]
Message-ID: <1408351052-25075-2-git-send-email-chuansheng.liu@intel.com> (raw)
In-Reply-To: <1408351052-25075-1-git-send-email-chuansheng.liu@intel.com>

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_cpus() to let all cpus out
of idle based on function wake_up_if_idle().

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
 include/linux/smp.h |    2 ++
 kernel/smp.c        |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/linux/smp.h b/include/linux/smp.h
index 34347f2..1cfb1fd 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -100,6 +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_cpus(void);
 
 /*
  * Generic and arch helpers
@@ -148,6 +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_cpus(void) {  }
 
 #endif /* !SMP */
 
diff --git a/kernel/smp.c b/kernel/smp.c
index aff8aa1..1e69507 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -13,6 +13,7 @@
 #include <linux/gfp.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
+#include <linux/sched.h>
 
 #include "smpboot.h"
 
@@ -699,3 +700,24 @@ void kick_all_cpus_sync(void)
 	smp_call_function(do_nothing, NULL, 1);
 }
 EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
+
+/**
+ * wake_up_all_cpus - break all cpus out of idle
+ * wake_up_all_cpus try to break all 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_cpus(void)
+{
+	int cpu;
+
+	preempt_disable();
+	for_each_online_cpu(cpu) {
+		if (cpu == smp_processor_id())
+			continue;
+
+		wake_up_if_idle(cpu);
+	}
+	preempt_enable();
+}
+EXPORT_SYMBOL_GPL(wake_up_all_cpus);
-- 
1.7.9.5


  reply	other threads:[~2014-08-18  8:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18  8:37 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-18  8:37 ` Chuansheng Liu [this message]
2014-09-03  9:52   ` [PATCH 2/3] smp: Adding new function wake_up_all_cpus() Peter Zijlstra
2014-08-18  8:37 ` [PATCH 3/3] cpuidle: Using the wake_up_all_cpus() to wake up all idle cpus Chuansheng Liu
2014-08-21  1:54 ` [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Daniel Lezcano
2014-08-21  2:12   ` Liu, Chuansheng
2014-08-21  3:48     ` Daniel Lezcano
2014-08-21 21:21 ` Andy Lutomirski
2014-09-03  9:54   ` Peter Zijlstra
2014-09-03  9:58     ` Liu, Chuansheng
2014-09-03  9:51 ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408351052-25075-2-git-send-email-chuansheng.liu@intel.com \
    --to=chuansheng.liu@intel.com \
    --cc=changcheng.liu@intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=souvik.k.chakravarty@intel.com \
    --cc=xiaoming.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).