Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759952AbYCZUyW (ORCPT ); Wed, 26 Mar 2008 16:54:22 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755075AbYCZUyM (ORCPT ); Wed, 26 Mar 2008 16:54:12 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:41029 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752214AbYCZUyL (ORCPT ); Wed, 26 Mar 2008 16:54:11 -0400 From: "Rafael J. Wysocki" To: Alan Stern Subject: Re: [RFC][PATCH] PM: Introduce new top level suspend and hibernation callbacks (rev. 3) Date: Wed, 26 Mar 2008 21:54:01 +0100 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Cc: pm list , ACPI Devel Maling List , Greg KH , Len Brown , LKML , Alexey Starikovskiy , David Brownell , Pavel Machek , Benjamin Herrenschmidt References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803262154.03129.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2527 Lines: 57 On Wednesday, 26 of March 2008, Alan Stern wrote: > On Wed, 26 Mar 2008, Rafael J. Wysocki wrote: > > > On Wednesday, 26 of March 2008, Alan Stern wrote: > > > On Tue, 25 Mar 2008, Rafael J. Wysocki wrote: > > > > > > > > I just thought of another problem. At the point where > > > > > local_irq_disable() is called, in between device_suspend() and > > > > > device_power_down(), it is possible in a preemptible kernel that > > > > > another task is holding dpm_list_mtx and is in the middle of updating > > > > > the list pointers. This would mess up the traversal in > > > > > device_power_down(). > > > > > > > > > > I'm not sure about the best way to prevent this. Is it legal to call > > > > > unlock_mutex() while interrupts or preemption are disabled? > > > > > > > > Well, I think it is, but I'm not sure how that can help. > > > > > > > > To prevent the race from happening, we can lock dpm_list_mtx before switching > > > > interrupts off in kernel/power/main.c:suspend_enter() and analogously in > > > > kernel/power/disk.c . > > > > > > That's right. And once interrupts are turned off you should unlock > > > dpm_list_mtx again, in case a noirq method wants to unregister a > > > device. > > > > Why would a noirq method want to do that? IMO, it's not a big deal if noirq > > methods are not allowed to unregister devices. > > Okay, that's fine. It keeps things simple. > > > > Hence my question: Is it legal to call unlock_mutex() while interrupts are > > > disabled? > > > > Well, I suspect that will confuse lockdep quite a bit. Otherwise, I don't see > > a problem with it (it's just changing the value of a shared variable after > > all). > > Then you have your answer. Perhaps have device_suspend() exit with the > mutex held and have device_resume() release it (with appropriate > handling for error situations, of course). That wouldn't work, because enable_nonboot_cpus() is called before device_resume() and the notifiers in there may want to unregister devices if some CPUs fail to go online. I added two accessor functions device_pm_lock() and device_pm_unlock() to be called just prior to disabling interrupts and right after enabling them, respectively, in the higher-level PM core (ie. kernel/power/main(disk).c). Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/