Re: [PATCH v3] PM / wakeup: show wakeup sources stats in sysfs
From: Tri Vo
Date: Mon Jul 15 2019 - 17:48:26 EST
On Mon, Jul 15, 2019 at 1:37 PM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Jul 15, 2019 at 01:11:16PM -0700, Tri Vo wrote:
> > Userspace can use wakeup_sources debugfs node to plot history of suspend
> > blocking wakeup sources over device's boot cycle. This information can
> > then be used (1) for power-specific bug reporting and (2) towards
> > attributing battery consumption to specific processes over a period of
> > time.
> >
> > However, debugfs doesn't have stable ABI. For this reason, create a
> > 'struct device' to expose wakeup sources statistics in sysfs under
> > /sys/class/wakeup/<name>/.
> >
> > Introduce CONFIG_PM_SLEEP_STATS that enables/disables showing wakeup
> > source statistics in sysfs.
> >
> > Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Tri Vo <trong@xxxxxxxxxxx>
> > Tested-by: Tri Vo <trong@xxxxxxxxxxx>
>
> Co-Developed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> perhaps given that I rewrote the whole file last time? :)
Thanks again for the help!
>
>
> > ---
> > Documentation/ABI/testing/sysfs-power | 73 ++++++++++++-
> > drivers/base/power/Makefile | 1 +
> > drivers/base/power/wakeup.c | 12 ++-
> > drivers/base/power/wakeup_stats.c | 148 ++++++++++++++++++++++++++
> > include/linux/pm_wakeup.h | 19 ++++
> > kernel/power/Kconfig | 10 ++
> > kernel/power/wakelock.c | 10 ++
> > 7 files changed, 270 insertions(+), 3 deletions(-)
> > create mode 100644 drivers/base/power/wakeup_stats.c
>
> What changed from v2? :)
Oops, my bad.
> And I am guessing that you actually tested this all out, and it works
> for you?
Yes, I played around with wakelocks to make sure that wakeup source
stats are added/updated/removed as expected.
> Have you changed Android userspace to use the new api with no
> problems?
Kalesh helped me test this patch (added him in Tested-by: field in
latest patch version). We haven't tested beyond booting and manual
inspection on android devices. Android userspace changes should be
fairly trivial though.