mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: linux-kernel@vger.kernel.org, mingo@elte.hu, peterz@infradead.org
Cc: rjw@rjwysocki.net, nicolas.pitre@linaro.org,
	linux-pm@vger.kernel.org, alex.shi@linaro.org,
	vincent.guittot@linaro.org, morten.rasmussen@arm.com
Subject: [RFC PATCHC 2/3] idle: store the idle state the cpu is
Date: Fri, 28 Mar 2014 13:29:55 +0100	[thread overview]
Message-ID: <1396009796-31598-3-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1396009796-31598-1-git-send-email-daniel.lezcano@linaro.org>

When the cpu enters idle it stores the cpuidle power info in the struct
rq which in turn could be used to take a right decision when balancing
a task.

As soon as the cpu exits the idle state, the structure is filled with the
NULL pointer.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 kernel/sched/idle.c  |   17 +++++++++++++++--
 kernel/sched/sched.h |    5 +++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 8f4390a..5c32c11 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -12,6 +12,8 @@
 
 #include <trace/events/power.h>
 
+#include "sched.h"
+
 static int __read_mostly cpu_idle_force_poll;
 
 void cpu_idle_poll_ctrl(bool enable)
@@ -69,7 +71,7 @@ void __weak arch_cpu_idle(void)
  * NOTE: no locks or semaphores should be used here
  * return non-zero on failure
  */
-static int cpuidle_idle_call(void)
+static int cpuidle_idle_call(struct cpuidle_power **power)
 {
 	struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
 	struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
@@ -143,6 +145,10 @@ static int cpuidle_idle_call(void)
 			if (!ret) {
 				trace_cpu_idle_rcuidle(next_state, dev->cpu);
 
+				*power = &drv->states[next_state].power;
+
+				wmb();
+
 				/*
 				 * Enter the idle state previously
 				 * returned by the governor
@@ -154,6 +160,10 @@ static int cpuidle_idle_call(void)
 				entered_state = cpuidle_enter(drv, dev,
 							      next_state);
 
+				*power = NULL;
+
+				wmb();
+
 				trace_cpu_idle_rcuidle(PWR_EVENT_EXIT,
 						       dev->cpu);
 
@@ -198,6 +208,9 @@ static int cpuidle_idle_call(void)
  */
 static void cpu_idle_loop(void)
 {
+	struct rq *rq = this_rq();
+	struct cpuidle_power **power = &rq->power;
+
 	while (1) {
 		tick_nohz_idle_enter();
 
@@ -223,7 +236,7 @@ static void cpu_idle_loop(void)
 			if (cpu_idle_force_poll || tick_check_broadcast_expired())
 				cpu_idle_poll();
 			else
-				cpuidle_idle_call();
+				cpuidle_idle_call(power);
 
 			arch_cpu_idle_exit();
 		}
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1929deb..1bcac35 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -14,6 +14,7 @@
 #include "cpuacct.h"
 
 struct rq;
+struct cpuidle_power;
 
 extern __read_mostly int scheduler_running;
 
@@ -632,6 +633,10 @@ struct rq {
 #ifdef CONFIG_SMP
 	struct llist_head wake_list;
 #endif
+
+#ifdef CONFIG_CPU_IDLE
+	struct cpuidle_power *power;
+#endif
 };
 
 static inline int cpu_of(struct rq *rq)
-- 
1.7.9.5


  parent reply	other threads:[~2014-03-28 12:29 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 12:29 [RFC PATCHC 0/3] sched/idle : find the idlest cpu with cpuidle info Daniel Lezcano
2014-03-28 12:29 ` [RFC PATCHC 1/3] cpuidle: encapsulate power info in a separate structure Daniel Lezcano
2014-03-28 18:17   ` Nicolas Pitre
2014-03-28 20:42     ` Daniel Lezcano
2014-03-29  0:00       ` Nicolas Pitre
2014-03-28 12:29 ` Daniel Lezcano [this message]
2014-04-15 12:43   ` [RFC PATCHC 2/3] idle: store the idle state the cpu is Peter Zijlstra
2014-04-15 12:44     ` Peter Zijlstra
2014-04-15 14:17       ` Daniel Lezcano
2014-04-15 14:33         ` Peter Zijlstra
2014-04-15 14:39           ` Daniel Lezcano
2014-03-28 12:29 ` [RFC PATCHC 3/3] sched/fair: use the idle state info to choose the idlest cpu Daniel Lezcano
2014-04-02  3:05   ` Nicolas Pitre
2014-04-04 11:57     ` Rafael J. Wysocki
2014-04-04 16:56       ` Nicolas Pitre
2014-04-05  2:01         ` Rafael J. Wysocki
2014-04-17 13:53     ` Daniel Lezcano
2014-04-17 14:47       ` Peter Zijlstra
2014-04-17 15:03         ` Daniel Lezcano
2014-04-18  8:09           ` Ingo Molnar
2014-04-18  8:36             ` Daniel Lezcano
2014-04-17 15:53       ` Nicolas Pitre
2014-04-17 16:05         ` Daniel Lezcano
2014-04-17 16:21           ` Nicolas Pitre
2014-04-18  9:38             ` Peter Zijlstra
2014-04-18 12:13               ` Daniel Lezcano
2014-04-18 12:53                 ` Peter Zijlstra
2014-04-18 13:04                   ` Daniel Lezcano
2014-04-18 16:00                     ` Nicolas Pitre
2014-04-15 13:03   ` Peter Zijlstra
2014-03-31 13:52 ` [RFC PATCHC 0/3] sched/idle : find the idlest cpu with cpuidle info Vincent Guittot
2014-03-31 15:55   ` Daniel Lezcano
2014-04-01  7:16     ` Vincent Guittot
2014-04-01  7:43       ` Daniel Lezcano
2014-04-01  9:05         ` Vincent Guittot
2014-04-15 13:13           ` Peter Zijlstra
2014-04-01 23:01 ` Rafael J. Wysocki
2014-04-02  3:14   ` Nicolas Pitre
2014-04-04 11:43     ` Rafael J. Wysocki
2014-04-15 13:17       ` Peter Zijlstra
2014-04-15 13:25       ` Peter Zijlstra
2014-04-15 15:27         ` Nicolas Pitre
2014-04-15 15:33         ` Rafael J. Wysocki
2014-04-02  8:26   ` Daniel Lezcano
2014-04-04 11:23     ` Rafael J. Wysocki
2014-04-04  6:29 ` Len Brown
2014-04-04  8:16   ` Daniel Lezcano

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=1396009796-31598-3-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=alex.shi@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=morten.rasmussen@arm.com \
    --cc=nicolas.pitre@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.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

Powered by JetHome