diff options
author | Michael Neuling <mikey@neuling.org> | 2008-02-06 04:36:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:00 -0500 |
commit | 06b8e878a9bc9301201cffe186eba99c4185f20a (patch) | |
tree | 857434ed559cdb001177e81283be6f0b5693a781 /include/asm-powerpc/cputime.h | |
parent | d9afa43532adf8a31b93c4c7601fda3f423d8972 (diff) |
taskstats scaled time cleanup
This moves the ability to scale cputime into generic code. This allows us
to fix the issue in kernel/timer.c (noticed by Balbir) where we could only
add an unscaled value to the scaled utime/stime.
This adds a cputime_to_scaled function. As before, the POWERPC version
does the scaling based on the last SPURR/PURR ratio calculated. The
generic and s390 (only other arch to implement asm/cputime.h) versions are
both NOPs.
Also moves the SPURR and PURR snapshots closer.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Cc: Jay Lan <jlan@engr.sgi.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-powerpc/cputime.h')
-rw-r--r-- | include/asm-powerpc/cputime.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/asm-powerpc/cputime.h b/include/asm-powerpc/cputime.h index 310804485208..f42e623030ee 100644 --- a/include/asm-powerpc/cputime.h +++ b/include/asm-powerpc/cputime.h | |||
@@ -52,12 +52,26 @@ typedef u64 cputime64_t; | |||
52 | * Convert cputime <-> jiffies | 52 | * Convert cputime <-> jiffies |
53 | */ | 53 | */ |
54 | extern u64 __cputime_jiffies_factor; | 54 | extern u64 __cputime_jiffies_factor; |
55 | DECLARE_PER_CPU(unsigned long, cputime_last_delta); | ||
56 | DECLARE_PER_CPU(unsigned long, cputime_scaled_last_delta); | ||
55 | 57 | ||
56 | static inline unsigned long cputime_to_jiffies(const cputime_t ct) | 58 | static inline unsigned long cputime_to_jiffies(const cputime_t ct) |
57 | { | 59 | { |
58 | return mulhdu(ct, __cputime_jiffies_factor); | 60 | return mulhdu(ct, __cputime_jiffies_factor); |
59 | } | 61 | } |
60 | 62 | ||
63 | /* Estimate the scaled cputime by scaling the real cputime based on | ||
64 | * the last scaled to real ratio */ | ||
65 | static inline cputime_t cputime_to_scaled(const cputime_t ct) | ||
66 | { | ||
67 | if (cpu_has_feature(CPU_FTR_SPURR) && | ||
68 | per_cpu(cputime_last_delta, smp_processor_id())) | ||
69 | return ct * | ||
70 | per_cpu(cputime_scaled_last_delta, smp_processor_id())/ | ||
71 | per_cpu(cputime_last_delta, smp_processor_id()); | ||
72 | return ct; | ||
73 | } | ||
74 | |||
61 | static inline cputime_t jiffies_to_cputime(const unsigned long jif) | 75 | static inline cputime_t jiffies_to_cputime(const unsigned long jif) |
62 | { | 76 | { |
63 | cputime_t ct; | 77 | cputime_t ct; |