All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Chirantan Ekbote <chirantan@chromium.org>,
	John Stultz <john.stultz@linaro.org>
Cc: Olof Johansson <olof@lixom.net>,
	Bastien Nocera <hadess@hadess.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	snanda@chromium.org, Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Linux PM list <linux-pm@vger.kernel.org>
Subject: Re: A desktop environment[1] kernel wishlist
Date: Tue, 05 May 2015 00:12:14 +0200	[thread overview]
Message-ID: <286173531.vzKW1UoxJJ@vostro.rjw.lan> (raw)
In-Reply-To: <CAJFHJrp8R+Na73W2Jx6BJ+JnHTGZfd61d+EracgehS+ZQoZOcg@mail.gmail.com>

On Thursday, April 30, 2015 11:54:51 AM Chirantan Ekbote wrote:
> On Thu, Apr 30, 2015 at 10:23 AM, Olof Johansson <olof@lixom.net> wrote:
> > Hi,
> >
> > On Thu, Apr 30, 2015 at 10:10 AM, John Stultz <john.stultz@linaro.org> wrote:
> >> On Thu, Apr 30, 2015 at 9:25 AM, Bastien Nocera <hadess@hadess.net> wrote:
> >>> On Tue, 2014-10-21 at 10:04 -0700, John Stultz wrote:

Thanks for CCin me, John!

Let's also CC linux-pm as the people on that list may be generally interested
in this thread.

> >>>> On Tue, Oct 21, 2014 at 1:49 AM, Bastien Nocera <hadess@hadess.net>
> >>>> wrote:
> >>>> > Hey,
> >>>> >
> >>>> > GNOME has had discussions with kernel developers in the past, and,
> >>>> > fortunately, in some cases we were able to make headway.
> >>>> >
> >>>> > There are however a number of items that we still don't have
> >>>> > solutions
> >>>> > for, items that kernel developers might not realise we'd like to
> >>>> > rely
> >>>> > on, or don't know that we'd make use of if merged.
> >>>> >
> >>>> > I've posted this list at:
> >>>> > https://wiki.gnome.org/BastienNocera/KernelWishlist
> >>>> >
> >>>> > Let me know on-list or off-list if you have any comments about
> >>>> > those, so
> >>>> > I can update the list.
> >>>>
> >>>> As for: 'Export of "wake reason" when the system wakes up (rtc alarm,
> >>>> lid open, etc.) and wakealarm (/sys/class/rtc/foo/wakealarm)
> >>>> documentation'
> >>>>
> >>>> Can you expand more on the rational for the need here? Is this for UI
> >>>> for power debugging, or something else?
> >>>
> >>> This is pretty much what I had in mind:
> >>> https://www.chromium.org/chromium-os/chromiumos-design-docs/lucid-sleep
> >>>
> >>> I guess I didn't make myself understood.
> >>
> >> My, admittedly quick skim, of that design document seems to suggest
> >> that lucid sleep would be a new kernel state. That would keep the
> >> kernel in charge of determining the state transitions (ie:
> >> SUSPEND-(alarm)->LUCID-(wakelock
> >> release)->SUSPEND-(alarm)->LUCID-(power-button)->AWAKE). Then it seems
> >> userspace would be able to query the current state. This avoids some
> >> of the races I was concerned with trying to detect which irq woke us
> >> from suspend from userspace.
> >>
> 
> Tomeu has been working on making things so that we don't need a new
> kernel state.

Which is good, because adding a new kernel state like that to the mainline is
out of the question as far as I'm concerned.

>  Adding him on cc so he can correct me if I say
> something wrong.  The current idea is to have userspace runtime
> suspend any unneeded devices before starting a suspend.  This way the
> kernel will leave them alone at resume.  This behavior already exists
> in the mainline kernel.  Getting the wakeup reason can be accomplished
> by having the kernel emit a uevent with the wakeup reason.  This is
> the only change that would be necessary.

Well, that needs to be thought through carefully in my view, or it will
always be racy.

You cannot really only rely on wakeup events that have already happened,
because something requiring you to bring up the full UI may happen at
any time.  In particular, it may happen when you're about to suspend again.

For this reason, it looks like you need something along the lines of
the wakeup_count interface, but acting on subsets of devices.

It actually shouldn't be too difficult to split the existing wakeup
counter into a number of subcounters each tracking a subset of wakeup
sources and one of them might be used as the "full UI wakeup" condition
trigger in principle.

> >> That said, the Power Manager section in that document sounds a little
> >> racy as it seems to rely on asking userspace if suspend is ok, rather
> >> then using userspace wakelocks, so I'm not sure how well baked this
> >> doc is.

You cannot be "a little" racy.  Either you are racy, or you aren't.  If you
are, it's only a matter of time until someone hits the race.  How often
that will happen depends on how hard the race is to trigger and how many
users of the feature there are.  Given enough users, quite a number of them
may be unhappy.

> I'm not sure I understand what you are saying here.  If you're saying
> that the kernel is asking userspace if suspend is ok, then I can say
> that that's definitely not the case.  Currently from the kernel's
> perspective a lucid sleep resume isn't really different from a regular
> resume.  We have a hack in each driver that we care about that
> basically boils down to an if statement that skips re-initialization
> if we are entering lucid sleep.  If userspace tries to access that
> device in lucid sleep, it just gets an error.  This has actually
> caused us some headache (see the GPU process section of the doc),
> which is why we'd like to switch to using the runtime suspend approach
> I mentioned above.

That's a good plan, because that's the only way you can satisfy all of the
dependencies that may be involved.

> If instead you're saying that the power manager needs to ask the rest
> of userspace whether suspend is ok, you can think of the current
> mechanism as a sort of timed wake lock.  Daemons that care about lucid
> sleep register with the power manager when they start up.  The power
> manager then waits for these daemons to report readiness while in
> lucid sleep before starting another suspend.  So each daemon
> effectively acquires a wake lock when the system enters lucid sleep
> and releases the wake lock when it reports readiness to the power
> manager or the timeout occurs.

I think what John meant was exactly what I said above: You need a race
free mechanism to verify whether or not it is OK to suspend again (ie.
whether or not there are any unhandled events that would have woken you up
had they happened while suspended) when you're about to.  You *also* need
to be able to determine (in a race free way) whether or not any of them
require you to bring up the UI.

It looks like your use case is actually more complex than the Android's one. :-)


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  parent reply	other threads:[~2015-05-04 21:47 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21  8:49 A desktop environment[1] kernel wishlist Bastien Nocera
2014-10-21 13:11 ` Sergey
2014-10-22  2:58   ` Minchan Kim
2014-10-22 16:52   ` Dan Streetman
2014-10-22 20:16   ` Heinrich Schuchardt
2014-10-27 16:11     ` Sergey "Shnatsel" Davidoff
2014-10-27  9:23   ` Pavel Machek
2014-10-27 16:02     ` Sergey "Shnatsel" Davidoff
2014-10-31  9:36       ` Jan Kara
2014-11-03 18:21         ` Heinrich Schuchardt
2014-11-04  9:28           ` Jan Kara
2014-11-04 19:55             ` Heinrich Schuchardt
2014-11-05 17:18               ` Jan Kara
2014-10-21 17:04 ` John Stultz
2014-10-21 17:14   ` Bastien Nocera
2014-10-21 18:00     ` John Stultz
2014-10-21 18:09       ` Bastien Nocera
2014-10-21 19:10         ` John Stultz
2014-10-27 14:19           ` Bastien Nocera
2014-10-27 16:56             ` John Stultz
2014-10-28 22:57               ` One Thousand Gnomes
2014-10-30 14:41                 ` Bastien Nocera
2014-10-30 23:39                   ` One Thousand Gnomes
2014-10-31 14:03                     ` Bastien Nocera
2014-11-03 14:17                       ` One Thousand Gnomes
2014-10-30 14:35               ` Bastien Nocera
2014-10-30 23:25                 ` One Thousand Gnomes
2014-10-31 14:01                   ` Bastien Nocera
2014-11-21 19:08             ` Pavel Machek
2014-10-21 19:23         ` Andy Lutomirski
2014-10-22 17:04         ` Zygo Blaxell
2014-10-27 14:28           ` Bastien Nocera
2014-10-27 20:59             ` Zygo Blaxell
2014-10-28 12:36               ` Bastien Nocera
2014-10-28 14:36                 ` John Stultz
2014-10-31 13:54                   ` Bastien Nocera
2014-10-31 17:38                     ` John Stultz
     [not found]                 ` <CANszf4gaozN9YHzxUToRP9CaA1VVEV9vcz_X6LDL1zW3fH4Fow@mail.gmail.com>
2014-10-28 16:41                   ` Fwd: " Rogelio Serrano
2014-10-27  9:28         ` Pavel Machek
2014-10-27 14:31           ` Bastien Nocera
2014-10-28 18:50             ` suspend to partition " Pavel Machek
2014-10-30 13:57               ` Bastien Nocera
2014-10-29 19:19             ` Andy Lutomirski
2014-10-29 20:26               ` Theodore Ts'o
2014-10-29 21:16                 ` Pavel Machek
2014-10-30 14:45                   ` Bastien Nocera
2014-10-30 14:53                     ` Andy Lutomirski
2014-10-30 15:07                       ` Bastien Nocera
2014-10-30 18:23                         ` Pavel Machek
2014-10-31 13:57                           ` Bastien Nocera
2014-10-30 15:05                     ` Theodore Ts'o
2014-10-30 15:15                       ` Bastien Nocera
2014-10-30 15:34                         ` Theodore Ts'o
2014-10-30 15:36                           ` Bastien Nocera
2014-10-30 17:41                         ` Pavel Machek
2014-10-31 13:59                           ` Bastien Nocera
2014-10-30 23:21                         ` One Thousand Gnomes
2014-10-30 23:19                       ` One Thousand Gnomes
2014-10-30 14:42                 ` Bastien Nocera
2014-10-28 22:42           ` One Thousand Gnomes
2014-10-21 18:24     ` Geert Uytterhoeven
2014-10-27 14:20       ` Bastien Nocera
2014-10-27 15:31         ` Geert Uytterhoeven
2014-10-27 15:44           ` Bastien Nocera
2015-04-30 16:25   ` Bastien Nocera
2015-04-30 17:10     ` John Stultz
2015-04-30 17:23       ` Olof Johansson
2015-04-30 18:54         ` Chirantan Ekbote
2015-05-01  9:02           ` Tomeu Vizoso
2015-05-04 22:19             ` Rafael J. Wysocki
2015-05-05  6:05               ` Tomeu Vizoso
2015-05-05 12:31                 ` Rafael J. Wysocki
2015-05-07 16:54                   ` One Thousand Gnomes
2015-05-07 21:03                     ` Rafael J. Wysocki
2015-05-08  7:09                       ` Tomeu Vizoso
2015-05-04 22:12           ` Rafael J. Wysocki [this message]
2015-05-04 23:30             ` Chirantan Ekbote
2015-05-05 10:46               ` Bastien Nocera
2015-05-05 19:22                 ` Chirantan Ekbote
2015-05-06 12:41                   ` Bastien Nocera
2015-05-05 14:39               ` Alan Stern
2015-05-05 14:39                 ` Alan Stern
2015-05-05 17:58                 ` Chirantan Ekbote
2015-05-05 19:35                   ` Alan Stern
2015-05-05 19:35                     ` Alan Stern
2015-05-05 20:58                     ` Chirantan Ekbote
2015-05-05 23:56                       ` Rafael J. Wysocki
2015-05-05 23:38                         ` David Lang
2015-05-05 23:51                           ` Rafael J. Wysocki
2015-05-07 17:03                       ` One Thousand Gnomes
2015-05-07 18:21                         ` Chirantan Ekbote
2015-05-05 23:47               ` Rafael J. Wysocki
2015-05-06 17:40                 ` Chirantan Ekbote
2015-05-07 23:19                   ` Rafael J. Wysocki
2015-05-11 22:12                 ` Pavel Machek
2015-05-12  0:45                   ` Rafael J. Wysocki
2014-10-21 19:28 ` Andy Lutomirski
2014-10-21 19:43   ` Al Viro
2014-10-21 19:47     ` Andy Lutomirski
2014-10-27 13:55   ` Bastien Nocera
2014-10-27 15:12     ` Andy Lutomirski
2014-10-27 15:45       ` Bastien Nocera
2014-10-27 16:08         ` Andy Lutomirski
2014-10-27 16:09           ` Bastien Nocera
2014-10-27 16:22             ` Al Viro

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=286173531.vzKW1UoxJJ@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=chirantan@chromium.org \
    --cc=hadess@hadess.net \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=snanda@chromium.org \
    --cc=tomeu.vizoso@collabora.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.