mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonghwa Lee <jonghwa3.lee@samsung.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	cpufreq@vger.kernel.org, MyungJoo Ham <myungjoo.ham@samsung.com>,
	Lukasz Majewski <l.majewski@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	sw0312.kim@samsung.com, m.szyprowski@samsung.com,
	Jonghwa Lee <jonghwa3.lee@samsung.com>
Subject: [RFC PATCH 1/2] cpuidle: Add idle enter/exit time stamp for notifying current idle state.
Date: Mon, 01 Apr 2013 17:24:16 +0900	[thread overview]
Message-ID: <1364804657-16590-2-git-send-email-jonghwa3.lee@samsung.com> (raw)
In-Reply-To: <1364804657-16590-1-git-send-email-jonghwa3.lee@samsung.com>

This patch adds idle state time stamp to cpuidle device structure to
notify its current idle state. If last enter time is newer than last
exit time, then it means that the core is in idle now.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
---
 drivers/cpuidle/cpuidle.c |    8 ++++----
 include/linux/cpuidle.h   |    4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index eba6929..1e830cc 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -233,18 +233,18 @@ int cpuidle_wrap_enter(struct cpuidle_device *dev,
 				int (*enter)(struct cpuidle_device *dev,
 					struct cpuidle_driver *drv, int index))
 {
-	ktime_t time_start, time_end;
 	s64 diff;
 
-	time_start = ktime_get();
+	dev->last_idle_start = ktime_get();
 
 	index = enter(dev, drv, index);
 
-	time_end = ktime_get();
+	dev->last_idle_end = ktime_get();
 
 	local_irq_enable();
 
-	diff = ktime_to_us(ktime_sub(time_end, time_start));
+	diff = ktime_to_us(ktime_sub(dev->last_idle_end,
+				dev->last_idle_start));
 	if (diff > INT_MAX)
 		diff = INT_MAX;
 
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 480c14d..d1af05f 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -16,6 +16,7 @@
 #include <linux/kobject.h>
 #include <linux/completion.h>
 #include <linux/hrtimer.h>
+#include <linux/ktime.h>
 
 #define CPUIDLE_STATE_MAX	8
 #define CPUIDLE_NAME_LEN	16
@@ -74,6 +75,9 @@ struct cpuidle_device {
 	struct kobject		kobj;
 	struct completion	kobj_unregister;
 
+	ktime_t			last_idle_start;
+	ktime_t			last_idle_end;
+
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
 	int			safe_state_index;
 	cpumask_t		coupled_cpus;
-- 
1.7.9.5


  reply	other threads:[~2013-04-01  8:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01  8:24 [RFC PATCH 0/2] cpufreq: Introduce LAB cpufreq governor Jonghwa Lee
2013-04-01  8:24 ` Jonghwa Lee [this message]
2013-04-02  5:00   ` [RFC PATCH 1/2] cpuidle: Add idle enter/exit time stamp for notifying current idle state Daniel Lezcano
2013-04-02  6:17     ` jonghwa3.lee
2013-04-02  7:34       ` Daniel Lezcano
2013-04-02  9:37         ` jonghwa3.lee
2013-04-02 10:08           ` Daniel Lezcano
2013-04-02 11:07             ` jonghwa3.lee
2013-04-02 11:18               ` Daniel Lezcano
2013-04-03  6:10                 ` jonghwa3.lee
2013-04-01  8:24 ` [RFC PATCH 2/2] cpufreq: Introduce new cpufreq governor, LAB(Legacy Application Boost) Jonghwa Lee
2013-04-01 15:37 ` [RFC PATCH 0/2] cpufreq: Introduce LAB cpufreq governor Viresh Kumar
2013-04-09 10:37   ` Lukasz Majewski
2013-04-09 12:02     ` Viresh Kumar
2013-04-09 16:44       ` Lukasz Majewski
     [not found]         ` <CAKfTPtD6MK9ogq7mOijSxLSsH0n65Xra48XfRSB3DFs35GT=2g@mail.gmail.com>
2013-04-10  6:56           ` Vincent Guittot
2013-04-10  8:44           ` Lukasz Majewski
2013-04-10  9:13             ` Vincent Guittot
2013-04-10  9:38               ` Lukasz Majewski
2013-04-10 10:45                 ` Vincent Guittot
2013-04-10 10:14             ` Lorenzo Pieralisi
2013-04-09 12:25     ` jonghwa3.lee

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=1364804657-16590-2-git-send-email-jonghwa3.lee@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.majewski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=rjw@sisk.pl \
    --cc=sw0312.kim@samsung.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

all inboxes | Powered by JetHome®