linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Chan <mike@android.com>
To: unlisted-recipients:; (no To-header on input)
Cc: khilman@deeprootsystems.com, menage@google.com,
	balbir@in.ibm.com, cpufreq@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	Mike Chan <mike@android.com>
Subject: [PATCH 4/4] omap: cpu: Power tracking support for cgroup cpuacct
Date: Tue, 18 May 2010 18:30:20 -0700	[thread overview]
Message-ID: <1274232620-23003-5-git-send-email-mike@android.com> (raw)
In-Reply-To: <1274232620-23003-1-git-send-email-mike@android.com>

Specify new power field in struct omap_opp, which is
power exported in milliWatt.

power_usage function gives power consumed in milliWatt seconds

Signed-off-by: Mike Chan <mike@android.com>
---
 arch/arm/plat-omap/cpu-omap.c             |   23 ++++++++++++++++++++++-
 arch/arm/plat-omap/include/plat/omap-pm.h |    1 +
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index d27234d..1381539 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -22,6 +22,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpuacct.h>
+#include <linux/math64.h>
 
 #include <mach/hardware.h>
 #include <plat/clock.h>
@@ -218,10 +219,30 @@ static void omap_cpuacct_freq_show(void *cpuacct_data, struct cgroup_map_cb *cb)
 	}
 }
 
+
+/* Returns power (in milliWatt seconds) for cgroup */
+static u64 omap_cpuacct_power_usage(void *cpuacct_data)
+{
+	int i;
+	u64 *cpuacct_freq = cpuacct_data;
+	u64 totalpower = 0;
+
+	/* mpu_opps table starts at 1 */
+	for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
+		totalpower += cpuacct_freq[i] * mpu_opps[i + 1].power;
+
+	/* milliwatt seconds */
+	totalpower = div64_u64(totalpower, NSEC_PER_SEC);
+
+	return totalpower;
+}
+
+
 static struct cpuacct_cpufreq_calls omap_cpuacct_cpufreq = {
 	.init = omap_cpuacct_freq_init,
 	.charge = omap_cpuacct_freq_charge,
-	.show = omap_cpuacct_freq_show,
+	.cpufreq_show = omap_cpuacct_freq_show,
+	.power_usage = omap_cpuacct_power_usage,
 };
 
 static int __init omap_cpuacct_init(void)
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index 3ee41d7..8f2db6f 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -31,6 +31,7 @@ struct omap_opp {
 	unsigned long rate;
 	u8 opp_id;
 	u16 min_vdd;
+	unsigned long power; /* power consumed running at OPP in milliWatts */
 };
 
 extern struct omap_opp *mpu_opps;
-- 
1.7.0.1


  parent reply	other threads:[~2010-05-19  1:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19  1:30 [PATCH 0/4] Enable cpu frequency and power tracking for cpuacct cgroup Mike Chan
2010-05-19  1:30 ` [PATCH 1/4] scheduler: cpuacct: Enable platform hooks to track cpuusage for CPU frequencies Mike Chan
2010-05-19  1:30 ` [PATCH 2/4] omap: cpu: Implement callbacks for cpu frequency tracking in cpuacct Mike Chan
2010-05-19  1:30 ` [PATCH 3/4] scheduler: cpuacct: Enable platform callbacks for cpuacct power tracking Mike Chan
2010-05-19  9:30   ` [PATCH] scheduler: Extract cgroups_cpuaccount code from sched.c into own file Thomas Renninger
2010-05-19  9:37     ` Peter Zijlstra
2010-05-19 10:27       ` Peter Zijlstra
2010-05-19 18:58         ` scheduler: cleanup sched.c and extract cgroup_cpuaccount stuff into separate file Thomas Renninger
2010-05-19 18:58         ` [PATCH 1/2] scheduler: Extract cgroups_cpuaccount code from sched.c into own file V2 Thomas Renninger
2010-05-19 18:58         ` [PATCH 2/2] scheduler: cgroups cpuaccouting: Make cpuusage atomic Thomas Renninger
2010-05-19 19:02           ` Peter Zijlstra
2010-05-19 19:13             ` Thomas Renninger
2010-05-19 19:31               ` Mike Chan
2010-05-20 10:53             ` Thomas Renninger
2010-05-20  0:43           ` KAMEZAWA Hiroyuki
2010-05-19 19:06     ` [PATCH] scheduler: Extract cgroups_cpuaccount code from sched.c into own file Mike Chan
2010-05-19  1:30 ` Mike Chan [this message]
2010-05-19 13:11   ` [PATCH 4/4] omap: cpu: Power tracking support for cgroup cpuacct Nishanth Menon
2010-05-19 15:34     ` Thomas Renninger
2010-05-19 18:56       ` Mike Chan
2010-05-19 19:00         ` Nishanth Menon

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=1274232620-23003-5-git-send-email-mike@android.com \
    --to=mike@android.com \
    --cc=balbir@in.ibm.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=menage@google.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).