Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756014AbZF0Ovl (ORCPT ); Sat, 27 Jun 2009 10:51:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751919AbZF0Ovb (ORCPT ); Sat, 27 Jun 2009 10:51:31 -0400 Received: from netrider.rowland.org ([192.131.102.5]:47859 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751765AbZF0Ovb (ORCPT ); Sat, 27 Jun 2009 10:51:31 -0400 Date: Sat, 27 Jun 2009 10:51:33 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: "Rafael J. Wysocki" cc: Greg KH , LKML , ACPI Devel Maling List , Linux-pm mailing list , Ingo Molnar , Arjan van de Ven Subject: Re: [patch update] PM: Introduce core framework for run-time PM of I/O devices (rev. 6) In-Reply-To: <200906270032.45290.rjw@sisk.pl> Message-ID: 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 Content-Length: 1152 Lines: 32 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/