Messages in this thread Patch in this message |  | | | From | "Darrick J. Wong" <> | | Subject | [PATCH 1/6] cpufreq_stats: Correct jiffies64/cputime64 conversion | | Date | Tue, 25 Nov 2008 13:44:42 -0800 |
| |
Since cpufreq_stats->time_in_state is a cputime64_t value, we ought to convert the jiffies64 values to cputime64_t. On platforms where cputime != jiffies, this leads to accounting errors in the sysfs reports.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> --- drivers/cpufreq/cpufreq_stats.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c0ff97d..b5ccf86 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -55,14 +55,18 @@ cpufreq_stats_update (unsigned int cpu) { struct cpufreq_stats *stat; unsigned long long cur_time; + cputime64_t d; cur_time = get_jiffies_64(); spin_lock(&cpufreq_stats_lock); stat = per_cpu(cpufreq_stats_table, cpu); - if (stat->time_in_state) + if (stat->time_in_state) { + d = jiffies64_to_cputime64(cputime_sub(cur_time, + stat->last_time)); stat->time_in_state[stat->last_index] = cputime64_add(stat->time_in_state[stat->last_index], - cputime_sub(cur_time, stat->last_time)); + d); + } stat->last_time = cur_time; spin_unlock(&cpufreq_stats_lock); return 0;
|  |