public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuansheng Liu <chuansheng.liu@intel.com>
To: rjw@rjwysocki.net, daniel.lezcano@linaro.org
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] cpuidle: Fix the CPU stuck at C0 for 2-3s after PM_QOS back to DEFAULT
Date: Thu, 14 Aug 2014 10:11:49 +0800	[thread overview]
Message-ID: <1407982309-4863-1-git-send-email-chuansheng.liu@intel.com> (raw)

We found sometimes even after we let PM_QOS back to DEFAULT,
the CPU still stuck at C0 for 2-3s, don't do the new suitable C-state
selection immediately after received the IPI interrupt.

The code model is simply like below:
{
	pm_qos_update_request(&pm_qos, C1 - 1);
		< == Here keep all cores at C0
	...;
	pm_qos_update_request(&pm_qos, PM_QOS_DEFAULT_VALUE);
		< == Here some cores still stuck at C0 for 2-3s
}

The reason is when pm_qos come back to DEFAULT, there is IPI interrupt to
wake up the core, but when core is in poll idle state, the IPI interrupt
can not break the polling loop.

So here in the IPI callback interrupt, when currently the idle task is
running, we need to forcedly set reschedule bit to break the polling loop,
as for other non-polling idle state, IPI interrupt can break them directly,
and setting reschedule bit has no harm for them too.

With this fix, we saved about 30mV power in our android platform.

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
 drivers/cpuidle/cpuidle.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index ee9df5e..9e28a13 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -532,7 +532,13 @@ EXPORT_SYMBOL_GPL(cpuidle_register);
 
 static void smp_callback(void *v)
 {
-	/* we already woke the CPU up, nothing more to do */
+	/* we already woke the CPU up, and when the corresponding
+	 * CPU is at polling idle state, we need to set the sched
+	 * bit to trigger reselect the new suitable C-state, it
+	 * will be helpful for power.
+	*/
+	if (is_idle_task(current))
+		set_tsk_need_resched(current);
 }
 
 /*
-- 
1.7.9.5

             reply	other threads:[~2014-08-14  2:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-14  2:11 Chuansheng Liu [this message]
     [not found] ` <CAKnoXLw3DrBAxCUWEkXtvCTf+E1w0xTHJSiSUY6Qd6xHXeGaoQ@mail.gmail.com>
2014-08-14 10:53   ` [PATCH] cpuidle: Fix the CPU stuck at C0 for 2-3s after PM_QOS back to DEFAULT Peter Zijlstra
2014-08-14 11:24     ` Liu, Chuansheng
2014-08-14 13:13       ` Peter Zijlstra
2014-08-14 14:10         ` Liu, Chuansheng
2014-08-14 14:17           ` Daniel Lezcano
2014-08-14 14:26             ` Liu, Chuansheng
2014-08-14 11:00   ` Peter Zijlstra
2014-08-14 11:14     ` Daniel Lezcano
2014-08-14 11:17       ` Liu, Chuansheng
2014-08-14 12:41       ` Peter Zijlstra
2014-08-14 13:29         ` Daniel Lezcano
2014-08-14 13:57           ` Liu, Chuansheng
2014-08-14 21:12       ` Andy Lutomirski
2014-08-14 21:16         ` Peter Zijlstra
2014-08-14 21:22           ` Andy Lutomirski
2014-08-15  1:21             ` Liu, Chuansheng
2014-08-15  1:27               ` 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=1407982309-4863-1-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=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