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 = local_clock();
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 = local_clock() - READ_ONCE(stats->reset_time);
90 time = stats->time_in_state[i];
91 if (i == stats->last_index)
92 time += local_clock() - 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, local_clock());
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++) {
136 len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]);
143 for (i = 0; i < stats->state_num; i++) {
147 len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]);
149 for (j = 0; j < stats->state_num; j++) {
156 count = stats->trans_table[i * stats->max_state + j];
182 .name = "stats"
185 static int freq_table_get_index(struct cpufreq_stats *stats, unsigned int freq)
188 for (index = 0; index < stats->max_state; index++)
189 if (stats->freq_table[index] == freq)
196 struct cpufreq_stats *stats = policy->stats;
199 if (!stats)
202 pr_debug("%s: Free stats table\n", __func__);
205 kfree(stats->time_in_state);
206 kfree(stats);
207 policy->stats = NULL;
213 struct cpufreq_stats *stats;
221 /* stats already initialized */
222 if (policy->stats)
225 stats = kzalloc(sizeof(*stats), GFP_KERNEL);
226 if (!stats)
234 stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
235 if (!stats->time_in_state)
238 stats->freq_table = (unsigned int *)(stats->time_in_state + count);
240 stats->trans_table = stats->freq_table + count;
242 stats->max_state = count;
247 freq_table_get_index(stats, pos->frequency) == -1)
248 stats->freq_table[i++] = pos->frequency;
250 stats->state_num = i;
251 stats->last_time = local_clock();
252 stats->last_index = freq_table_get_index(stats, policy->cur);
254 policy->stats = stats;
259 policy->stats = NULL;
260 kfree(stats->time_in_state);
262 kfree(stats);
268 struct cpufreq_stats *stats = policy->stats;
271 if (unlikely(!stats))
274 if (unlikely(READ_ONCE(stats->reset_pending)))
275 cpufreq_stats_reset_table(stats);
277 old_index = stats->last_index;
278 new_index = freq_table_get_index(stats, new_freq);
280 /* We can't do stats->time_in_state[-1]= .. */
284 cpufreq_stats_update(stats, stats->last_time);
286 stats->last_index = new_index;
287 stats->trans_table[old_index * stats->max_state + new_index]++;
288 stats->total_trans++;