From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757365AbYG1TmB (ORCPT ); Mon, 28 Jul 2008 15:42:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752526AbYG1Tlx (ORCPT ); Mon, 28 Jul 2008 15:41:53 -0400 Received: from www.tglx.de ([62.245.132.106]:39556 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbYG1Tlw (ORCPT ); Mon, 28 Jul 2008 15:41:52 -0400 Date: Mon, 28 Jul 2008 21:38:44 +0200 (CEST) From: Thomas Gleixner To: Andi Kleen cc: Linus Torvalds , Andrew Morton , LKML , Ingo Molnar , Dhaval Giani , Venkatesch Pallipadi , Len Brown Subject: Re: [PATCH] ACPI/CPUIDLE: prevent setting pm_idle to NULL In-Reply-To: <20080728174644.GC30344@one.firstfloor.org> Message-ID: References: <20080728174644.GC30344@one.firstfloor.org> User-Agent: Alpine 1.10 (LFD 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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