Re: [RFC] PM: suspend: Upstreaming wakeup reason capture support

From: Kelly Rossmoyer
Date: Sat Jan 29 2022 - 03:27:32 EST


On Thu, Jan 27, 2022 at 12:10 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>
> On Thu, Jan 27, 2022 at 8:54 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
> >
> > On Mon, Jan 10, 2022 at 7:49 PM Kelly Rossmoyer <krossmo@xxxxxxxxxx> wrote:
> > >
> > So as Zichar said, this is quite heavy-weight.
> >
> > I'm not fundamentally against adding more infrastructure to help
> > identify issues related to system suspend, but there needs to be a
> > clear benefit associated with any change in this direction.
>
> That said, the general idea behind wakeup_source objects is that every
> system wakeup event should be recorded in one of them which then can
> be used for later analysis.
>
> If there are reasons why this cannot work in general, what are they?

I won't presume to say that it "cannot work in general." Nearly everyone on
this thread has more expertise here than I do, and I'm keenly aware of how
much I don't know. :-)

What I will say is that - across the chips and architectures I've worked upon
over the last few years - that concept has not appeared to match observed
reality. From what I've seen (which is a very narrow slice of the Linux
universe, but I suspect is at least pretty representative of Android):
* resumes from successful suspends are typically accompanied by a flurry of
wakesource activity from which it is not possible to determine what actually
caused the resume (despite last changed timestamps)
* resumes that aren't accompanied by wakeup-armed IRQs can be even
less well-reflected by wakesource activity
* I believe inferring wakeup reasons from wakesource stats would require
having a snapshot from the last moment prior to suspend, which seems
unsolvable from userspace
* suspend aborts (which can be even more harmful for battery life than
"true" wakeups) are often caused by things that aren't reflected by specific
wakesources (e.g. a driver failing to suspend)

And as I mentioned in my reply to Zichar, this isn't solely about
troubleshooting. There's a lot of room to improve on user-focused power
attribution, and I'm hoping to build change in that direction upon the same
foundation. Having the best possible data about "why we're awake" serves both
goals.

Tangentially, the new(ish) wakesource stats interface has also proved to be
quite difficult to utilize robustly from userspace (at least on Android, maybe
not elsewhere?). But that's a different fish for a different fryer, that I'm
hoping to tackle later this year.


--

Kelly Rossmoyer | Software Engineer | krossmo@xxxxxxxxxx | 858-239-4111