Commit Graph

5 Commits

Author SHA1 Message Date
Srinath Sridharan ba7c59f518 Introducing per-task/per-process cpufreq statistics.
The statistics are provided in /proc/<pid>/cpufreq_stats as a read-only
interface. This gives the amount of time spent by a task/process in
each of the frequencies on each of the CPUs. The cat output will have
"<cpu> <frequency> <time>" triplet in each line, which will mean that
a given task spent <time> usertime units of time at <frequency> on
CPU <cpu>. usertime units here is 10mS (similar to other time exported
in /proc). The statistics are available during the lifetime of the
tasks/processes.

Change-Id: I3ebb338c27020aabd6b4e258bd26981c51a57771
2016-03-02 18:02:13 -08:00
Anurag Singh 87fb7c5002 cpufreq: persistent_stats: Synchronize access to time_in_state
The cpufreq_stats_create_table function does not fully protect cpu_stats'
members with a spinlock. This change fixes that. It also performs a
null-check on freq_table in freq_table_get_index and returns -ENOENT
appropriately.

Change-Id: I301d1b23ef766a77161bab1472dc810d53b6c5fe
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2014-07-22 15:27:57 -07:00
Junjie Wu 73308b21a4 cpufreq: persistent_stats: Use correct CPU to get freq table
If a policy manages multiple CPUs, frequency table might only be
available on policy->cpu. Use the correct CPU to obtain frequency
table.

Change-Id: I3a52bb88f64df70e32e511a37d8364a0f62b507c
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-05-06 14:00:56 -07:00
Anurag Singh fa7c796bd6 cpufreq: persistent_stats: make enable node writable only by root
The 'enable' node in the sysfs structure is currently writable by all
users. This is not desirable from an access control perspective. Changing
permissions to provide write access to root only.

Change-Id: I92525cc63571607a38c7aada2a6853cf89b5b38f
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2014-03-24 18:13:46 -07:00
Anurag Singh a16e20e70e cpufreq: persistent_stats: export persistent CPU frequency data
CPU frequency statistics are lost when a CPU is put offline to save power.
Due to this behavior, there is currently no way of knowing what frequencies
a CPU ran at over the system's uptime (assuming it is hot-pluggable and was
offlined/onlined multiple times). To solve this problem, export these
statistics so that frequency residencies for all CPUs are preserved.

These statistics can be found under
/sys/devices/system/cpu/cpufreq/stats/cpuX - 'cpuX' is the CPU ID.

Following are the important nodes:
- time_in_state: reading this node would output all the frequencies the CPU
  is capable of running at and the amount of time (in jiffies) it ran at
  those frequencies
- reset: writing 1 to this node would reset all frequency time stats to 0
- enable: writing 0 or 1 to this node disables or enables stats collection,
  respectively. By default, stats collection is enabled.

Change-Id: I225ef89f7b359f1f94386f2f9445ece9d5119768
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2014-02-13 15:15:02 -08:00