From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: NeilBrown <neilb@suse.de>,
Linux PM list <linux-pm@vger.kernel.org>,
mark gross <markgross@thegnar.org>,
LKML <linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>
Subject: Re: [RFC][PATCH 0/2] PM / Sleep: Extended control of suspend/hibernate interfaces
Date: Mon, 17 Oct 2011 23:10:17 +0200 [thread overview]
Message-ID: <201110172310.18069.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1110171046490.2430-100000@iolanthe.rowland.org>
On Monday, October 17, 2011, Alan Stern wrote:
> On Sun, 16 Oct 2011, Rafael J. Wysocki wrote:
>
> > On Sunday, October 16, 2011, Alan Stern wrote:
> > > On Sat, 15 Oct 2011, Alan Stern wrote:
> > >
> > > > Basically, what we need is a reliable way to intercept the existing
> > > > mechanisms for suspend/hibernate and to redirect the requests to the PM
> > > > daemon. When the daemon is started up in "legacy" mode, it assumes
> > > > there is a legacy client (representing the entire set of
> > > > non-wakeup-aware programs) that always forbids suspend _except_ when
> > > > one of the old mechanisms is invoked.
> > >
> > > The more I think about this, the better it seems. In essence, it
> > > amounts to "virtualizing" the existing PM interface.
> > >
> > > Let's add /sys/power/manage, and make it single-open.
> >
> > I'm not sure how to do that in sysfs.
>
> If we don't implement the virtualization in the kernel, as Neil
> suggests, then /sys/power/manage isn't necessary. (And yes, I don't
> know how to make sysfs files single-open either -- probably there's no
> way to do it.)
>
> > Also I'm not sure what the real difference between /sys/power/manage
> > and my /sys/power/sleep_mode is (I could make /sys/power/sleep_mode
> > single-open too, if I knew how to do that).
>
> We really need to determine up front what userspace environments we
> want to support. It seems reasonable to decide that wakeup-awareness
> will be available only on systems that use a centralized mechanism for
> initiating system sleeps. Whether that mechanism is pm-utils or a
> vendor-specific program in an embedded system shouldn't matter too much
> -- the important thing is that it can easily be changed to send
> requests to a PM daemon instead of writing directly to /sys/power/state
> or /dev/snapshot.
>
> (Sending requests to the daemon need not be difficult; we could write a
> special program just for that purpose.)
>
> If we do things this way, it leaves open the possibility of bypassing
> all the wakeup-aware code. That's not necessarily a bad thing.
OK, I'd like to focus on this a bit more. I'll reply to the rest of your
message separately.
_If_ we are going to use an extra interface for switching "modes" (e.g. current
behavior vs something that uses wakeup events detection unconditionally), then
it may be /dev/sleepctl working as follows:
1. It may be open only *once* for writing.
2. It may be open multiple times in parallel for reading.
3. While open for writing, it will cause all writes to /sys/power/wakeup_count
fail (e.g. return -EACCES).
4. Writing to it will unconditionally store the written value as saved_count
(this will allow the writer to effectively block all suspend/hibernate
interfaces by writing a "known bad" number to it).
5. Reading from it will work like reading from /sys/power/wakeup_count.
This way, the writer using it (the power manager) won't have to open
/sys/power/wakeup_count in addition to opening /dev/sleepctl.
Next, we can add the SLEEPCTL_RELAX and SLEEPCTL_STAY_AWAKE ioctls to it in the
following way:
SLEEPCTL_STAY_AWAKE: cause all attempts to use /sys/power/state and the
/dev/snapshot's ioctls to block until SLEEPCTL_RELAX is executed for
the same file descriptor.
SLEEPCTL_RELAX(arg): if arg is 0, reverse the previous SLEEPCTL_STAY_AWAKE and
return. If arg is different from 0, reverse the previous SLEEPCTL_STAY_AWAKE
and prepare the kernel to carry out an equivalent of SLEEPCTL_STAY_AWAKE on
the given file descriptor and send the calling process the SIGPWR signal
on the first wakeup event.
Then, the John's backup scenario will look like this:
1. SLEEPCTL_STAY_AWAKE
2. Set up the wakealarm.
3. SLEEPCTL_RELAX(1)
4. Sleep with timeout to wake up at time T (slightly before the wakealarm).
5. (a) if the system doesn't suspend and there are no wakeup events,
do SLEEPCTL_STAY_AWAKE (when woken up) and create a backup.
(b) if there is a wakeup event, check if the current time is earlier than
T and go to 3 if so. Otherwise, create a backup (the kernel has already
done the SLEEPCTL_STAY_AWAKE for us).
Thanks,
Rafael
next prev parent reply other threads:[~2011-10-17 21:07 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 19:45 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
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 [this message]
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=201110172310.18069.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=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=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
all inboxes | Powered by JetHome®