[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.0906271042450.12287-100000@netrider.rowland.org>
Date: Sat, 27 Jun 2009 10:51:33 -0400 (EDT)
From: Alan Stern <stern@...land.harvard.edu>
To: "Rafael J. Wysocki" <rjw@...k.pl>
cc: Greg KH <gregkh@...e.de>, LKML <linux-kernel@...r.kernel.org>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
Linux-pm mailing list <linux-pm@...ts.linux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
Arjan van de Ven <arjan@...radead.org>
Subject: Re: [patch update] PM: Introduce core framework for run-time PM of
I/O devices (rev. 6)
On Sat, 27 Jun 2009, Rafael J. Wysocki wrote:
> > Speaking of races, have you noticed that the way power.work_done gets
> > used is racy?
>
> Not really. :-)
>
> > You can't wait for the completion before releasing the
> > lock, but then anything could happen.
> >
> > A safer approach would be to use a wait_queue.
>
> I'm not sure what you mean exactly. What's the race?
Come to think of it, there really is a problem here. Because the
wait_for_completion call occurs outside the spinlock, it can race with
the init_completion call. It's not good for both of them to run at the
same time; the completion's internal spinlock and list pointers could
get corrupted.
Therefore I stand by my original assertion: The struct completion
should be replaced with a wait_queue. Set the runtime_error field to
-EINPROGRESS initially, and make other threads wait until the value
changes.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists