linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Chuansheng Liu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, torvalds@linux-foundation.org, jack@suse.cz,
	geert+renesas@glider.be, peterz@infradead.org,
	fweisbec@gmail.com, akpm@linux-foundation.org, axboe@fb.com,
	tglx@linutronix.de, klamm@yandex-team.ru,
	chuansheng.liu@intel.com, linux-kernel@vger.kernel.org,
	hpa@zytor.com, axboe@kernel.dk, srivatsa.bhat@linux.vnet.ibm.com,
	hch@infradead.org, mhocko@suse.cz, paul.gortmaker@windriver.com
Subject: [tip:sched/core] smp: Add new wake_up_all_idle_cpus() function
Date: Fri, 19 Sep 2014 04:44:00 -0700	[thread overview]
Message-ID: <tip-c6f4459fc3ba532e896cb678e29b45cb985f82bf@git.kernel.org> (raw)
In-Reply-To: <1409815075-4180-2-git-send-email-chuansheng.liu@intel.com>

Commit-ID:  c6f4459fc3ba532e896cb678e29b45cb985f82bf
Gitweb:     http://git.kernel.org/tip/c6f4459fc3ba532e896cb678e29b45cb985f82bf
Author:     Chuansheng Liu <chuansheng.liu@intel.com>
AuthorDate: Thu, 4 Sep 2014 15:17:54 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 19 Sep 2014 12:35:15 +0200

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>
---
 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..93dff5f 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_idle_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_idle_cpus(void) {  }
 
 #endif /* !SMP */
 
diff --git a/kernel/smp.c b/kernel/smp.c
index aff8aa1..9e0d0b2 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_idle_cpus - break all cpus out of idle
+ * wake_up_all_idle_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_idle_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_idle_cpus);

  parent reply	other threads:[~2014-09-19 11:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04  7:17 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-09-04  7:17 ` [PATCH 2/3] smp: Adding new function wake_up_all_idle_cpus() Chuansheng Liu
2014-09-04 12:56   ` Daniel Lezcano
2014-09-19 11:44   ` tip-bot for Chuansheng Liu [this message]
2014-09-04  7:17 ` [PATCH 3/3] cpuidle: Using the wake_up_all_idle_cpus() to wake up all idle cpus Chuansheng Liu
2014-09-04 13:01   ` Daniel Lezcano
2014-09-04 13:39     ` Liu, Chuansheng
2014-09-04 15:47       ` Peter Zijlstra
2014-09-19 11:44   ` [tip:sched/core] cpuidle: Use " tip-bot for Chuansheng Liu
2014-09-04 12:53 ` [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Daniel Lezcano
2014-09-04 12:59   ` Liu, Chuansheng
2014-09-19 11:43 ` [tip:sched/core] " tip-bot for Chuansheng Liu
2014-12-19 20:23   ` Andy Lutomirski

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=tip-c6f4459fc3ba532e896cb678e29b45cb985f82bf@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@fb.com \
    --cc=axboe@kernel.dk \
    --cc=chuansheng.liu@intel.com \
    --cc=fweisbec@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jack@suse.cz \
    --cc=klamm@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=mingo@kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=peterz@infradead.org \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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).