From: Daniel Drake <dsd@laptop.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-pm@lists.linux-foundation.org
Subject: Re: Trying to understand new wakeup events architecture
Date: Thu, 13 Jan 2011 20:41:54 +0000 [thread overview]
Message-ID: <1294951314.2228.19.camel@polyethylene> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1101131526400.2022-100000@iolanthe.rowland.org>
On Thu, 2011-01-13 at 15:31 -0500, Alan Stern wrote:
> On Thu, 13 Jan 2011, Daniel Drake wrote:
>
> > On Thu, 2011-01-13 at 20:34 +0100, Rafael J. Wysocki wrote:
> > > It looks like Daniel wants the wakeup events framework to store the last
> > > active wakeup source information somewhere (eg. in a file in /sys/power).
> > > I'm a little bit worried about that, because potentially there may be many
> > > wakeup events occuring at run time, in which case it would be a significant
> > > performance overhead to update the "last active wakeup source" info every
> > > time (and a scalability issue, because every code path handling a wakeup
> > > source would want to update the same sysfs file). Also, collecting that
> > > information at run time doesn't seem to be particularly useful.
> >
> > This was one thing that confused me reading about the wakeup events
> > architecture, and I'm still not entirely clear.
> >
> > Your definition of "wakeup event" is an event that happens, during
> > regular system operation, that should prevent the system from going to
> > sleep. Is that accurate?
>
> My understanding (which probably isn't exactly the same as Rafael's) is
> that a "wakeup event" is any event which should either prevent the
> system from going to sleep or should wake up the system if it is
> already asleep. After all, these are the same events (user typing,
> network packet arriving, alarm firing) -- the only difference is what
> state the system is in when they occur.
OK, that makes it clearer.
> > When I refer to "wakeup event" I'm referring exclusively to events that
> > happen when the system is suspended, that cause it to wake up and resume
> > operation.
> >
> > > It may be useful to know what device has actually woken up the system from
> > > suspend. To that end, I think the only really valid approach is to retrieve
> > > this information from the platform firmware early during resume and export
> > > it through a sysfs attribute afterwards. We can develop a generic helper
> > > code for that second part, but the first one has to be platform-specific.
> > >
> > > Daniel, what exactly does your user space use this information for?
> >
> > We're talking the same language here. I'd welcome a generic helper.
> >
> > There are several different cases, but here is one example that should
> > be illustrative:
> >
> > 1) System is idle, hence it goes to sleep with display on, with rtcwake
> > timer for 5 minutes in the future, as well as various other wakeup
> > sources active (keyboard, mouse, network, ...)
> >
> > 2) 5 minutes passes and system resumes. Userspace determines that the
> > wakeup source was the RTC alarm. In other words, the system is still
> > idle. Since the user doesn't seem to be doing anything and might not
> > even be watching, we dim the screen a bit to save some power. Then we go
> > back to sleep.
> >
> > 3) A few minutes later, the user starts typing. The system resumes.
> > Userspace checks the wakeup reason, notes that it was woken up due to
> > local user activity. So the display is restored to normal brightness.
> > The idle-check timer is started again, ready to go to sleep a minute or
> > so after user inactivity.
>
> What happens when the system wakes up because more than one event
> happened? For example, what if the user starts typing at exactly the
> same moment as the 5-minute RTC alarm fires?
I think there is some guarantee that the wakeup source is identifiable.
One of those things has to have happened first, even if they were very
close in time. If it was the keyboard waking up in #2, the keyboard is
presented as the wakeup reason, and the system decides to keep running
for a while, restarting its user inactivity timer for the next suspend
(where we go back to #1).
If the RTC alarm wakes the system but then there is a keypress during
resume, this will get caught by a userspace daemon, returning the system
to "normal state" with the user inactivity timer. If it happens as the
system is going into suspend, the system will go into suspend then will
cause a new immediate system resume with the keyboard identified as the
wakeup source.
There may be some race conditions here, which Rafael's recent
infrastructure work may be on the road to fixing.
Daniel
next prev parent reply other threads:[~2011-01-13 20:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 17:57 Trying to understand new wakeup events architecture Daniel Drake
2010-12-15 22:33 ` Rafael J. Wysocki
2010-12-16 14:39 ` Daniel Drake
2011-01-12 15:01 ` Daniel Drake
2011-01-12 20:02 ` Rafael J. Wysocki
2011-01-13 15:06 ` Daniel Drake
2011-01-13 15:14 ` Alan Stern
2011-01-13 15:56 ` Daniel Drake
2011-01-13 16:55 ` Alan Stern
2011-01-13 19:34 ` Rafael J. Wysocki
2011-01-13 20:01 ` Daniel Drake
2011-01-13 20:31 ` Alan Stern
2011-01-13 20:41 ` Daniel Drake [this message]
2011-01-14 2:11 ` Paul Fox
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=1294951314.2228.19.camel@polyethylene \
--to=dsd@laptop.org \
--cc=linux-pm@lists.linux-foundation.org \
--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