]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] acpi_processor_idle() latency fix
authorIngo Molnar <mingo@elte.hu>
Thu, 2 Dec 2004 23:45:53 +0000 (15:45 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 2 Dec 2004 23:45:53 +0000 (15:45 -0800)
We check need_resched() _before_ disabling preemption.  This opens up the
following scenario:

 swapper: !need_resched()
 [IRQ context]
wakes up a task
marks idle task as need-resched

 swapper: acpi_processor_idle(); // sleeps until next irq

instant 1msec latency introduced...

normally default_idle() is safe because it re-checks need_resched with
interrupts disabled before it truly halts the CPU.  But
acpi_processor_idle() doesnt seem to be doing this!  Your trace clearly
shows a missed preemption due to ACPI.  I'm wondering why no-one has
triggered this before, it's a really bad bug that should be fixed in
2.6.10.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/acpi/processor.c

index 0076cbb5070110a39eaafa531b368f168fbbba52..64ce1e92e1f10aaac8afdbaa65cd8ff3287eef5c 100644 (file)
@@ -353,6 +353,15 @@ acpi_processor_idle (void)
         */
        local_irq_disable();
 
+       /*
+        * Check whether we truly need to go idle, or should
+        * reschedule:
+        */
+       if (unlikely(need_resched())) {
+               local_irq_enable();
+               return;
+       }
+
        cx = &(pr->power.states[pr->power.state]);
 
        /*