aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/entry_64.S
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-02-23 18:06:59 -0500
committerPaul Mackerras <paulus@samba.org>2006-02-23 22:05:56 -0500
commitc6622f63db86fcbd41bf6fe05ddf2e00c1e51ced (patch)
tree102f3ea0a891212603a3722fece337d6a74d450c /arch/powerpc/kernel/entry_64.S
parenta00428f5b149e36b8225b2a0812742a6dfb07b8c (diff)
powerpc: Implement accurate task and CPU time accounting
This implements accurate task and cpu time accounting for 64-bit powerpc kernels. Instead of accounting a whole jiffy of time to a task on a timer interrupt because that task happened to be running at the time, we now account time in units of timebase ticks according to the actual time spent by the task in user mode and kernel mode. We also count the time spent processing hardware and software interrupts accurately. This is conditional on CONFIG_VIRT_CPU_ACCOUNTING. If that is not set, we do tick-based approximate accounting as before. To get this accurate information, we read either the PURR (processor utilization of resources register) on POWER5 machines, or the timebase on other machines on * each entry to the kernel from usermode * each exit to usermode * transitions between process context, hard irq context and soft irq context in kernel mode * context switches. On POWER5 systems with shared-processor logical partitioning we also read both the PURR and the timebase at each timer interrupt and context switch in order to determine how much time has been taken by the hypervisor to run other partitions ("steal" time). Unfortunately, since we need values of the PURR on both threads at the same time to accurately calculate the steal time, and since we can only calculate steal time on a per-core basis, the apportioning of the steal time between idle time (time which we ceded to the hypervisor in the idle loop) and actual stolen time is somewhat approximate at the moment. This is all based quite heavily on what s390 does, and it uses the generic interfaces that were added by the s390 developers, i.e. account_system_time(), account_user_time(), etc. This patch doesn't add any new interfaces between the kernel and userspace, and doesn't change the units in which time is reported to userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(), times(), etc. Internally the various task and cpu times are stored in timebase units, but they are converted to USER_HZ units (1/100th of a second) when reported to userspace. Some precision is therefore lost but there should not be any accumulating error, since the internal accumulation is at full precision. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/entry_64.S')
-rw-r--r--arch/powerpc/kernel/entry_64.S7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 79a0c910f0d8..8f606c1889fa 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -61,6 +61,7 @@ system_call_common:
61 std r12,_MSR(r1) 61 std r12,_MSR(r1)
62 std r0,GPR0(r1) 62 std r0,GPR0(r1)
63 std r10,GPR1(r1) 63 std r10,GPR1(r1)
64 ACCOUNT_CPU_USER_ENTRY(r10, r11)
64 std r2,GPR2(r1) 65 std r2,GPR2(r1)
65 std r3,GPR3(r1) 66 std r3,GPR3(r1)
66 std r4,GPR4(r1) 67 std r4,GPR4(r1)
@@ -168,8 +169,9 @@ syscall_error_cont:
168 stdcx. r0,0,r1 /* to clear the reservation */ 169 stdcx. r0,0,r1 /* to clear the reservation */
169 andi. r6,r8,MSR_PR 170 andi. r6,r8,MSR_PR
170 ld r4,_LINK(r1) 171 ld r4,_LINK(r1)
171 beq- 1f /* only restore r13 if */ 172 beq- 1f
172 ld r13,GPR13(r1) /* returning to usermode */ 173 ACCOUNT_CPU_USER_EXIT(r11, r12)
174 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */
1731: ld r2,GPR2(r1) 1751: ld r2,GPR2(r1)
174 li r12,MSR_RI 176 li r12,MSR_RI
175 andc r11,r10,r12 177 andc r11,r10,r12
@@ -536,6 +538,7 @@ restore:
536 * userspace 538 * userspace
537 */ 539 */
538 beq 1f 540 beq 1f
541 ACCOUNT_CPU_USER_EXIT(r3, r4)
539 REST_GPR(13, r1) 542 REST_GPR(13, r1)
5401: 5431:
541 ld r3,_CTR(r1) 544 ld r3,_CTR(r1)