Skip to content

Commit

Permalink
sched: Call tick_check_idle before __irq_enter
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Venkatesh Pallipadi <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Venkatesh Pallipadi authored and Ingo Molnar committed Oct 18, 2010
1 parent aa48380 commit d267f87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1974,8 +1974,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;
/*
Expand Down
12 changes: 9 additions & 3 deletions kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d267f87

Please sign in to comment.