• Home
  • Raw
  • Download

Lines Matching refs:stats

30 static void cpufreq_stats_update(struct cpufreq_stats *stats,  in cpufreq_stats_update()  argument
35 stats->time_in_state[stats->last_index] += cur_time - time; in cpufreq_stats_update()
36 stats->last_time = cur_time; in cpufreq_stats_update()
39 static void cpufreq_stats_reset_table(struct cpufreq_stats *stats) in cpufreq_stats_reset_table() argument
41 unsigned int count = stats->max_state; in cpufreq_stats_reset_table()
43 memset(stats->time_in_state, 0, count * sizeof(u64)); in cpufreq_stats_reset_table()
44 memset(stats->trans_table, 0, count * count * sizeof(int)); in cpufreq_stats_reset_table()
45 stats->last_time = local_clock(); in cpufreq_stats_reset_table()
46 stats->total_trans = 0; in cpufreq_stats_reset_table()
49 WRITE_ONCE(stats->reset_pending, 0); in cpufreq_stats_reset_table()
55 cpufreq_stats_update(stats, READ_ONCE(stats->reset_time)); in cpufreq_stats_reset_table()
60 struct cpufreq_stats *stats = policy->stats; in show_total_trans() local
62 if (READ_ONCE(stats->reset_pending)) in show_total_trans()
65 return sprintf(buf, "%u\n", stats->total_trans); in show_total_trans()
71 struct cpufreq_stats *stats = policy->stats; in show_time_in_state() local
72 bool pending = READ_ONCE(stats->reset_pending); in show_time_in_state()
77 for (i = 0; i < stats->state_num; i++) { in show_time_in_state()
79 if (i == stats->last_index) { in show_time_in_state()
85 time = local_clock() - READ_ONCE(stats->reset_time); in show_time_in_state()
90 time = stats->time_in_state[i]; in show_time_in_state()
91 if (i == stats->last_index) in show_time_in_state()
92 time += local_clock() - stats->last_time; in show_time_in_state()
95 len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i], in show_time_in_state()
106 struct cpufreq_stats *stats = policy->stats; in store_reset() local
112 WRITE_ONCE(stats->reset_time, local_clock()); in store_reset()
118 WRITE_ONCE(stats->reset_pending, 1); in store_reset()
126 struct cpufreq_stats *stats = policy->stats; in show_trans_table() local
127 bool pending = READ_ONCE(stats->reset_pending); in show_trans_table()
133 for (i = 0; i < stats->state_num; i++) { in show_trans_table()
137 stats->freq_table[i]); in show_trans_table()
144 for (i = 0; i < stats->state_num; i++) { in show_trans_table()
149 stats->freq_table[i]); in show_trans_table()
151 for (j = 0; j < stats->state_num; j++) { in show_trans_table()
158 count = stats->trans_table[i * stats->max_state + j]; in show_trans_table()
187 static int freq_table_get_index(struct cpufreq_stats *stats, unsigned int freq) in freq_table_get_index() argument
190 for (index = 0; index < stats->max_state; index++) in freq_table_get_index()
191 if (stats->freq_table[index] == freq) in freq_table_get_index()
198 struct cpufreq_stats *stats = policy->stats; in cpufreq_stats_free_table() local
201 if (!stats) in cpufreq_stats_free_table()
207 kfree(stats->time_in_state); in cpufreq_stats_free_table()
208 kfree(stats); in cpufreq_stats_free_table()
209 policy->stats = NULL; in cpufreq_stats_free_table()
215 struct cpufreq_stats *stats; in cpufreq_stats_create_table() local
224 if (policy->stats) in cpufreq_stats_create_table()
227 stats = kzalloc(sizeof(*stats), GFP_KERNEL); in cpufreq_stats_create_table()
228 if (!stats) in cpufreq_stats_create_table()
236 stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL); in cpufreq_stats_create_table()
237 if (!stats->time_in_state) in cpufreq_stats_create_table()
240 stats->freq_table = (unsigned int *)(stats->time_in_state + count); in cpufreq_stats_create_table()
242 stats->trans_table = stats->freq_table + count; in cpufreq_stats_create_table()
244 stats->max_state = count; in cpufreq_stats_create_table()
248 if (freq_table_get_index(stats, pos->frequency) == -1) in cpufreq_stats_create_table()
249 stats->freq_table[i++] = pos->frequency; in cpufreq_stats_create_table()
251 stats->state_num = i; in cpufreq_stats_create_table()
252 stats->last_time = local_clock(); in cpufreq_stats_create_table()
253 stats->last_index = freq_table_get_index(stats, policy->cur); in cpufreq_stats_create_table()
255 policy->stats = stats; in cpufreq_stats_create_table()
260 policy->stats = NULL; in cpufreq_stats_create_table()
261 kfree(stats->time_in_state); in cpufreq_stats_create_table()
263 kfree(stats); in cpufreq_stats_create_table()
269 struct cpufreq_stats *stats = policy->stats; in cpufreq_stats_record_transition() local
272 if (unlikely(!stats)) in cpufreq_stats_record_transition()
275 if (unlikely(READ_ONCE(stats->reset_pending))) in cpufreq_stats_record_transition()
276 cpufreq_stats_reset_table(stats); in cpufreq_stats_record_transition()
278 old_index = stats->last_index; in cpufreq_stats_record_transition()
279 new_index = freq_table_get_index(stats, new_freq); in cpufreq_stats_record_transition()
285 cpufreq_stats_update(stats, stats->last_time); in cpufreq_stats_record_transition()
287 stats->last_index = new_index; in cpufreq_stats_record_transition()
288 stats->trans_table[old_index * stats->max_state + new_index]++; in cpufreq_stats_record_transition()
289 stats->total_trans++; in cpufreq_stats_record_transition()