]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sched: Call tick_check_idle before __irq_enter
authorVenkatesh Pallipadi <venki@google.com>
Thu, 10 Feb 2011 09:23:28 +0000 (10:23 +0100)
committerAK <andi@firstfloor.org>
Thu, 31 Mar 2011 18:58:01 +0000 (11:58 -0700)
Commit: d267f87fb8179c6dba03d08b91952e81bc3723c7 upstream

When CPU is idle and on first interrupt, irq_enter calls tick_check_idle()
to notify interruption from idle. But, there is a problem if this call
is done after __irq_enter, as all routines in __irq_enter may find
stale time due to yet to be done tick_check_idle.

Specifically, trace calls in __irq_enter when they use global clock and also
account_system_vtime change in this patch as it wants to use sched_clock_cpu()
to do proper irq timing.

But, tick_check_idle was moved after __irq_enter intentionally to
prevent problem of unneeded ksoftirqd wakeups by the commit ee5f80a:

    irq: call __irq_enter() before calling the tick_idle_check
    Impact: avoid spurious ksoftirqd wakeups

Moving tick_check_idle() before __irq_enter and wrapping it with
local_bh_enable/disable would solve both the problems.

Fixed-by: Yong Zhang <yong.zhang0@gmail.com>
Signed-off-by: Venkatesh Pallipadi <venki@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
LKML-Reference: <1286237003-12406-9-git-send-email-venki@google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Mike Galbraith <efault@gmx.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/sched.c
kernel/softirq.c

index 97a989b6fcff9a6cceb3bdcd23275c568db323ac..c7a66a3ebc7c4bc93e38bce1c0a172d0f2c89bce 100644 (file)
@@ -1884,8 +1884,8 @@ void account_system_vtime(struct task_struct *curr)
 
        local_irq_save(flags);
 
-       now = sched_clock();
        cpu = smp_processor_id();
+       now = sched_clock_cpu(cpu);
        delta = now - per_cpu(irq_start_time, cpu);
        per_cpu(irq_start_time, cpu) = now;
        /*
index 267f7b763ebb390defa77a3667d26a8aefc1e095..79ee8f1fc0e71a343cf7de924c8ae5fa69b554b3 100644 (file)
@@ -296,10 +296,16 @@ void irq_enter(void)
 
        rcu_irq_enter();
        if (idle_cpu(cpu) && !in_interrupt()) {
-               __irq_enter();
+               /*
+                * Prevent raise_softirq from needlessly waking up ksoftirqd
+                * here, as softirq will be serviced on return from interrupt.
+                */
+               local_bh_disable();
                tick_check_idle(cpu);
-       } else
-               __irq_enter();
+               _local_bh_enable();
+       }
+
+       __irq_enter();
 }
 
 #ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED