From: Tri Vo <trong@android.com>
To: rjw@rjwysocki.net, gregkh@linuxfoundation.org, viresh.kumar@linaro.org
Cc: rafael@kernel.org, hridya@google.com, sspatil@google.com,
kaleshsingh@google.com, ravisadineni@chromium.org,
swboyd@chromium.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, kernel-team@android.com,
Tri Vo <trong@android.com>
Subject: [PATCH v8 0/3] PM / wakeup: Show wakeup sources stats in sysfs
Date: Tue, 6 Aug 2019 18:48:43 -0700 [thread overview]
Message-ID: <20190807014846.143949-1-trong@android.com> (raw)
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/wakeup<ID>/*.
Patch 1 and 2 do some cleanup to simplify our changes to how wakeup sources are
created. Patch 3 implements wakeup sources stats in sysfs.
Tri Vo (3):
PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare()
PM / wakeup: Use wakeup_source_register() in wakelock.c
PM / wakeup: Show wakeup sources stats in sysfs
Documentation/ABI/testing/sysfs-class-wakeup | 76 +++++++
drivers/acpi/device_pm.c | 3 +-
drivers/base/power/Makefile | 2 +-
drivers/base/power/power.h | 9 +
drivers/base/power/wakeup.c | 59 +++---
drivers/base/power/wakeup_stats.c | 203 +++++++++++++++++++
fs/eventpoll.c | 4 +-
include/linux/pm_wakeup.h | 21 +-
kernel/power/autosleep.c | 2 +-
kernel/power/wakelock.c | 32 +--
kernel/time/alarmtimer.c | 2 +-
11 files changed, 358 insertions(+), 55 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-wakeup
create mode 100644 drivers/base/power/wakeup_stats.c
v2:
- Updated Documentation/ABI/, as per Greg.
- Removed locks in attribute functions, as per Greg.
- Lifetimes of struct wakelock and struck wakeup_source are now different due to
the latter embedding a refcounted kobject. Changed it so that struct wakelock
only has a pointer to struct wakeup_source, instead of embedding it.
- Added CONFIG_PM_SLEEP_STATS that enables/disables wakeup source statistics in
sysfs.
v3:
Changes by Greg:
- Reworked code to use 'struct device' instead of raw kobjects.
- Updated documentation file.
- Only link wakeup_stats.o when CONFIG_PM_SLEEP_STATS is enabled.
Changes by Tri:
- Reverted changes to kernel/power/wakelock.c. 'struct device' hides kobject
operations. So no need to handle lifetimes in wakelock.c
v4:
- Added 'Co-developed-by:' and 'Tested-by:' fields to commit message.
- Moved new documentation to a separate file
Documentation/ABI/testing/sysfs-class-wakeup, as per Greg.
- Fixed copyright header in drivers/base/power/wakeup_stats.c, as per Greg.
v5:
- Removed CONFIG_PM_SLEEP_STATS
- Used PTR_ERR_OR_ZERO instead of if(IS_ERR(...)) + PTR_ERR, reported by
kbuild test robot <lkp@intel.com>
- Stephen reported that a call to device_init_wakeup() and writing 'enabled' to
that device's power/wakeup file results in multiple wakeup source being
allocated for that device. Changed device_wakeup_enable() to check if device
wakeup was previously enabled.
Changes by Stephen:
- Changed stats location from /sys/class/wakeup/<name>/* to
/sys/class/wakeup/wakeup<ID>/*, where ID is an IDA-allocated integer. This
avoids name collisions in /sys/class/wakeup/ directory.
- Added a "name" attribute to wakeup sources, and updated documentation.
- Device registering the wakeup source is now the parent of the wakeup source.
Updated wakeup_source_register()'s signature and its callers accordingly.
v6:
- Changed stats location to /sys/class/wakeup/ws<ID>/*
- Replaced ida_simple_get()/ida_simple_remove() with ida_alloc()/ida_free() as
the former is deprecated.
- Reverted changes to device_init_wakeup(). Rafael is preparing a patch to deal
with extra wakeup source allocation in a separate patch.
v7:
- Removed wakeup_source_init(), wakeup_source_prepare().
- Removed duplicate wakeup source creation code from kernel/power/wakelock.
- Moved ID allocation to wakeup source object creation time.
- Changed stats location back to /sys/class/wakeup/wakeup<ID>/*
- Remove wakeup source device's "power" attributes.
v8:
- Updated commit message on patch 1 to indicate change of behavior of
wakeup_source_create(), as per Stephen.
- Included headers for used symbols, as per Stephen.
- Added a function to create wakeup source devices to use
device_set_pm_not_required() to skip power management for such devices, as per
Stephen.
--
2.22.0.770.g0f2c4a37fd-goog
next reply other threads:[~2019-08-07 1:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 1:48 Tri Vo [this message]
2019-08-07 1:48 ` [PATCH v8 1/3] PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare() Tri Vo
2019-08-07 11:09 ` Greg KH
2019-08-07 15:00 ` Stephen Boyd
2019-08-07 1:48 ` [PATCH v8 2/3] PM / wakeup: Use wakeup_source_register() in wakelock.c Tri Vo
2019-08-07 11:14 ` Greg KH
2019-08-07 1:48 ` [PATCH v8 3/3] PM / wakeup: Show wakeup sources stats in sysfs Tri Vo
2019-08-26 9:15 ` [PATCH v8 0/3] " Rafael J. Wysocki
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=20190807014846.143949-1-trong@android.com \
--to=trong@android.com \
--cc=gregkh@linuxfoundation.org \
--cc=hridya@google.com \
--cc=kaleshsingh@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ravisadineni@chromium.org \
--cc=rjw@rjwysocki.net \
--cc=sspatil@google.com \
--cc=swboyd@chromium.org \
--cc=viresh.kumar@linaro.org \
/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.