Re: [patch v2 15/35] Hexagon: Add init_task and process functions

From: Arnd Bergmann
Date: Wed Aug 31 2011 - 09:45:40 EST


On Tuesday 30 August 2011, Richard Kuo wrote:
> Fixed potential race-to-sleep condition in cpu_idle(). I hope.
>
> If called with interrupts disabled, our __vmwait() actually just returns
> without servicing it. Let me know if there's any other condition that
> I've missed...

The race should be gone now, but

> +void cpu_idle(void)
> +{
> + while (1) {
> + tick_nohz_stop_sched_tick(1);
> + local_irq_disable();
> + while (!need_resched()) {
> + idle_sleep();
> + /* interrupts wake us up, but aren't serviced */
> + local_irq_enable(); /* service interrupt */
> + local_irq_disable();
> + }
> + tick_nohz_restart_sched_tick();
> + schedule();
> + }
> +}

you now call schedule() with interrupts disabled, which isn't strictly
allowed.

I think it should all be fine if you write it as

while (1) {
tick_nohz_stop_sched_tick(1);
local_irq_disable();
while (!need_resched()) {
idle_sleep();
}
local_irq_enable();
tick_nohz_restart_sched_tick();
schedule();
}


Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/