linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuansheng Liu <chuansheng.liu@intel.com>
To: peterz@infradead.org, luto@amacapital.net,
	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 <chuansheng.liu@intel.com>
Subject: [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle()
Date: Fri, 15 Aug 2014 15:01:24 +0800	[thread overview]
Message-ID: <1408086085-16691-2-git-send-email-chuansheng.liu@intel.com> (raw)
In-Reply-To: <1408086085-16691-1-git-send-email-chuansheng.liu@intel.com>

Currently using smp_call_function() just woke up the corresponding
cpu, but can not break the polling idle loop.

Here using the new sched API wake_up_if_idle() to implement it.

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
 kernel/smp.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index aff8aa1..0b647c3 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"
 
@@ -677,10 +678,6 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
 }
 EXPORT_SYMBOL(on_each_cpu_cond);
 
-static void do_nothing(void *unused)
-{
-}
-
 /**
  * kick_all_cpus_sync - Force all cpus out of idle
  *
@@ -694,8 +691,15 @@ static void do_nothing(void *unused)
  */
 void kick_all_cpus_sync(void)
 {
-	/* Make sure the change is visible before we kick the cpus */
-	smp_mb();
-	smp_call_function(do_nothing, NULL, 1);
+	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(kick_all_cpus_sync);
-- 
1.7.9.5

  reply	other threads:[~2014-08-15  7:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15  7:01 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-15  7:01 ` Chuansheng Liu [this message]
2014-08-15 15:40   ` [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle() Andy Lutomirski
2014-08-18  0:12     ` Liu, Chuansheng
2014-08-15  7:01 ` [PATCH 3/3] cpuidle: Using the kick_all_cpus_sync() to wake up all cpus Chuansheng Liu

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=1408086085-16691-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).