Re: [PATCH] ACPI/CPUIDLE: prevent setting pm_idle to NULL

From: Thomas Gleixner
Date: Mon Jul 28 2008 - 15:42:03 EST


On Mon, 28 Jul 2008, Andi Kleen wrote:
> > + /*
> > + * Fall back to the default idle loop, when pm_idle_save had
> > + * been initialized.
> > + */
> > + if (pm_idle_save) {
> > + pm_idle = pm_idle_save;
> > + /* Relies on interrupts forcing exit from idle. */
> > + synchronize_sched();
> > + }
>
> I think it would be better to fall back to default_idle (which
> might need to be exported) when the old pointer is NULL.

No, falling back to default_idle is wrong as hell. When pm_idle was
set to mwait_idle or whatever then you override pm_idle to
default_idle for no good reason.

The problem here is that the acpi/cpuidle code can be in a state where
the _save/old variables _ARE_ NULL because they had not been
initialized with the original pm_idle before the module is removed or
the cst state changes. So all we have to do is to prevent pm_idle to
be set to NULL.

> Now with your patch
> the cpuidle idle code would run with inconsistent state for some time,
> which is probably not good.

Err, this happens when the original pm_idle pointer _is_ restored. But
if the _save/old pointer is NULL we crash the system and that's what
my patch prevents.

So nothing runs with an inconsistent state. If pm_idle_save contains
the original pm_idle value we restore, if it is NULL we do not touch
pm_idle and keep the original value.

Thanks,

tglx
--
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/