From: Mike Chan <mike@android.com>
To: unlisted-recipients:; (no To-header on input)
Cc: menage@google.com, balbir@in.ibm.com, cpufreq@vger.kernel.org,
linux-kernel@vger.kernel.org, trenn@suse.de,
khilman@deeprootsystems.com, linux-omap@vger.kernel.org,
Mike Chan <mike@android.com>
Subject: [PATCH v2 3/3] omap: cpu: Implement callbacks for cpu frequency tracking in cpuacct
Date: Thu, 20 May 2010 11:42:24 -0700 [thread overview]
Message-ID: <1274380944-20947-4-git-send-email-mike@android.com> (raw)
In-Reply-To: <1274380944-20947-1-git-send-email-mike@android.com>
Implement OMAP platform specific scheduler callbacks for tracking
cpu frequencies per cpuacct cgroup.
Signed-off-by: Mike Chan <mike@android.com>
---
arch/arm/plat-omap/cpu-omap.c | 67 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index 6d3d333..176417a 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -21,6 +21,8 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/cpuacct.h>
#include <mach/hardware.h>
#include <plat/clock.h>
@@ -38,6 +40,10 @@ static struct cpufreq_frequency_table *freq_table;
static struct clk *mpu_clk;
+#ifdef CONFIG_CGROUP_CPUACCT
+static int freq_index;
+#endif
+
/* TODO: Add support for SDRAM timing changes */
int omap_verify_speed(struct cpufreq_policy *policy)
@@ -96,6 +102,11 @@ static int omap_target(struct cpufreq_policy *policy,
freqs.old, freqs.new);
#endif
ret = clk_set_rate(mpu_clk, freqs.new * 1000);
+#ifdef CONFIG_CGROUP_CPUACCT
+ /* Update freq_index before cpufreq transition post notification. */
+ cpufreq_frequency_table_target(policy, freq_table, freqs.new,
+ CPUFREQ_RELATION_L, &freq_index);
+#endif
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
return ret;
@@ -125,7 +136,14 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.max_freq = clk_round_rate(mpu_clk,
VERY_HI_RATE) / 1000;
}
-
+#ifdef CONFIG_CGROUP_CPUACCT
+ /*
+ * Update freq_index, since we are using the extact frequency
+ * we can use any relation.
+ */
+ cpufreq_frequency_table_target(policy, freq_table, policy->cur,
+ CPUFREQ_RELATION_L, &freq_index);
+#endif
/* FIXME: what's the actual transition time? */
policy->cpuinfo.transition_latency = 300 * 1000;
@@ -169,3 +187,50 @@ arch_initcall(omap_cpufreq_init);
* cpufreq_frequency_table_put_attr()
*/
+#ifdef CONFIG_CGROUP_CPUACCT
+/*
+ * Omap platform calls for cpuacct frequency accounting.
+ */
+
+static void omap_cpuacct_freq_init(void **cpuacct_data)
+{
+ /* MAX_VDD1_OPP is gone, define a table size to fit available values */
+ *cpuacct_data = kzalloc(sizeof(u64) * 8, GFP_KERNEL);
+}
+
+/* Called with rcu_read_lock() held. */
+static void omap_cpuacct_freq_charge(void *cpuacct_data, u64 cputime, unsigned int cpu)
+{
+ u64 *cpuacct_freq = cpuacct_data;
+ if (freq_index < 0)
+ return;
+
+ cpuacct_freq[freq_index] += cputime;
+}
+
+static void omap_cpuacct_freq_show(void *cpuacct_data, struct cgroup_map_cb *cb)
+{
+ int i;
+ char buf[32];
+ u64 *cpuacct_freq = cpuacct_data;
+ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
+ snprintf(buf, sizeof(buf), "%u", freq_table[i].frequency);
+ cb->fill(cb, buf, cpuacct_freq[i]);
+ }
+}
+
+static struct cpuacct_charge_calls omap_cpuacct_cpufreq = {
+ .init = omap_cpuacct_freq_init,
+ .charge = omap_cpuacct_freq_charge,
+ .cpufreq_show = omap_cpuacct_freq_show,
+};
+
+static int __init omap_cpuacct_init(void)
+{
+ freq_index = -1;
+ cpuacct_charge_register(&omap_cpuacct_cpufreq);
+ return 0;
+}
+
+early_initcall(omap_cpuacct_init);
+#endif
--
1.7.0.1
next prev parent reply other threads:[~2010-05-20 18:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 18:42 [PATCH v2 0/3] Enable CPU frequency and power tracking in cpuacct cgroup Mike Chan
2010-05-20 18:42 ` [PATCH v2 1/3] scheduler: cpuacct: Enable platform hooks to track cpuusage for CPU frequencies Mike Chan
2010-05-20 18:42 ` [PATCH v2 2/3] scheduler: cpuacct: Enable platform callbacks for cpuacct power tracking Mike Chan
2010-05-20 18:42 ` Mike Chan [this message]
2010-05-20 21:01 ` [PATCH v2 0/3] Enable CPU frequency and power tracking in cpuacct cgroup Thomas Renninger
2010-05-20 21:21 ` Mike Chan
2010-05-21 17:05 ` Kevin Hilman
2010-06-01 20:56 ` Mike Chan
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=1274380944-20947-4-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 \
--cc=trenn@suse.de \
/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).