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: Ruchi Kandoi <kandoiruchi@google.com>
Git-commit: d17e7e2771a3998c2514de082be588522625618e
Git-repo: https://android.googlesource.com/kernel/msm/
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
This commit is contained in:
Ruchi Kandoi
2015-11-30 12:58:19 +05:30
committed by Srinivasarao P
parent c997826cef
commit f49d0f7761
+10 -2
View File
@@ -38,6 +38,8 @@ struct uid_entry {
cputime_t stime;
cputime_t active_utime;
cputime_t active_stime;
unsigned long long active_power;
unsigned long long power;
struct hlist_node hash;
};
@@ -83,6 +85,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
hash_for_each(hash_table, bkt, node, uid_entry, hash) {
uid_entry->active_stime = 0;
uid_entry->active_utime = 0;
uid_entry->active_power = 0;
}
read_lock(&tasklist_lock);
@@ -97,6 +100,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
}
uid_entry->active_utime += task->utime;
uid_entry->active_stime += task->stime;
uid_entry->active_power += task->cpu_power;
}
read_unlock(&tasklist_lock);
@@ -105,9 +109,12 @@ static int uid_stat_show(struct seq_file *m, void *v)
uid_entry->active_utime;
cputime_t total_stime = uid_entry->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_stime));
cputime_to_usecs(total_stime),
total_power);
}
mutex_unlock(&uid_lock);
@@ -199,6 +206,7 @@ static int process_notifier(struct notifier_block *self,
uid_entry->utime += task->utime;
uid_entry->stime += task->stime;
uid_entry->power += task->cpu_power;
exit:
mutex_unlock(&uid_lock);