[PATCH 1/6] cpufreq_stats: Correct jiffies64/cputime64 conversion

From: Darrick J. Wong
Date: Tue Nov 25 2008 - 16:46:54 EST


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@xxxxxxxxxx>
---
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;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/