]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
powerpc: Fix wrong divisor in usecs_to_cputime
authorAndreas Schwab <schwab@linux-m68k.org>
Fri, 9 Dec 2011 11:35:08 +0000 (11:35 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 25 Jul 2012 03:11:38 +0000 (04:11 +0100)
commit 9f5072d4f63f28d30d343573830ac6c85fc0deff upstream.

Commit d57af9b (taskstats: use real microsecond granularity for CPU times)
renamed msecs_to_cputime to usecs_to_cputime, but failed to update all
numbers on the way.  This causes nonsensical cpu idle/iowait values to be
displayed in /proc/stat (the only user of usecs_to_cputime so far).

This also renames __cputime_msec_factor to __cputime_usec_factor, adapting
its value and using it directly in cputime_to_usecs instead of doing two
multiplications.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Acked-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/powerpc/include/asm/cputime.h
arch/powerpc/kernel/time.c

index 98b7c4b49c9d0586cce4d7132593ee359c3fd803..fa3f921b9b3595dc0911f3d884358e7dcae85510 100644 (file)
@@ -126,11 +126,11 @@ static inline u64 cputime64_to_jiffies64(const cputime_t ct)
 /*
  * Convert cputime <-> microseconds
  */
-extern u64 __cputime_msec_factor;
+extern u64 __cputime_usec_factor;
 
 static inline unsigned long cputime_to_usecs(const cputime_t ct)
 {
-       return mulhdu(ct, __cputime_msec_factor) * USEC_PER_MSEC;
+       return mulhdu(ct, __cputime_usec_factor);
 }
 
 static inline cputime_t usecs_to_cputime(const unsigned long us)
@@ -143,7 +143,7 @@ static inline cputime_t usecs_to_cputime(const unsigned long us)
        sec = us / 1000000;
        if (ct) {
                ct *= tb_ticks_per_sec;
-               do_div(ct, 1000);
+               do_div(ct, 1000000);
        }
        if (sec)
                ct += (cputime_t) sec * tb_ticks_per_sec;
index 5db163c96751f8d3979a8757f25958cf91264c39..ec8affecf940b92bad2439646c6db876d1b6ca2c 100644 (file)
@@ -168,13 +168,13 @@ EXPORT_SYMBOL_GPL(ppc_tb_freq);
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
 /*
  * Factors for converting from cputime_t (timebase ticks) to
- * jiffies, milliseconds, seconds, and clock_t (1/USER_HZ seconds).
+ * jiffies, microseconds, seconds, and clock_t (1/USER_HZ seconds).
  * These are all stored as 0.64 fixed-point binary fractions.
  */
 u64 __cputime_jiffies_factor;
 EXPORT_SYMBOL(__cputime_jiffies_factor);
-u64 __cputime_msec_factor;
-EXPORT_SYMBOL(__cputime_msec_factor);
+u64 __cputime_usec_factor;
+EXPORT_SYMBOL(__cputime_usec_factor);
 u64 __cputime_sec_factor;
 EXPORT_SYMBOL(__cputime_sec_factor);
 u64 __cputime_clockt_factor;
@@ -192,8 +192,8 @@ static void calc_cputime_factors(void)
 
        div128_by_32(HZ, 0, tb_ticks_per_sec, &res);
        __cputime_jiffies_factor = res.result_low;
-       div128_by_32(1000, 0, tb_ticks_per_sec, &res);
-       __cputime_msec_factor = res.result_low;
+       div128_by_32(1000000, 0, tb_ticks_per_sec, &res);
+       __cputime_usec_factor = res.result_low;
        div128_by_32(1, 0, tb_ticks_per_sec, &res);
        __cputime_sec_factor = res.result_low;
        div128_by_32(USER_HZ, 0, tb_ticks_per_sec, &res);