summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMike Chan <mike@android.com>2011-10-09 02:21:22 +0100
committerAndy Green <andy.green@linaro.org>2011-10-09 02:21:22 +0100
commit51938b55fa8b7b0e457af833025c62164c79c4ff (patch)
tree1ac7b40eb030d0f3a4b4bf5668d8dca61d4b3336 /kernel
parentdc19eaeb4fa44e3265e19775118f628746da91c9 (diff)
scheduler: cpuacct: Enable platform callbacks for cpuacct power tracking
Platform must register cpu power function that return power in milliWatt seconds. Change-Id: I1caa0335e316c352eee3b1ddf326fcd4942bcbe8 Signed-off-by: Mike Chan <mike@android.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index a0118596945..27ee31e5673 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -9304,12 +9304,28 @@ static int cpuacct_cpufreq_show(struct cgroup *cgrp, struct cftype *cft,
struct cgroup_map_cb *cb)
{
struct cpuacct *ca = cgroup_ca(cgrp);
- if (ca->cpufreq_fn && ca->cpufreq_fn->show)
- ca->cpufreq_fn->show(ca->cpuacct_data, cb);
+ if (ca->cpufreq_fn && ca->cpufreq_fn->cpufreq_show)
+ ca->cpufreq_fn->cpufreq_show(ca->cpuacct_data, cb);
return 0;
}
+/* return total cpu power usage (milliWatt second) of a group */
+static u64 cpuacct_powerusage_read(struct cgroup *cgrp, struct cftype *cft)
+{
+ int i;
+ struct cpuacct *ca = cgroup_ca(cgrp);
+ u64 totalpower = 0;
+
+ if (ca->cpufreq_fn && ca->cpufreq_fn->power_usage)
+ for_each_present_cpu(i) {
+ totalpower += ca->cpufreq_fn->power_usage(
+ ca->cpuacct_data);
+ }
+
+ return totalpower;
+}
+
static struct cftype files[] = {
{
.name = "usage",
@@ -9328,6 +9344,10 @@ static struct cftype files[] = {
.name = "cpufreq",
.read_map = cpuacct_cpufreq_show,
},
+ {
+ .name = "power",
+ .read_u64 = cpuacct_powerusage_read
+ },
};
static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)