Lines Matching refs:stats
30 static void cpufreq_stats_update(struct cpufreq_stats *stats,
35 stats->time_in_state[stats->last_index] += cur_time - time;
36 stats->last_time = cur_time;
39 static void cpufreq_stats_reset_table(struct cpufreq_stats *stats)
41 unsigned int count = stats->max_state;
43 memset(stats->time_in_state, 0, count * sizeof(u64));
44 memset(stats->trans_table, 0, count * count * sizeof(int));
45 stats->last_time = get_jiffies_64();
46 stats->total_trans = 0;
49 WRITE_ONCE(stats->reset_pending, 0);
55 cpufreq_stats_update(stats, READ_ONCE(stats->reset_time));
60 struct cpufreq_stats *stats = policy->stats;
62 if (READ_ONCE(stats->reset_pending))
65 return sprintf(buf, "%u\n", stats->total_trans);
71 struct cpufreq_stats *stats = policy->stats;
72 bool pending = READ_ONCE(stats->reset_pending);
77 for (i = 0; i < stats->state_num; i++) {
79 if (i == stats->last_index) {
85 time = get_jiffies_64() - READ_ONCE(stats->reset_time);
90 time = stats->time_in_state[i];
91 if (i == stats->last_index)
92 time += get_jiffies_64() - stats->last_time;
95 len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
106 struct cpufreq_stats *stats = policy->stats;
109 * Defer resetting of stats to cpufreq_stats_record_transition() to
112 WRITE_ONCE(stats->reset_time, get_jiffies_64());
118 WRITE_ONCE(stats->reset_pending, 1);
126 struct cpufreq_stats *stats = policy->stats;
127 bool pending = READ_ONCE(stats->reset_pending);
133 for (i = 0; i < stats->state_num; i++) {
137 stats->freq_table[i]);
144 for (i = 0; i < stats->state_num; i++) {
149 stats->freq_table[i]);
151 for (j = 0; j < stats->state_num; j++) {
158 count = stats->trans_table[i * stats->max_state + j];
184 .name = "stats"
187 static int freq_table_get_index(struct cpufreq_stats *stats, unsigned int freq)
190 for (index = 0; index < stats->max_state; index++)
191 if (stats->freq_table[index] == freq)
198 struct cpufreq_stats *stats = policy->stats;
201 if (!stats)
204 pr_debug("%s: Free stats table\n", __func__);
207 kfree(stats->time_in_state);
208 kfree(stats);
209 policy->stats = NULL;
215 struct cpufreq_stats *stats;
223 /* stats already initialized */
224 if (policy->stats)
227 stats = kzalloc(sizeof(*stats), GFP_KERNEL);
228 if (!stats)
236 stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
237 if (!stats->time_in_state)
240 stats->freq_table = (unsigned int *)(stats->time_in_state + count);
242 stats->trans_table = stats->freq_table + count;
244 stats->max_state = count;
248 if (freq_table_get_index(stats, pos->frequency) == -1)
249 stats->freq_table[i++] = pos->frequency;
251 stats->state_num = i;
252 stats->last_time = get_jiffies_64();
253 stats->last_index = freq_table_get_index(stats, policy->cur);
255 policy->stats = stats;
261 policy->stats = NULL;
262 kfree(stats->time_in_state);
264 kfree(stats);
270 struct cpufreq_stats *stats = policy->stats;
273 if (unlikely(!stats))
276 if (unlikely(READ_ONCE(stats->reset_pending)))
277 cpufreq_stats_reset_table(stats);
279 old_index = stats->last_index;
280 new_index = freq_table_get_index(stats, new_freq);
282 /* We can't do stats->time_in_state[-1]= .. */
286 cpufreq_stats_update(stats, stats->last_time);
288 stats->last_index = new_index;
289 stats->trans_table[old_index * stats->max_state + new_index]++;
290 stats->total_trans++;