aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/irq.c
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/irq.c
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/irq.c')
-rw-r--r--arch/powerpc/kernel/irq.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index edb2b00edbd2..24dc8117b822 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -369,6 +369,7 @@ unsigned int real_irq_to_virt_slowpath(unsigned int real_irq)
369 return NO_IRQ; 369 return NO_IRQ;
370 370
371} 371}
372#endif /* CONFIG_PPC64 */
372 373
373#ifdef CONFIG_IRQSTACKS 374#ifdef CONFIG_IRQSTACKS
374struct thread_info *softirq_ctx[NR_CPUS]; 375struct thread_info *softirq_ctx[NR_CPUS];
@@ -392,10 +393,24 @@ void irq_ctx_init(void)
392 } 393 }
393} 394}
394 395
396static inline void do_softirq_onstack(void)
397{
398 struct thread_info *curtp, *irqtp;
399
400 curtp = current_thread_info();
401 irqtp = softirq_ctx[smp_processor_id()];
402 irqtp->task = curtp->task;
403 call_do_softirq(irqtp);
404 irqtp->task = NULL;
405}
406
407#else
408#define do_softirq_onstack() __do_softirq()
409#endif /* CONFIG_IRQSTACKS */
410
395void do_softirq(void) 411void do_softirq(void)
396{ 412{
397 unsigned long flags; 413 unsigned long flags;
398 struct thread_info *curtp, *irqtp;
399 414
400 if (in_interrupt()) 415 if (in_interrupt())
401 return; 416 return;
@@ -403,19 +418,18 @@ void do_softirq(void)
403 local_irq_save(flags); 418 local_irq_save(flags);
404 419
405 if (local_softirq_pending()) { 420 if (local_softirq_pending()) {
406 curtp = current_thread_info(); 421 account_system_vtime(current);
407 irqtp = softirq_ctx[smp_processor_id()]; 422 local_bh_disable();
408 irqtp->task = curtp->task; 423 do_softirq_onstack();
409 call_do_softirq(irqtp); 424 account_system_vtime(current);
410 irqtp->task = NULL; 425 __local_bh_enable();
411 } 426 }
412 427
413 local_irq_restore(flags); 428 local_irq_restore(flags);
414} 429}
415EXPORT_SYMBOL(do_softirq); 430EXPORT_SYMBOL(do_softirq);
416 431
417#endif /* CONFIG_IRQSTACKS */ 432#ifdef CONFIG_PPC64
418
419static int __init setup_noirqdistrib(char *str) 433static int __init setup_noirqdistrib(char *str)
420{ 434{
421 distribute_irqs = 0; 435 distribute_irqs = 0;