/* Adjust for the time elapsed since reset was requested */
WRITE_ONCE(stats->reset_pending, 0); /* * Prevent the reset_time read from being reordered before the * reset_pending accesses in cpufreq_stats_record_transition().
*/
smp_rmb();
cpufreq_stats_update(stats, READ_ONCE(stats->reset_time));
}
for (i = 0; i < stats->state_num; i++) { if (pending) { if (i == stats->last_index) { /* * Prevent the reset_time read from occurring * before the reset_pending read above.
*/
smp_rmb();
time = local_clock() - READ_ONCE(stats->reset_time);
} else {
time = 0;
}
} else {
time = stats->time_in_state[i]; if (i == stats->last_index)
time += local_clock() - stats->last_time;
}
/* We don't care what is written to the attribute */ static ssize_t store_reset(struct cpufreq_policy *policy, constchar *buf,
size_t count)
{ struct cpufreq_stats *stats = policy->stats;
/* * Defer resetting of stats to cpufreq_stats_record_transition() to * avoid races.
*/
WRITE_ONCE(stats->reset_time, local_clock()); /* * The memory barrier below is to prevent the readers of reset_time from * seeing a stale or partially updated value.
*/
smp_wmb();
WRITE_ONCE(stats->reset_pending, 1);
return count;
}
cpufreq_freq_attr_wo(reset);
static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
{ struct cpufreq_stats *stats = policy->stats; bool pending = READ_ONCE(stats->reset_pending);
ssize_t len = 0; int i, j, count;
len += sysfs_emit_at(buf, len, " From : To\n");
len += sysfs_emit_at(buf, len, " : "); for (i = 0; i < stats->state_num; i++) { if (len >= PAGE_SIZE - 1) break;
len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]);
} if (len >= PAGE_SIZE - 1) return PAGE_SIZE - 1;
len += sysfs_emit_at(buf, len, "\n");
for (i = 0; i < stats->state_num; i++) { if (len >= PAGE_SIZE - 1) break;
len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]);
for (j = 0; j < stats->state_num; j++) { if (len >= PAGE_SIZE - 1) break;
/* Allocate memory for time_in_state/freq_table/trans_table in one go */
stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL); if (!stats->time_in_state) goto free_stat;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.