From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: pm list <linux-pm@lists.linux-foundation.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Greg KH <greg@kroah.com>, Len Brown <lenb@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Alexey Starikovskiy <astarikovskiy@suse.de>,
David Brownell <david-b@pacbell.net>, Pavel Machek <pavel@ucw.cz>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [RFC][PATCH] PM: Introduce new top level suspend and hibernation callbacks (rev. 3)
Date: Wed, 26 Mar 2008 21:54:01 +0100 [thread overview]
Message-ID: <200803262154.03129.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0803261633190.9881-100000@iolanthe.rowland.org>
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
next prev parent reply other threads:[~2008-03-26 20:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-24 17:39 [RFC][PATCH] PM: Introduce new top level suspend and hibernation callbacks (rev. 3) Rafael J. Wysocki
2008-03-24 20:14 ` Alan Stern
2008-03-24 21:18 ` Rafael J. Wysocki
2008-03-25 15:06 ` Alan Stern
2008-03-25 20:35 ` Rafael J. Wysocki
2008-03-26 14:03 ` Alan Stern
2008-03-26 20:26 ` Rafael J. Wysocki
2008-03-26 20:36 ` Alan Stern
2008-03-26 20:54 ` Rafael J. Wysocki [this message]
2008-03-24 22:18 ` Rafael J. Wysocki
2008-03-25 11:55 ` Oliver Neukum
2008-03-25 12:40 ` Rafael J. Wysocki
2008-03-25 13:37 ` Oliver Neukum
2008-03-25 14:24 ` Alan Stern
2008-03-25 14:29 ` Alan Stern
2008-03-25 15:12 ` Alan Stern
2008-03-25 20:39 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200803262154.03129.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=astarikovskiy@suse.de \
--cc=benh@kernel.crashing.org \
--cc=david-b@pacbell.net \
--cc=greg@kroah.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox