Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965881AbZLHToe (ORCPT ); Tue, 8 Dec 2009 14:44:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965879AbZLHToa (ORCPT ); Tue, 8 Dec 2009 14:44:30 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:48968 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756212AbZLHTo3 (ORCPT ); Tue, 8 Dec 2009 14:44:29 -0500 From: "Rafael J. Wysocki" To: Linus Torvalds Subject: Re: Async resume patch (was: Re: [GIT PULL] PM updates for 2.6.33) Date: Tue, 8 Dec 2009 20:44:52 +0100 User-Agent: KMail/1.12.3 (Linux/2.6.32-rjw; KDE/4.3.3; x86_64; ; ) Cc: Alan Stern , Zhang Rui , LKML , ACPI Devel Maling List , pm list References: <200912081323.50606.rjw@sisk.pl> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912082044.52098.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1858 Lines: 42 On Tuesday 08 December 2009, Linus Torvalds wrote: > > On Tue, 8 Dec 2009, Rafael J. Wysocki wrote: > > > > The wait queue plus the op_complete flag combo plays the role of the locking > > in the Linus' picture > > Please just use the lock. Don't make up your own locking crap. Really. > > Your patch is horrible. Exactly because your locking is horribly > mis-designed. You can't say things are complete from an interrupt, for > example, since you made it some random bitfield, which has unknown > characteristics (ie non-atomic read-modify-write etc). I didn't assume anyone would check it from an interrupt, because I didn't see a point. In fact I didn't assume anyone except for the PM core would check it. In case this assumption is wrong, it can be easily put under the dev->sem that we take anyway before calling the bus type (etc.) callbacks. Anyway, if we use an rwsem, it won't be checkable from interrupt context just as well. > The fact is, any time anybody makes up a new locking mechanism, THEY > ALWAYS GET IT WRONG. Don't do it. > > I suggested using the rwsem locking for a good reason. It made sense. It > was simpler. Just do it that way, stop making up crap. Suppose we use rwsem and during suspend each child uses a down_read() on a parent and then the parent uses down_write() on itself. What if, whatever the reason, the parent is a bit early and does the down_write() before one of the children has a chance to do the down_read()? Aren't we toast? Do we need any direct protection against that or does it just work itself out in a way I just don't see right now? 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/