Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71204
b: refs/heads/master
c: 4603ac1
h: refs/heads/master
v: v3
  • Loading branch information
Michael Neuling authored and Linus Torvalds committed Oct 18, 2007
1 parent b16061c commit 3bb9fcd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f494f8fcb18e962839a82d542fbe6bed9cf5be07
refs/heads/master: 4603ac180a824197c2262747948d0179eb076e9c
1 change: 1 addition & 0 deletions trunk/arch/powerpc/kernel/asm-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ int main(void)
DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr));
DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));
DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr));
DEFINE(PACA_STARTSPURR, offsetof(struct paca_struct, startspurr));
DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr));
Expand Down
32 changes: 30 additions & 2 deletions trunk/arch/powerpc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,45 @@ static u64 read_purr(void)
return mftb();
}

/*
* Read the SPURR on systems that have it, otherwise the purr
*/
static u64 read_spurr(u64 purr)
{
if (cpu_has_feature(CPU_FTR_SPURR))
return mfspr(SPRN_SPURR);
return purr;
}

/*
* Account time for a transition between system, hard irq
* or soft irq state.
*/
void account_system_vtime(struct task_struct *tsk)
{
u64 now, delta;
u64 now, nowscaled, delta, deltascaled;
unsigned long flags;

local_irq_save(flags);
now = read_purr();
delta = now - get_paca()->startpurr;
get_paca()->startpurr = now;
nowscaled = read_spurr(now);
deltascaled = nowscaled - get_paca()->startspurr;
get_paca()->startspurr = nowscaled;
if (!in_interrupt()) {
/* deltascaled includes both user and system time.
* Hence scale it based on the purr ratio to estimate
* the system time */
deltascaled = deltascaled * get_paca()->system_time /
(get_paca()->system_time + get_paca()->user_time);
delta += get_paca()->system_time;
get_paca()->system_time = 0;
}
account_system_time(tsk, 0, delta);
get_paca()->purrdelta = delta;
account_system_time_scaled(tsk, deltascaled);
get_paca()->spurrdelta = deltascaled;
local_irq_restore(flags);
}

Expand All @@ -240,11 +261,17 @@ void account_system_vtime(struct task_struct *tsk)
*/
void account_process_vtime(struct task_struct *tsk)
{
cputime_t utime;
cputime_t utime, utimescaled;

utime = get_paca()->user_time;
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;
account_user_time_scaled(tsk, utimescaled);
}

static void account_process_time(struct pt_regs *regs)
Expand All @@ -266,6 +293,7 @@ struct cpu_purr_data {
int initialized; /* thread is running */
u64 tb; /* last TB value read */
u64 purr; /* last PURR value read */
u64 spurr; /* last SPURR value read */
};

/*
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/asm-powerpc/paca.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ struct paca_struct {
u64 user_time; /* accumulated usermode TB ticks */
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[];
Expand Down

0 comments on commit 3bb9fcd

Please sign in to comment.