From patchwork Wed May 19 01:30:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Chan X-Patchwork-Id: 100679 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 o4J1Vh1I012276 for ; Wed, 19 May 2010 01:31:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756489Ab0ESBbO (ORCPT ); Tue, 18 May 2010 21:31:14 -0400 Received: from smtp-out.google.com ([74.125.121.35]:10981 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755838Ab0ESBag (ORCPT ); Tue, 18 May 2010 21:30:36 -0400 Received: from kpbe14.cbf.corp.google.com (kpbe14.cbf.corp.google.com [172.25.105.78]) by smtp-out.google.com with ESMTP id o4J1UQhX027035; Tue, 18 May 2010 18:30:26 -0700 Received: from mikechan.mtv.corp.google.com (mikechan.mtv.corp.google.com [172.18.102.252]) by kpbe14.cbf.corp.google.com with ESMTP id o4J1UNGB010286; Tue, 18 May 2010 18:30:23 -0700 Received: by mikechan.mtv.corp.google.com (Postfix, from userid 18922) id 49E0F223B7; 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 4/4] omap: cpu: Power tracking support for cgroup cpuacct Date: Tue, 18 May 2010 18:30:20 -0700 Message-Id: <1274232620-23003-5-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:43 +0000 (UTC) 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 #include #include +#include #include #include @@ -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;