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

Arnd Bergmann
2011-08-31T13:45:38Z

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