From 19f918546d433f18ca6d7a3e243a29efa0102878 Mon Sep 17 00:00:00 2001 From: Michael Neuling Date: Wed, 6 Feb 2008 01:36:12 -0800 Subject: [PATCH] --- yaml --- r: 83374 b: refs/heads/master c: 06b8e878a9bc9301201cffe186eba99c4185f20a h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/powerpc/kernel/time.c | 12 ++++++------ trunk/include/asm-generic/cputime.h | 1 + trunk/include/asm-powerpc/cputime.h | 14 ++++++++++++++ trunk/include/asm-powerpc/paca.h | 2 -- trunk/include/asm-s390/cputime.h | 1 + trunk/kernel/timer.c | 10 ++++++---- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index 75fbb2ce5204..b712ddfb800a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d9afa43532adf8a31b93c4c7601fda3f423d8972 +refs/heads/master: 06b8e878a9bc9301201cffe186eba99c4185f20a diff --git a/trunk/arch/powerpc/kernel/time.c b/trunk/arch/powerpc/kernel/time.c index 5cd3db5cae41..3b26fbd6bec9 100644 --- a/trunk/arch/powerpc/kernel/time.c +++ b/trunk/arch/powerpc/kernel/time.c @@ -66,6 +66,7 @@ #include #include #include +#include #ifdef CONFIG_PPC_ISERIES #include #include @@ -189,6 +190,8 @@ u64 __cputime_sec_factor; EXPORT_SYMBOL(__cputime_sec_factor); u64 __cputime_clockt_factor; EXPORT_SYMBOL(__cputime_clockt_factor); +DEFINE_PER_CPU(unsigned long, cputime_last_delta); +DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta); static void calc_cputime_factors(void) { @@ -257,8 +260,8 @@ void account_system_vtime(struct task_struct *tsk) } account_system_time(tsk, 0, delta); account_system_time_scaled(tsk, deltascaled); - get_paca()->purrdelta = delta; - get_paca()->spurrdelta = deltascaled; + per_cpu(cputime_last_delta, smp_processor_id()) = delta; + per_cpu(cputime_scaled_last_delta, smp_processor_id()) = deltascaled; local_irq_restore(flags); } @@ -276,10 +279,7 @@ void account_process_tick(struct task_struct *tsk, int user_tick) get_paca()->user_time = 0; account_user_time(tsk, utime); - /* Estimate the scaled utime by scaling the real utime based - * on the last spurr to purr ratio */ - utimescaled = utime * get_paca()->spurrdelta / get_paca()->purrdelta; - get_paca()->spurrdelta = get_paca()->purrdelta = 0; + utimescaled = cputime_to_scaled(utime); account_user_time_scaled(tsk, utimescaled); } diff --git a/trunk/include/asm-generic/cputime.h b/trunk/include/asm-generic/cputime.h index 09204e40d663..1c1fa422d18a 100644 --- a/trunk/include/asm-generic/cputime.h +++ b/trunk/include/asm-generic/cputime.h @@ -18,6 +18,7 @@ typedef unsigned long cputime_t; #define cputime_lt(__a, __b) ((__a) < (__b)) #define cputime_le(__a, __b) ((__a) <= (__b)) #define cputime_to_jiffies(__ct) (__ct) +#define cputime_to_scaled(__ct) (__ct) #define jiffies_to_cputime(__hz) (__hz) typedef u64 cputime64_t; diff --git a/trunk/include/asm-powerpc/cputime.h b/trunk/include/asm-powerpc/cputime.h index 310804485208..f42e623030ee 100644 --- a/trunk/include/asm-powerpc/cputime.h +++ b/trunk/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; diff --git a/trunk/include/asm-powerpc/paca.h b/trunk/include/asm-powerpc/paca.h index f6dfce025adf..748b35ab37b5 100644 --- a/trunk/include/asm-powerpc/paca.h +++ b/trunk/include/asm-powerpc/paca.h @@ -115,8 +115,6 @@ struct paca_struct { u64 system_time; /* accumulated system TB ticks */ u64 startpurr; /* PURR/TB value snapshot */ u64 startspurr; /* SPURR value snapshot */ - u64 purrdelta; /* FIXME: document */ - u64 spurrdelta; /* FIXME: document */ }; extern struct paca_struct paca[]; diff --git a/trunk/include/asm-s390/cputime.h b/trunk/include/asm-s390/cputime.h index 4b3ef7cad115..133ce054fc89 100644 --- a/trunk/include/asm-s390/cputime.h +++ b/trunk/include/asm-s390/cputime.h @@ -54,6 +54,7 @@ __div(unsigned long long n, unsigned int base) #define cputime_lt(__a, __b) ((__a) < (__b)) #define cputime_le(__a, __b) ((__a) <= (__b)) #define cputime_to_jiffies(__ct) (__div((__ct), 1000000 / HZ)) +#define cputime_to_scaled(__ct) (__ct) #define jiffies_to_cputime(__hz) ((cputime_t)(__hz) * (1000000 / HZ)) #define cputime64_zero (0ULL) diff --git a/trunk/kernel/timer.c b/trunk/kernel/timer.c index 9fbb472b8cf0..70b29b59343f 100644 --- a/trunk/kernel/timer.c +++ b/trunk/kernel/timer.c @@ -818,12 +818,14 @@ unsigned long next_timer_interrupt(void) #ifndef CONFIG_VIRT_CPU_ACCOUNTING void account_process_tick(struct task_struct *p, int user_tick) { + cputime_t one_jiffy = jiffies_to_cputime(1); + if (user_tick) { - account_user_time(p, jiffies_to_cputime(1)); - account_user_time_scaled(p, jiffies_to_cputime(1)); + account_user_time(p, one_jiffy); + account_user_time_scaled(p, cputime_to_scaled(one_jiffy)); } else { - account_system_time(p, HARDIRQ_OFFSET, jiffies_to_cputime(1)); - account_system_time_scaled(p, jiffies_to_cputime(1)); + account_system_time(p, HARDIRQ_OFFSET, one_jiffy); + account_system_time_scaled(p, cputime_to_scaled(one_jiffy)); } } #endif