diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2015-04-17 16:33:29 -0700 |
---|---|---|
committer | Ruchi Kandoi <kandoiruchi@google.com> | 2015-06-01 17:14:48 +0000 |
commit | 85a6bd2bc4c903df43186e6f41209746aa6fdf05 (patch) | |
tree | 0693c8a1285e1a3d86055b6c080ed4a5fe1b92e8 /kernel | |
parent | 8d12562a74922eac859dcec9c43d34d8fd1a9fd1 (diff) | |
download | edison-v3.10-85a6bd2bc4c903df43186e6f41209746aa6fdf05.tar.gz |
sched: cpufreq: Adds a field cpu_power in the task_struct
cpu_power has been added to keep track of amount of power each task is
consuming. cpu_power is updated whenever stime and utime are updated for
a task. power is computed by taking into account the frequency at which
the current core was running and the current for cpu actively
running at hat frequency.
Change-Id: Ic535941e7b339aab5cae9081a34049daeb44b248
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 1 | ||||
-rw-r--r-- | kernel/sched/cputime.c | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 0ff07d94e07..52bde0c3ed9 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1297,6 +1297,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->utime = p->stime = p->gtime = 0; p->utimescaled = p->stimescaled = 0; + p->cpu_power = 0; #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE p->prev_cputime.utime = p->prev_cputime.stime = 0; #endif diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index b5ccba22603..cc211d01f77 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -1,3 +1,4 @@ +#include <linux/cpufreq.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/tsacct_kern.h> @@ -149,6 +150,9 @@ void account_user_time(struct task_struct *p, cputime_t cputime, /* Account for user time used */ acct_account_cputime(p); + + /* Account power usage for user time */ + acct_update_power(p, cputime); } /* @@ -199,6 +203,9 @@ void __account_system_time(struct task_struct *p, cputime_t cputime, /* Account for system time used */ acct_account_cputime(p); + + /* Account power usage for system time */ + acct_update_power(p, cputime); } /* |