Re: [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm3-V0.7.31-19

From: Ingo Molnar
Date: Wed Dec 01 2004 - 11:33:29 EST



* Ingo Molnar <mingo@xxxxxxx> wrote:

> i think i found the bug - it's an upstream ACPI bug. Does the patch
> below (or the -31-19 kernel, which i've just uploaded) fix the xruns?
>
> the upstream ACPI bug is this: 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.

i've attached the particular trace from Rui's collection of traces which
nicely shows the ACPI race in action. Here are the relevant events:

swapper-0 08000000 0.840ms (+0.000ms): preempt_schedule (cpu_idle)
swapper-0 ........ 0.913ms (+0.000ms): -> IRQ 5-3052 [ 0000001d 0000008c ]: wake_up_process
swapper-0 08000001 0.913ms (+0.920ms): acpi_processor_idle (cpu_idle)
swapper-0 ........ 1.834ms (+0.000ms): common_interrupt: [ e0022266 00000000 00000000 ]
swapper-0 88010001 1.834ms (+0.000ms): direct_timer_interrupt (do_IRQ)
IRQ 5-3052 80000002 1.848ms (+0.000ms): __switch_to (__sched_text_start)

i.e. at timestamp 0.840ms cpu_idle() got preempted (it was after the
need_resched() check but before the rcu_read_lock() which disables
preemption), then at 0.913ms a task was woken up by the hardirq context,
but despite this we called into acpi_processor_idle() which slept
dutifully until the next timer interrupt hit us. Then did only the woken
up task schedule. (which caused an xrun in Rui's setup.)

Ingo

Attachment: xruntrace1-2.6.10-rc2-mm3-RT-V0.7.31-15-20041201143614.trc.gz
Description: GNU Zip compressed data