aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>2005-05-25 17:46:50 -0400
committerDave Jones <davej@redhat.com>2005-05-31 22:04:05 -0400
commit58f1df25403988b73d7129fcd2c4d4c24017f1af (patch)
tree2ac97023a131c5d5c32e46dd13f53f9ab989ce92 /drivers/cpufreq
parentf94ea640a28230f82a4395c34e1290748a9f6586 (diff)
[PATCH] cpufreq-stats driver updates
Changes to the cpufreq stats driver: * Changes the way P-state transition table looks in /sysfs providing more clear output * Changes the time unit in the output from HZ to clock_t Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 2084593937c6..741b6b191e6a 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -19,6 +19,7 @@
19#include <linux/percpu.h> 19#include <linux/percpu.h>
20#include <linux/kobject.h> 20#include <linux/kobject.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <asm/cputime.h>
22 23
23static spinlock_t cpufreq_stats_lock; 24static spinlock_t cpufreq_stats_lock;
24 25
@@ -29,20 +30,14 @@ static struct freq_attr _attr_##_name = {\
29 .show = _show,\ 30 .show = _show,\
30}; 31};
31 32
32static unsigned long
33delta_time(unsigned long old, unsigned long new)
34{
35 return (old > new) ? (old - new): (new + ~old + 1);
36}
37
38struct cpufreq_stats { 33struct cpufreq_stats {
39 unsigned int cpu; 34 unsigned int cpu;
40 unsigned int total_trans; 35 unsigned int total_trans;
41 unsigned long long last_time; 36 unsigned long long last_time;
42 unsigned int max_state; 37 unsigned int max_state;
43 unsigned int state_num; 38 unsigned int state_num;
44 unsigned int last_index; 39 unsigned int last_index;
45 unsigned long long *time_in_state; 40 cputime64_t *time_in_state;
46 unsigned int *freq_table; 41 unsigned int *freq_table;
47#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 42#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
48 unsigned int *trans_table; 43 unsigned int *trans_table;
@@ -60,12 +55,16 @@ static int
60cpufreq_stats_update (unsigned int cpu) 55cpufreq_stats_update (unsigned int cpu)
61{ 56{
62 struct cpufreq_stats *stat; 57 struct cpufreq_stats *stat;
58 unsigned long long cur_time;
59
60 cur_time = get_jiffies_64();
63 spin_lock(&cpufreq_stats_lock); 61 spin_lock(&cpufreq_stats_lock);
64 stat = cpufreq_stats_table[cpu]; 62 stat = cpufreq_stats_table[cpu];
65 if (stat->time_in_state) 63 if (stat->time_in_state)
66 stat->time_in_state[stat->last_index] += 64 stat->time_in_state[stat->last_index] =
67 delta_time(stat->last_time, jiffies); 65 cputime64_add(stat->time_in_state[stat->last_index],
68 stat->last_time = jiffies; 66 cputime_sub(cur_time, stat->last_time));
67 stat->last_time = cur_time;
69 spin_unlock(&cpufreq_stats_lock); 68 spin_unlock(&cpufreq_stats_lock);
70 return 0; 69 return 0;
71} 70}
@@ -90,8 +89,8 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf)
90 return 0; 89 return 0;
91 cpufreq_stats_update(stat->cpu); 90 cpufreq_stats_update(stat->cpu);
92 for (i = 0; i < stat->state_num; i++) { 91 for (i = 0; i < stat->state_num; i++) {
93 len += sprintf(buf + len, "%u %llu\n", 92 len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
94 stat->freq_table[i], stat->time_in_state[i]); 93 (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i]));
95 } 94 }
96 return len; 95 return len;
97} 96}
@@ -107,16 +106,30 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
107 if(!stat) 106 if(!stat)
108 return 0; 107 return 0;
109 cpufreq_stats_update(stat->cpu); 108 cpufreq_stats_update(stat->cpu);
109 len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n");
110 len += snprintf(buf + len, PAGE_SIZE - len, " : ");
111 for (i = 0; i < stat->state_num; i++) {
112 if (len >= PAGE_SIZE)
113 break;
114 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
115 stat->freq_table[i]);
116 }
117 if (len >= PAGE_SIZE)
118 return len;
119
120 len += snprintf(buf + len, PAGE_SIZE - len, "\n");
121
110 for (i = 0; i < stat->state_num; i++) { 122 for (i = 0; i < stat->state_num; i++) {
111 if (len >= PAGE_SIZE) 123 if (len >= PAGE_SIZE)
112 break; 124 break;
113 len += snprintf(buf + len, PAGE_SIZE - len, "%9u:\t", 125
126 len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ",
114 stat->freq_table[i]); 127 stat->freq_table[i]);
115 128
116 for (j = 0; j < stat->state_num; j++) { 129 for (j = 0; j < stat->state_num; j++) {
117 if (len >= PAGE_SIZE) 130 if (len >= PAGE_SIZE)
118 break; 131 break;
119 len += snprintf(buf + len, PAGE_SIZE - len, "%u\t", 132 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
120 stat->trans_table[i*stat->max_state+j]); 133 stat->trans_table[i*stat->max_state+j]);
121 } 134 }
122 len += snprintf(buf + len, PAGE_SIZE - len, "\n"); 135 len += snprintf(buf + len, PAGE_SIZE - len, "\n");
@@ -197,7 +210,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
197 count++; 210 count++;
198 } 211 }
199 212
200 alloc_size = count * sizeof(int) + count * sizeof(long long); 213 alloc_size = count * sizeof(int) + count * sizeof(cputime64_t);
201 214
202#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 215#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
203 alloc_size += count * count * sizeof(int); 216 alloc_size += count * count * sizeof(int);
@@ -224,7 +237,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
224 } 237 }
225 stat->state_num = j; 238 stat->state_num = j;
226 spin_lock(&cpufreq_stats_lock); 239 spin_lock(&cpufreq_stats_lock);
227 stat->last_time = jiffies; 240 stat->last_time = get_jiffies_64();
228 stat->last_index = freq_table_get_index(stat, policy->cur); 241 stat->last_index = freq_table_get_index(stat, policy->cur);
229 spin_unlock(&cpufreq_stats_lock); 242 spin_unlock(&cpufreq_stats_lock);
230 cpufreq_cpu_put(data); 243 cpufreq_cpu_put(data);