mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC v3 0/4] Make it easier to measure % in HW sleep state
@ 2022-11-15 20:01 Mario Limonciello
  2022-11-15 20:01 ` [RFC v3 1/4] PM: Add a sysfs file to represent the total sleep duration Mario Limonciello
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Mario Limonciello @ 2022-11-15 20:01 UTC (permalink / raw)
  To: Rafael J . Wysocki, Stephen Boyd, platform-driver-x86, linux-pm,
	linux-kernel
  Cc: Sven van Ashbrook, Raul Rangel, Pavel Machek, Len Brown,
	John Stultz, Thomas Gleixner, Rajneesh Bhardwaj,
	S-k Shyam-sundar, Rajat Jain, David E Box, Hans de Goede

Sven van Ashbrook brought a patch to the kernel mailing list that
attempted to change the reporting level of a s0ix entry issue to a
different debugging level so that infastructure used by Google could
better scan logs to catch problems.

This approach was rejected, but during the conversation another
suggestion was made by David E. Box to introduce some infrastructure
into the kernel to report this information.

As it's information that is reported by both AMD and Intel platforms
over s2idle, this seems to make sense.

RFC v1 and v2 introduced two new sysfs files to report the information, but
Rafael pointed out that there was already a file that could be used on
Intel platforms: `low_power_idle_system_residency_us`.

RFC v3 creates this file for AMD platforms and also introduces another file
that can be used to determine total sleep time:
`/sys/power/suspend_stats/last_total`.

With these two files a simple shell script can be run after suspend to
calculate the percentage.

```
 #!/bin/sh
total=$(cat /sys/power/suspend_stats/last_total)
hw=$(cat /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us)
percent=$(awk -v hw=$hw -v total=$total 'BEGIN { printf "%.2f%%", (hw/total*100) }')
echo "Last ${total}us suspend cycle spent $percent of the time in a hardware sleep state."
```

A sample run on an AMD platform that was just sleeping with this series on
top of 6.1-rc5 shows the following:
 # ./compare.sh
Last 15699838us suspend cycle spent 98.63% of the time in a hardware sleep state.

Further discussion to be expected on this series:

* What last_total will represent from the suspend cycle

* Whether the semantics of all platforms will be the same for
  `low_power_idle_system_residency_us`
  - AMD platforms reset this counter before s2idle entry.  Do Intel? Others?

* Maybe the *kernel* should be responsible to do the calculation and export
  a `last_hw_sleep_percent` file instead. Platform differences can be
  abstracted then within individual drivers.

Mario Limonciello (4):
  PM: Add a sysfs file to represent the total sleep duration
  platform/x86/intel/pmc: core: Drop check_counters
  platform/x86/amd: pmc: Report duration of time in deepest hw state
  platform/x86/amd: pmc: Populate cpuidle sysfs file with hw sleep data

 Documentation/ABI/testing/sysfs-amd-pmc |  6 ++++++
 Documentation/ABI/testing/sysfs-power   |  8 ++++++++
 drivers/platform/x86/amd/pmc.c          | 27 ++++++++++++++++++++++---
 drivers/platform/x86/intel/pmc/core.c   |  7 ++-----
 drivers/platform/x86/intel/pmc/core.h   |  1 -
 include/linux/suspend.h                 |  2 ++
 kernel/power/main.c                     | 15 ++++++++++++++
 kernel/power/suspend.c                  |  2 ++
 kernel/time/timekeeping.c               |  2 ++
 9 files changed, 61 insertions(+), 9 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-17 14:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15 20:01 [RFC v3 0/4] Make it easier to measure % in HW sleep state Mario Limonciello
2022-11-15 20:01 ` [RFC v3 1/4] PM: Add a sysfs file to represent the total sleep duration Mario Limonciello
2022-11-15 20:44   ` John Stultz
2022-11-16  2:40     ` Limonciello, Mario
2022-11-15 20:01 ` [RFC v3 2/4] platform/x86/intel/pmc: core: Drop check_counters Mario Limonciello
2022-11-15 20:01 ` [RFC v3 3/4] platform/x86/amd: pmc: Report duration of time in deepest hw state Mario Limonciello
2022-11-15 20:01 ` [RFC v3 4/4] platform/x86/amd: pmc: Populate cpuidle sysfs file with hw sleep data Mario Limonciello
2022-11-17 14:10 ` [RFC v3 0/4] Make it easier to measure % in HW sleep state Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®