Re: [PATCH v4 0/2] PM: runtime: add new runtime metrics and summary
From: Rafael J. Wysocki (Intel)
Date: Fri Dec 04 2026 - 14:38:38 EST
On Mon, Nov 30, 2026 at 11:57 AM Joshua Crofts <crofts@xxxxxxxxxx> wrote:
>
> Add a new set additional PM runtime metrics to improve power management
> debugging and reporting (these metrics may be useful to userspace utilities
> such as Powertop).
>
> MOTIVATION:
> The current implementation only measures the duration a device spends in
> suspended or active mode, which is very limiting. We can't find out how many
> times a device changed state or what its shortest suspend cycle was.
>
> This overview would be useful for detecting power "thrashing" and tuning
> autosuspend delays. Currently, sysfs only shows the total time a device spent
> in active and suspended mode; from an energy standpoint, a continuous 50
> second suspension is different from a device cycling 1000 times for 50ms each
> (these transitions can be pretty power-hungry). This could help userspace
> utilities like PowerTOP to more effectively determine what is causing an
> increased power consumption.
>
> NEW FEATURES:
> This series introduces the following new metrics:
> - resume_count : number of successful transitions to active
> - suspend_count: number of successful transitions to suspended
> - last_suspended_time: duration of the most recent sleep cycle (ns)
> - min_suspended_time / max_suspended_time: shortest and longest sleep
> cycle durations to help detect power thrashing (ns)
>
> By reading the debugfs file /sys/kernel/debug/pm_runtime_summary, you get
> the following table describing the power stats of each device with
> runtime PM enabled:
>
> Device Status Resumes Suspends Active(ms) Suspend(ms) Last(ms) Min(ms) Max(ms)
> --------------------------------------------------------------------------------------------------------------------------
> 0000:00:02.0 active 1 0 45688 0 0 0 0
> 0000:00:1f.0 active 1 0 45687 0 0 0 0
> 0000:00:1f.2 active 1 0 45686 0 0 0 0
> 0000:00:1f.3 suspended 1 1 1658 44028 0 0 0
> 00:03:0 active 15 14 19627 25899 42 5 14811
> 00:03:0.0 active 14 13 19626 25900 42 5 14811
>
> TESTING:
> Tested with an x86_64 defconfig kernel and QEMU.
>
> AI ASSISTANCE:
> Gemini was used to prepare this series.
>
> Signed-off-by: Joshua Crofts <crofts@xxxxxxxxxx>
> ---
> Changes in v4:
> - Extract #ifdef CONFIG_DEBUG_FS guarded logic into new functions and
> add their stubs if debugfs isn't enabled (Rafael)
> - Fix timestamp calculations as pointed out by Sashiko
> - Link to v3: https://patch.msgid.link/20261123-pm-runtime-summary-v3-0-81a966953a81@xxxxxxxxxx
>
> Changes in v3:
> - Guard new metrics with #ifdef CONFIG_DEBUG_FS to reduce overhead on
> non-debugfs enabled systems (Rafael)
> - Fix runtime status transition fixes flagged by Sashiko
> - Link to v2: https://lore.kernel.org/r/20261116-pm-runtime-summary-v2-0-a3d8654baf8f@xxxxxxxxxx
>
> Changes in v2:
> - Drop sysfs patch as it would have a non-negligible impact on boot times and
> the debugfs summary is enough (Samuel Wu)
> - Expand cover letter
> - Fix Sashiko findings - typo in commit message, race condition, duplicate
> function call
> - Link to v1: https://lore.kernel.org/r/20261110-pm-runtime-summary-v1-0-12ebf283db78@xxxxxxxxxx
>
> To: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> To: Pavel Machek <pavel@xxxxxxxxxx>
> To: Len Brown <lenb@xxxxxxxxxx>
> To: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> To: Danilo Krummrich <dakr@xxxxxxxxxx>
> To: Johan Hovold <johan@xxxxxxxxxx>
> Cc: linux-pm@xxxxxxxxxxxxxxx
> Cc: driver-core@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
> ---
> Joshua Crofts (2):
> PM: runtime: add additional suspend/resume metrics
> PM: runtime: add debugfs entry for pm_runtime_summary
>
> drivers/base/power/runtime.c | 151 +++++++++++++++++++++++++++++++++++++++++++
> include/linux/pm.h | 18 +++++-
> 2 files changed, 168 insertions(+), 1 deletion(-)
> ---
Please look at Sashiko's feedback on this series
https://sashiko.dev/#/patchset/20261130-pm-runtime-summary-v4-0-154a4c079ea7%40kernel.org
and see what can be done to make it not complain.