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>
---
arch/powerpc/kernel/time.c | 14 +++++++-------
include/asm-generic/cputime.h | 1 +
include/asm-powerpc/cputime.h | 14 ++++++++++++++
include/asm-powerpc/paca.h | 2 --
include/asm-s390/cputime.h | 1 +
kernel/timer.c | 9 +++++----
6 files changed, 28 insertions(+), 13 deletions(-)
Index: linux-2.6-ozlabs/arch/powerpc/kernel/time.c
===================================================================
--- linux-2.6-ozlabs.orig/arch/powerpc/kernel/time.c
+++ linux-2.6-ozlabs/arch/powerpc/kernel/time.c
@@ -66,6 +66,7 @@
#include <asm/smp.h>
#include <asm/vdso_datapage.h>
#include <asm/firmware.h>
+#include <asm/cputime.h>
#ifdef CONFIG_PPC_ISERIES
#include <asm/iseries/it_lp_queue.h>
#include <asm/iseries/hv_call_xm.h>
@@ -186,6 +187,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)
{
@@ -232,9 +235,9 @@ void account_system_vtime(struct task_st
local_irq_save(flags);
now = read_purr();
+ nowscaled = read_spurr(now);
delta = now - get_paca()->startpurr;
get_paca()->startpurr = now;
- nowscaled = read_spurr(now);
deltascaled = nowscaled - get_paca()->startspurr;
get_paca()->startspurr = nowsc...