Re: [PATCH 11/19] OpenRISC: Idle/Power management

From: Arnd Bergmann
Date: Mon Jun 20 2011 - 04:21:05 EST


On Sunday 19 June 2011 13:43:37 Jonas Bonn wrote:
> +void cpu_idle(void)
> +{
> + unsigned int cpu = smp_processor_id();
> +
> + set_thread_flag(TIF_POLLING_NRFLAG);
> +
> + /* endless idle loop with no priority at all */
> + while (1) {
> + tick_nohz_stop_sched_tick(1);
> +
> + while (!need_resched()) {
> + check_pgt_cache();
> + rmb();
> +
> +/* if (cpu_is_offline(cpu))
> + play_dead();
> +*/
> + clear_thread_flag(TIF_POLLING_NRFLAG);
> +
> + local_irq_disable();
> + /* Don't trace irqs off for idle */
> + stop_critical_timings();
> + if (powersave != NULL )
> + powersave();
> + start_critical_timings();
> + local_irq_enable();
> + set_thread_flag(TIF_POLLING_NRFLAG);
> + }
> +
> + tick_nohz_restart_sched_tick();
> + preempt_enable_no_resched();
> + schedule();
> + preempt_disable();
> + }

Shouldn't you check need_resched() inside of local_irq_disable? Otherwise
you may get interrupted between the check at the start of the loop and
the irq_disable, which tries to wake up another process just before you go
to sleep indefinitely.

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/