public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Linux PM list <linux-pm@vger.kernel.org>,
	mark gross <markgross@thegnar.org>,
	LKML <linux-kernel@vger.kernel.org>, NeilBrown <neilb@suse.de>
Subject: Re: [RFC][PATCH 2/2] PM / Sleep: Introduce cooperative suspend/hibernate mode
Date: Mon, 17 Oct 2011 14:20:09 -0700	[thread overview]
Message-ID: <1318886409.3125.106.camel@work-vm> (raw)
In-Reply-To: <201110172238.18027.rjw@sisk.pl>

On Mon, 2011-10-17 at 22:38 +0200, Rafael J. Wysocki wrote:
> On Monday, October 17, 2011, John Stultz wrote:
> > Though as I've been thinking about it, there may be a way to do a
> > userland solution that uses the wakeup_count that isn't so inefficient.
> > Basically, its a varient of Mark's wakeup-device idea, but moved out to
> > userland.
> > 
> > There is a userland PM daemon. Its responsible for both suspending the
> > system, *and* handing all wakeup events.
> > 
> > Normal wakeup consumers open wakeup devices with a special library which
> > passes the open request through the PM daemon. The PM daemon opens the
> > device and provides a pipe fd back to the application, and basically
> > acts as a middle-man.
> > 
> > The PM daemon then cycles, doing the following:
> > 
> > while(1) {
> > 	wakeup_count = read_int(wakeup_count_fd) /*possibly blocking*/
> > 	if (wakeup_count != last_wakeup) {
> > 		have_data = check_open_fds(fds);
> > 		if (have_data)
> > 			process_fds(fds);
> > 		last_wakeup = wakeup_count;
> > 	}
> > 	write_int(wakeup_count_fd, wakeup_count);
> > 	attempt_suspend();
> > }
> > 
> > 
> > Where check_open_fds() does a non-blocking select on all the fds that
> > the PM deamon has opened on behalf of applications, and process_fds()
> > basically writes any available data from the opened fds over to the
> > application through the earlier setup pipe. The daemon's write to the
> > pipe could be blocking, to ensure the application has read all of the
> > necessary data before the deamon continues trying to suspend.
> > 
> > Provided there is some suspend_inhibit/allow command that userspace can
> > make to the PM damon, this approach then provides a similar
> > select/wakelock/read pattern as what Android uses. The only other
> > features we might want is suggestion from Peter that
> > the /sys/power/state be only able to be opened by one application, so
> > that on systems which don't have the PM deamon running, applications
> > like the firmware update tool can try opening /sys/power/state and
> > blocking anyone from suspending under it.
> > 
> > Thoughts?
> 
> Well, that's kind of like I thought it might work when I introduced
> wakeup_count. :-)  So, I definitely don't think it's a bad approach.
> If it addesses all your use cases, I'd say we can go for it, but I'd
> like to explore the alternatives as far as we can to avoid going back
> to them some time in future.

Do forgive me for not seeing it earlier. But until I considered the idea
of the PM deamon handling the data as well as the wakeup_count, I didn't
really see a solution with a workable API (requiring full communication
before suspending didn't seem very usable in my mind, but I'm still
happy to entertain it if folks can get working protypes going to demo
it).

I of course am still interested in considering other approaches. But
I'll probably see how far I can get in prototyping this current userland
approach to see what issues it runs up against.

> As for single-opening /sys/power/state, I don't think it will be
> sufficient, because of the hibernate user space interface that doesn't
> work on the basis of /sys/power/state.  It would have to be something
> like /sys/power/manage that Alan has suggested (which opens one more
> possibility, but see my reply to Alan).

Right. I forgot about hibernate.

Although maybe if any of the sysfs devices are open, we could return
error on open to all of them? 

I'm just trying to think of what we can do without introducing a new
ABI.

thanks
-john


  reply	other threads:[~2011-10-17 21:20 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 19:45 [RFC][PATCH 0/2] PM / Sleep: Extended control of suspend/hibernate interfaces Rafael J. Wysocki
2011-10-13 19:49 ` [RFC][PATCH 1/2] PM / Sleep: Add mechanism to disable suspend and hibernation Rafael J. Wysocki
2011-10-13 19:50 ` [RFC][PATCH 2/2] PM / Sleep: Introduce cooperative suspend/hibernate mode Rafael J. Wysocki
2011-10-13 22:58   ` John Stultz
2011-10-14 22:49     ` Rafael J. Wysocki
2011-10-15  0:04       ` John Stultz
2011-10-15 21:29         ` Rafael J. Wysocki
2011-10-17 16:48           ` John Stultz
2011-10-17 18:19             ` Alan Stern
2011-10-17 19:08               ` John Stultz
2011-10-17 20:07                 ` Alan Stern
2011-10-17 20:34                   ` John Stultz
2011-10-17 20:38                 ` Rafael J. Wysocki
2011-10-17 21:20                   ` John Stultz [this message]
2011-10-17 21:19                 ` NeilBrown
2011-10-17 21:43                   ` John Stultz
2011-10-17 23:06                     ` NeilBrown
2011-10-17 23:14                     ` NeilBrown
2011-10-17 21:13             ` Rafael J. Wysocki
2011-10-14  5:52 ` [RFC][PATCH 0/2] PM / Sleep: Extended control of suspend/hibernate interfaces NeilBrown
2011-10-14 16:00   ` Alan Stern
2011-10-14 21:07     ` NeilBrown
2011-10-15 18:34       ` Alan Stern
2011-10-15 21:43         ` NeilBrown
2011-10-15 22:10   ` Rafael J. Wysocki
2011-10-16  2:49     ` Alan Stern
2011-10-16 14:51       ` Alan Stern
2011-10-16 20:32         ` Rafael J. Wysocki
2011-10-17 15:33           ` Alan Stern
2011-10-17 21:10             ` Rafael J. Wysocki
2011-10-17 21:27             ` Rafael J. Wysocki
2011-10-18 17:30               ` Alan Stern
2011-10-16 22:34         ` NeilBrown
2011-10-17 14:45           ` Alan Stern
2011-10-17 22:49             ` NeilBrown
2011-10-17 23:47               ` John Stultz
2011-10-18  2:13                 ` NeilBrown
2011-10-18 17:11                   ` Alan Stern
2011-10-18 22:55                     ` NeilBrown
2011-10-19 16:19                       ` Alan Stern
2011-10-20  0:17                         ` NeilBrown
2011-10-20 14:29                           ` Alan Stern
2011-10-21  5:05                             ` NeilBrown
2011-10-21  5:23                             ` lsusd - The Linux SUSpend Daemon NeilBrown
2011-10-21 16:07                               ` Alan Stern
2011-10-21 22:34                                 ` NeilBrown
2011-10-22  2:00                                   ` Alan Stern
2011-10-22 16:31                                     ` Alan Stern
2011-10-23  3:31                                       ` NeilBrown
2011-10-23  8:21                                     ` NeilBrown
2011-10-23 12:48                                       ` Rafael J. Wysocki
2011-10-23 23:04                                         ` NeilBrown
2011-10-23 16:17                                       ` Alan Stern
2011-10-21 20:10                               ` david
2011-10-21 22:09                                 ` NeilBrown
2011-10-26 14:31                               ` Jan Engelhardt
2011-10-27  4:34                                 ` NeilBrown
2011-10-31 15:11           ` [RFC][PATCH 0/2] PM / Sleep: Extended control of suspend/hibernate interfaces Richard Hughes
2011-10-16 20:26       ` Rafael J. Wysocki
2011-10-16 23:48     ` NeilBrown
2011-10-17 15:43       ` Alan Stern
2011-10-17 22:02       ` Rafael J. Wysocki
2011-10-17 23:36         ` NeilBrown
2011-10-22 22:07           ` Rafael J. Wysocki
2011-10-23  2:57             ` NeilBrown
2011-10-23 13:16               ` Rafael J. Wysocki
2011-10-23 23:44                 ` NeilBrown
2011-10-24 10:23                   ` Rafael J. Wysocki
2011-10-25  2:52                     ` NeilBrown
2011-10-25  7:47                       ` Valdis.Kletnieks
2011-10-25  8:35                         ` Rafael J. Wysocki
2011-10-23 15:50             ` Alan Stern
2011-10-27 21:06               ` Rafael J. Wysocki
2011-10-28  0:02               ` NeilBrown
2011-10-28  8:27                 ` Rafael J. Wysocki
2011-10-28 15:08                   ` Alan Stern
2011-10-28 17:26                     ` Rafael J. Wysocki
2011-10-31 19:55 ` Ming Lei
2011-10-31 21:15   ` NeilBrown
2011-10-31 21:23     ` Ming Lei

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=1318886409.3125.106.camel@work-vm \
    --to=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=markgross@thegnar.org \
    --cc=neilb@suse.de \
    --cc=rjw@sisk.pl \
    --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