From 2a1f6b498f6c8138aa092c6b0b1deb897f67291f Mon Sep 17 00:00:00 2001 From: malc Date: Fri, 28 Mar 2008 19:59:43 +0300 Subject: [PATCH] Add IRQ accounting but only on PPC Why only PPC a) It appears that IRQ accounting is done right only on PPC (maybe on S390 too) b) cputime64 == cputime there (hopefuly if/when this changes the compiler will notify us) --- mod/itc-mod.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mod/itc-mod.c b/mod/itc-mod.c index 2f2e457..fc86698 100644 --- a/mod/itc-mod.c +++ b/mod/itc-mod.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,7 @@ #ifdef CONFIG_6xx #include #define pm_idle ppc_md.power_save +#define ACCOUNT_IRQ #endif #if !(defined CONFIG_X86 || defined CONFIG_6xx) @@ -156,12 +158,25 @@ itc_monotonic (struct timeval *tv) do_gettimeofday (tv); } +#ifdef ACCOUNT_IRQ +static cputime64_t +itc_irq_time (void) +{ + struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; + return cpustat->irq; +} +#endif + static void itc_idle (void) { struct itc *itc; struct timeval tv; unsigned long flags; +#ifdef ACCOUNT_IRQ + struct timeval tv_irq_before, tv_irq_after; + cputime64_t irq_time_before, irq_time_after; +#endif #ifdef ITC_PREEMPT_HACK preempt_disable (); @@ -172,6 +187,9 @@ itc_idle (void) itc = &global_itc[smp_processor_id ()]; itc_monotonic (&itc->sleep_started); itc->sleeping = 1; +#ifdef ACCOUNT_IRQ + irq_time_before = itc_irq_time (); +#endif spin_unlock_irqrestore (&lock, flags); #ifdef QUIRK @@ -207,7 +225,19 @@ itc_idle (void) spin_lock_irqsave (&lock, flags); itc_monotonic (&tv); + +#ifdef ACCOUNT_IRQ + irq_time_after = itc_irq_time (); + + cputime_to_timeval (irq_time_before, &tv_irq_before); + cputime_to_timeval (irq_time_after, &tv_irq_after); + + cpeamb (&itc->cumm_sleep_time, &tv, &itc->sleep_started); + cpeamb (&itc->cumm_sleep_time, &tv_irq_before, &tv_irq_after); +#else cpeamb (&itc->cumm_sleep_time, &tv, &itc->sleep_started); +#endif + itc->sleeping = 0; spin_unlock_irqrestore (&lock, flags); /* printk ("idle out %d\n", smp_processor_id ()); */ -- 2.11.4.GIT