Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755761Ab2BVWGg (ORCPT ); Wed, 22 Feb 2012 17:06:36 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:37780 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755647Ab2BVWGf (ORCPT ); Wed, 22 Feb 2012 17:06:35 -0500 From: "Rafael J. Wysocki" To: "Srivatsa S. Bhat" Subject: Re: [RFC][PATCH 0/7] PM: Implement autosleep and "wake locks", take2 Date: Wed, 22 Feb 2012 23:10:21 +0100 User-Agent: KMail/1.13.6 (Linux/3.3.0-rc4+; KDE/4.6.0; x86_64; ; ) Cc: John Stultz , Linux PM list , LKML , Magnus Damm , markgross@thegnar.org, Matthew Garrett , Greg KH , Arve =?utf-8?q?Hj=C3=B8nnev=C3=A5g?= , Brian Swetland , Neil Brown , Alan Stern , Dmitry Torokhov References: <201202070200.55505.rjw@sisk.pl> <1329886179.2229.2.camel@js-netbook> <4F44AB09.9000606@linux.vnet.ibm.com> In-Reply-To: <4F44AB09.9000606@linux.vnet.ibm.com> MIME-Version: 1.0 Message-Id: <201202222310.21627.rjw@sisk.pl> X-Length: 15392 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2550 Lines: 63 On Wednesday, February 22, 2012, Srivatsa S. Bhat wrote: > On 02/22/2012 10:19 AM, John Stultz wrote: > > > On Wed, 2012-02-22 at 00:31 +0100, Rafael J. Wysocki wrote: > >> Hi all, > >> > >> After the feedback so far I've decided to follow up with a refreshed patchset. > >> The first two patches from the previous one went to linux-pm/linux-next > >> and I included the recent evdev patch from Arve (with some modifications) > >> to this patchset for completness. > > > > Hey Rafael, > > Thanks again for posting this! I've started playing around with it in a > > kvm environment, and got the following warning after echoing off > > > autosleep: > > ... > > PM: resume of devices complete after 185.615 msecs > > PM: Finishing wakeup. > > Restarting tasks ... done. > > PM: Syncing filesystems ... done. > > PM: Preparing system for mem sleep > > Freezing user space processes ... > > Freezing of tasks failed after 20.01 seconds (1 tasks refusing to freeze, wq_busy=0): > > bash D ffff880015714010 > > > Ah.. I think I know what is the problem here.. > > The kernel was freezing userspace processes and meanwhile, you wrote "off" > to autosleep. So, as a result, this userspace process (bash) just now > entered kernel mode. Unfortunately, the autosleep_lock is held for too long, > that is, something like: > > acquire autosleep_lock > modify autosleep_state > <============== "A" > pm_suspend or hibernate() > > release autosleep_lock > > At point marked "A", we should have released the autosleep lock and only then > entered pm_suspend or hibernate(). Since the current code holds the lock and > enters suspend/hibernate, the userspace process that wrote "off" to autosleep > (or even userspace process that writes to /sys/power/state will end up waiting > on autosleep_lock, thus failing the freezing operation.) > > So the solution is to always release the autosleep lock before entering > suspend/hibernation. Well, the autosleep lock is intentionally held around suspend/hibernation in try_to_suspend(), because otherwise it would be possible to trigger automatic suspend right after user space has disabled it. I think the solution is to make pm_autosleep_lock() do a _trylock() and return error code if already locked. Thanks, 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/