diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-01-06 10:39:05 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-01-23 17:06:44 -0500 |
commit | 2aba0c1bae564a59fc38c407abf7985f9e347cc4 (patch) | |
tree | 187084e0c331a68ca46754f57c868764032401f7 /drivers/cpufreq | |
parent | f93dbbbd108936b18b3230af36d9a36866ce69a7 (diff) |
cpufreq: stats: pass 'stat' to cpufreq_stats_update()
It is better to pass a struct cpufreq_stats pointer to cpufreq_stats_update()
instead of a CPU number, because that's all it needs.
Even if we pass a cpu number to cpufreq_stats_update(), it reads the per-cpu
variable to get 'stats' out of it. So we are doing these operations
unnecessarily:
- First getting the cpu number to pass to cpufreq_stats_update(), stat->cpu.
- And then getting stats from the cpu, per_cpu(cpufreq_stats_table, cpu).
Reviewed-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index e9d68420b876..6c234f548601 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -33,13 +33,11 @@ struct cpufreq_stats { | |||
33 | 33 | ||
34 | static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table); | 34 | static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table); |
35 | 35 | ||
36 | static int cpufreq_stats_update(unsigned int cpu) | 36 | static int cpufreq_stats_update(struct cpufreq_stats *stat) |
37 | { | 37 | { |
38 | struct cpufreq_stats *stat; | ||
39 | unsigned long long cur_time = get_jiffies_64(); | 38 | unsigned long long cur_time = get_jiffies_64(); |
40 | 39 | ||
41 | spin_lock(&cpufreq_stats_lock); | 40 | spin_lock(&cpufreq_stats_lock); |
42 | stat = per_cpu(cpufreq_stats_table, cpu); | ||
43 | if (stat->time_in_state) | 41 | if (stat->time_in_state) |
44 | stat->time_in_state[stat->last_index] += | 42 | stat->time_in_state[stat->last_index] += |
45 | cur_time - stat->last_time; | 43 | cur_time - stat->last_time; |
@@ -64,7 +62,7 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) | |||
64 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); | 62 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); |
65 | if (!stat) | 63 | if (!stat) |
66 | return 0; | 64 | return 0; |
67 | cpufreq_stats_update(stat->cpu); | 65 | cpufreq_stats_update(stat); |
68 | for (i = 0; i < stat->state_num; i++) { | 66 | for (i = 0; i < stat->state_num; i++) { |
69 | len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], | 67 | len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], |
70 | (unsigned long long) | 68 | (unsigned long long) |
@@ -82,7 +80,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
82 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); | 80 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); |
83 | if (!stat) | 81 | if (!stat) |
84 | return 0; | 82 | return 0; |
85 | cpufreq_stats_update(stat->cpu); | 83 | cpufreq_stats_update(stat); |
86 | len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); | 84 | len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); |
87 | len += snprintf(buf + len, PAGE_SIZE - len, " : "); | 85 | len += snprintf(buf + len, PAGE_SIZE - len, " : "); |
88 | for (i = 0; i < stat->state_num; i++) { | 86 | for (i = 0; i < stat->state_num; i++) { |
@@ -307,7 +305,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb, | |||
307 | if (old_index == -1 || new_index == -1) | 305 | if (old_index == -1 || new_index == -1) |
308 | return 0; | 306 | return 0; |
309 | 307 | ||
310 | cpufreq_stats_update(freq->cpu); | 308 | cpufreq_stats_update(stat); |
311 | 309 | ||
312 | if (old_index == new_index) | 310 | if (old_index == new_index) |
313 | return 0; | 311 | return 0; |