public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
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. 2)
Date: Sun, 23 Mar 2008 19:41:39 +0100	[thread overview]
Message-ID: <200803231941.41079.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0803222157550.13906-100000@netrider.rowland.org>

On Sunday, 23 of March 2008, Alan Stern wrote:
> On Sun, 23 Mar 2008, Rafael J. Wysocki wrote:
> 
> > On Sunday, 23 of March 2008, Alan Stern wrote:
> > > On Sat, 22 Mar 2008, Rafael J. Wysocki wrote:
> > > 
> > [--snip--]
> > > 
> > > No, you have missed the entire point.  The problem doesn't exist in the
> > > current code; it exists only if we switch over to using a single list.  
> > > Routines like dpm_suspend() won't be able to use list_for_each_entry()
> > > to traverse the list because entries may be removed by other threads
> > > during the traversal.  Even list_for_each_entry_safe() won't work
> > > correctly without careful attention to details.
> > 
> > Ah, ok.  Thanks for the clarification.
> > 
> > Doesn't it help that we traverse the list under dpm_list_mtx?  Anyone who
> > removes an entry is required to take dpm_list_mtx that we're holding while
> > the list is traversed except when the callbacks are invoked.
> 
> It doesn't help.  What _does_ help is the fact that these traversals 
> are all serialized (since only one thread can carry out a system sleep 
> at any time).
> 
> > The only problem I see is when the device currently being handled is removed
> > from the list by a concurrent thread.  Is that you were referring to?
> 
> Yes, that is the problem.  If you try to work around it by using
> list_for_each_entry_safe() then you run into a problem when a
> concurrent thread removes the device _following_ the one being handled
> (or when the device being handled is the last one on the list and a
> concurrent thread registers a new device, which can only happen in
> dpm_prepare()).
> 
> It's not hard to fix.  Just something to be aware of.

Yes, I've almost finished a new patch taking that into account.  I'll send it
soon in a separate thread.
 
> P.S.: Oh yes, another related issue...  We should call get_device() and 
> put_device() while holding dpm_list_mtx.  Otherwise the device 
> structure might vanish when the callbacks are invoked.

Good idea.

Thanks,
Rafael

  reply	other threads:[~2008-03-23 18:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-21  0:01 [RFC][PATCH] PM: Introduce new top level suspend and hibernation callbacks (rev. 2) Rafael J. Wysocki
2008-03-21  0:21 ` [linux-pm] " Johannes Berg
2008-03-21  0:26   ` Rafael J. Wysocki
2008-03-25  9:49   ` Oliver Neukum
2008-03-25 13:06     ` Rafael J. Wysocki
2008-03-25 13:15       ` Oliver Neukum
2008-03-25 14:19         ` Alan Stern
2008-03-25 14:24           ` Oliver Neukum
2008-03-25 14:33             ` Alan Stern
2008-03-25 19:48               ` Oliver Neukum
2008-03-25 20:41                 ` Rafael J. Wysocki
2008-03-25 20:49                   ` Oliver Neukum
2008-03-25 20:56                     ` Rafael J. Wysocki
2008-03-26 14:10                       ` Alan Stern
2008-03-26 14:24                         ` Oliver Neukum
2008-03-26 14:40                           ` Alan Stern
2008-03-26 15:42                             ` Oliver Neukum
2008-03-26 16:36                               ` Alan Stern
2008-03-26 20:46                                 ` Rafael J. Wysocki
2008-03-27  2:48                                   ` Alan Stern
2008-03-21  1:21 ` Alan Stern
2008-03-21  2:14   ` Rafael J. Wysocki
2008-03-21  2:53     ` Alan Stern
2008-03-22 22:17       ` Rafael J. Wysocki
2008-03-22 23:28         ` Alan Stern
2008-03-22 23:44           ` Rafael J. Wysocki
2008-03-23  2:07             ` Alan Stern
2008-03-23 18:41               ` Rafael J. Wysocki [this message]
2008-03-21  8:15 ` Sam Ravnborg
2008-03-23 21:16   ` 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=200803231941.41079.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