Skip to content
Snippets Groups Projects
Commit 17be7005 authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by z00208928
Browse files

uid_cputime: Extends the cputime functionality to report power per uid


/proc/uid_cputime/show_uid_stats shows a third field power for each of
the uids. It represents the power in the units (uAusec)

Bug: 21498425
Change-Id: I52fdc5e59647e9dc97561a26d56f462a2689ba9c
Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent 28d41233
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,8 @@ struct uid_entry { ...@@ -38,6 +38,8 @@ struct uid_entry {
cputime_t stime; cputime_t stime;
cputime_t active_utime; cputime_t active_utime;
cputime_t active_stime; cputime_t active_stime;
unsigned long long active_power;
unsigned long long power;
struct hlist_node hash; struct hlist_node hash;
}; };
...@@ -83,6 +85,7 @@ static int uid_stat_show(struct seq_file *m, void *v) ...@@ -83,6 +85,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
hash_for_each(hash_table, bkt, uid_entry, hash) { hash_for_each(hash_table, bkt, uid_entry, hash) {
uid_entry->active_stime = 0; uid_entry->active_stime = 0;
uid_entry->active_utime = 0; uid_entry->active_utime = 0;
uid_entry->active_power = 0;
} }
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
...@@ -100,6 +103,7 @@ static int uid_stat_show(struct seq_file *m, void *v) ...@@ -100,6 +103,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
task_cputime_adjusted(task, &utime, &stime); task_cputime_adjusted(task, &utime, &stime);
uid_entry->active_utime += utime; uid_entry->active_utime += utime;
uid_entry->active_stime += stime; uid_entry->active_stime += stime;
uid_entry->active_power += task->cpu_power;
} }
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
...@@ -108,9 +112,12 @@ static int uid_stat_show(struct seq_file *m, void *v) ...@@ -108,9 +112,12 @@ static int uid_stat_show(struct seq_file *m, void *v)
uid_entry->active_utime; uid_entry->active_utime;
cputime_t total_stime = uid_entry->stime + cputime_t total_stime = uid_entry->stime +
uid_entry->active_stime; uid_entry->active_stime;
seq_printf(m, "%d: %u %u\n", uid_entry->uid, unsigned long long total_power = uid_entry->power +
uid_entry->active_power;
seq_printf(m, "%d: %u %u %llu\n", uid_entry->uid,
cputime_to_usecs(total_utime), cputime_to_usecs(total_utime),
cputime_to_usecs(total_stime)); cputime_to_usecs(total_stime),
total_power);
} }
mutex_unlock(&uid_lock); mutex_unlock(&uid_lock);
...@@ -203,6 +210,7 @@ static int process_notifier(struct notifier_block *self, ...@@ -203,6 +210,7 @@ static int process_notifier(struct notifier_block *self,
task_cputime_adjusted(task, &utime, &stime); task_cputime_adjusted(task, &utime, &stime);
uid_entry->utime += utime; uid_entry->utime += utime;
uid_entry->stime += stime; uid_entry->stime += stime;
uid_entry->power += task->cpu_power;
exit: exit:
mutex_unlock(&uid_lock); mutex_unlock(&uid_lock);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment