From 06b8e878a9bc9301201cffe186eba99c4185f20a Mon Sep 17 00:00:00 2001 From: Michael Neuling Date: Wed, 6 Feb 2008 01:36:12 -0800 Subject: 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 Cc: Jay Lan Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Heiko Carstens Cc: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-powerpc/cputime.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/asm-powerpc/cputime.h') diff --git a/include/asm-powerpc/cputime.h b/include/asm-powerpc/cputime.h index 31080448520..f42e623030e 100644 --- a/include/asm-powerpc/cputime.h +++ b/include/asm-powerpc/cputime.h @@ -52,12 +52,26 @@ typedef u64 cputime64_t; * Convert cputime <-> jiffies */ extern u64 __cputime_jiffies_factor; +DECLARE_PER_CPU(unsigned long, cputime_last_delta); +DECLARE_PER_CPU(unsigned long, cputime_scaled_last_delta); static inline unsigned long cputime_to_jiffies(const cputime_t ct) { return mulhdu(ct, __cputime_jiffies_factor); } +/* Estimate the scaled cputime by scaling the real cputime based on + * the last scaled to real ratio */ +static inline cputime_t cputime_to_scaled(const cputime_t ct) +{ + if (cpu_has_feature(CPU_FTR_SPURR) && + per_cpu(cputime_last_delta, smp_processor_id())) + return ct * + per_cpu(cputime_scaled_last_delta, smp_processor_id())/ + per_cpu(cputime_last_delta, smp_processor_id()); + return ct; +} + static inline cputime_t jiffies_to_cputime(const unsigned long jif) { cputime_t ct; -- cgit v1.2.3