From patchwork Wed May 19 01:30:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Chan X-Patchwork-Id: 100675 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4J1VOcd012192 for ; Wed, 19 May 2010 01:31:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756165Ab0ESBag (ORCPT ); Tue, 18 May 2010 21:30:36 -0400 Received: from smtp-out.google.com ([216.239.44.51]:8291 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755735Ab0ESBae (ORCPT ); Tue, 18 May 2010 21:30:34 -0400 Received: from hpaq1.eem.corp.google.com (hpaq1.eem.corp.google.com [172.25.149.1]) by smtp-out.google.com with ESMTP id o4J1USi3000618; Tue, 18 May 2010 18:30:29 -0700 Received: from mikechan.mtv.corp.google.com (mikechan.mtv.corp.google.com [172.18.102.252]) by hpaq1.eem.corp.google.com with ESMTP id o4J1UN2u019257; Tue, 18 May 2010 18:30:24 -0700 Received: by mikechan.mtv.corp.google.com (Postfix, from userid 18922) id 4019922020; Tue, 18 May 2010 18:30:23 -0700 (PDT) From: Mike Chan 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 Subject: [PATCH 2/4] omap: cpu: Implement callbacks for cpu frequency tracking in cpuacct Date: Tue, 18 May 2010 18:30:18 -0700 Message-Id: <1274232620-23003-3-git-send-email-mike@android.com> X-Mailer: git-send-email 1.7.0.1 In-Reply-To: <1274232620-23003-1-git-send-email-mike@android.com> References: <1274232620-23003-1-git-send-email-mike@android.com> X-System-Of-Record: true To: unlisted-recipients:; (no To-header on input) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 19 May 2010 01:31:24 +0000 (UTC) diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c index 6d3d333..d27234d 100644 --- a/arch/arm/plat-omap/cpu-omap.c +++ b/arch/arm/plat-omap/cpu-omap.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,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 +101,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 +135,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 +186,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) +{ + *cpuacct_data = kzalloc(sizeof(u64) * MAX_VDD1_OPP, + 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_cpufreq_calls omap_cpuacct_cpufreq = { + .init = omap_cpuacct_freq_init, + .charge = omap_cpuacct_freq_charge, + .show = omap_cpuacct_freq_show, +}; + +static int __init omap_cpuacct_init(void) +{ + freq_index = -1; + cpuacct_register_cpufreq(&omap_cpuacct_cpufreq); + return 0; +} + +early_initcall(omap_cpuacct_init); +#endif