Commit 43b8d157 authored by Andres Oportus's avatar Andres Oportus Committed by Vincent Zvikaramba

ANDROID: cpufreq_stat: add per task/uid/freq stats

Adds per process nodes in /proc/PID/time_in_state showing per
frequency times and adds a global /proc/uid_time_in_state
showing per frequency per uid times.

Bug: 34133340
Bug: 38320164

Tests: boot sailfish and reading /proc/uid_time_in_state and
/proc/$$/time_in_state
Signed-off-by: 's avatarAndres Oportus <andresoportus@google.com>
Change-Id: Ideb22b608b9a5e7bd2200a3a6df0f110b635f96a
parent 9da6dd3a
This diff is collapsed.
......@@ -76,6 +76,7 @@
#include <linux/printk.h>
#include <linux/cgroup.h>
#include <linux/cpuset.h>
#include <linux/cpufreq.h>
#include <linux/audit.h>
#include <linux/poll.h>
#include <linux/nsproxy.h>
......@@ -2792,6 +2793,9 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_CHECKPOINT_RESTORE
REG("timers", S_IRUGO, proc_timers_operations),
#endif
#ifdef CONFIG_CPU_FREQ_STAT
ONE("time_in_state", 0444, proc_time_in_state_show),
#endif
};
static int proc_tgid_base_readdir(struct file * filp,
......@@ -3183,6 +3187,9 @@ static const struct pid_entry tid_base_stuff[] = {
REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
REG("setgroups", S_IRUGO|S_IWUSR, proc_setgroups_operations),
#endif
#ifdef CONFIG_CPU_FREQ_STAT
ONE("time_in_state", 0444, proc_time_in_state_show),
#endif
};
static int proc_tid_base_readdir(struct file * filp,
......
......@@ -11,6 +11,7 @@
#ifndef _LINUX_CPUFREQ_H
#define _LINUX_CPUFREQ_H
#include <linux/pid_namespace.h>
#include <linux/cpumask.h>
#include <linux/completion.h>
#include <linux/kobject.h>
......@@ -498,4 +499,10 @@ static inline void acct_update_power(struct task_struct *p, cputime_t cputime) {
#endif
#define MIN_FINGER_LIMIT 1344000
void cpufreq_task_stats_init(struct task_struct *p);
void cpufreq_task_stats_exit(struct task_struct *p);
int proc_time_in_state_show(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *p);
#endif /* _LINUX_CPUFREQ_H */
......@@ -1335,6 +1335,8 @@ struct task_struct {
cputime_t utime, stime, utimescaled, stimescaled;
cputime_t gtime;
atomic64_t *time_in_state;
unsigned int max_states;
unsigned long long cpu_power;
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
struct cputime prev_cputime;
......
......@@ -53,6 +53,7 @@
#include <linux/oom.h>
#include <linux/writeback.h>
#include <linux/shm.h>
#include <linux/cpufreq.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
......@@ -172,6 +173,9 @@ void release_task(struct task_struct * p)
{
struct task_struct *leader;
int zap_leader;
#ifdef CONFIG_CPU_FREQ_STAT
cpufreq_task_stats_exit(p);
#endif
repeat:
/* don't need to get the RCU readlock here - the process is dead and
* can't be modifying its own credentials. But shut RCU-lockdep up */
......
......@@ -3438,6 +3438,10 @@ static void __sched_fork(struct task_struct *p)
memset(&p->se.statistics, 0, sizeof(p->se.statistics));
#endif
#ifdef CONFIG_CPU_FREQ_STAT
cpufreq_task_stats_init(p);
#endif
INIT_LIST_HEAD(&p->rt.run_list);
#ifdef CONFIG_PREEMPT_NOTIFIERS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment