From: "Limonciello, Mario" <mario.limonciello@amd.com>
To: John Stultz <jstultz@google.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>,
Sven van Ashbrook <svenva@chromium.org>,
Raul Rangel <rrangel@chromium.org>,
linux-pm@vger.kernel.org, platform-driver-x86@vger.kernel.org,
Rajneesh Bhardwaj <irenic.rajneesh@gmail.com>,
S-k Shyam-sundar <Shyam-sundar.S-k@amd.com>,
Rajat Jain <rajatja@google.com>,
David E Box <david.e.box@intel.com>,
Hans de Goede <hdegoede@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC v3 1/4] PM: Add a sysfs file to represent the total sleep duration
Date: Tue, 15 Nov 2022 20:40:59 -0600 [thread overview]
Message-ID: <8ab6048e-26fe-5cc1-9116-c25fdc742a65@amd.com> (raw)
In-Reply-To: <CANDhNCqPWV_dC_wo-CCqBuO0J=5TcRAh5AX335PLft2+w19_tQ@mail.gmail.com>
On 11/15/2022 14:44, John Stultz wrote:
> On Tue, Nov 15, 2022 at 12:02 PM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
>>
>> For userspace to be able to analyze how much of a suspend cycle was spent
>> in the hardware sleep states userspace software has to use kernel trace
>> points paired with the file `low_power_idle_system_residency_us` on
>> supported systems.
>>
>> To make this information more discoverable, introduce a new sysfs file
>> to represent the duration spent in a sleep state.
>> This file will be present and updated during resume for all suspend
>> types.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> RFC v2->v3
>> * Drop one of the sysfs files
>> * Use sysfs_emit instead
>> * Fix symbol name (s/type/time/)
>> * Drop is_visible
>> * Use timespec64 type for suspend stats
>> * Update documentation
>> * Update sysfs file name
>> ---
>> Documentation/ABI/testing/sysfs-power | 8 ++++++++
>> include/linux/suspend.h | 2 ++
>> kernel/power/main.c | 15 +++++++++++++++
>> kernel/power/suspend.c | 2 ++
>> kernel/time/timekeeping.c | 2 ++
>> 5 files changed, 29 insertions(+)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
>> index f99d433ff311..3abe20c47e08 100644
>> --- a/Documentation/ABI/testing/sysfs-power
>> +++ b/Documentation/ABI/testing/sysfs-power
>> @@ -413,6 +413,14 @@ Description:
>> The /sys/power/suspend_stats/last_failed_step file contains
>> the last failed step in the suspend/resume path.
>>
>> +What: /sys/power/suspend_stats/last_total
>> +Date: December 2022
>> +Contact: Mario Limonciello <mario.limonciello@amd.com>
>> +Description:
>> + The /sys/power/suspend_stats/last_total file contains
>> + the total duration of the sleep cycle.
>> + This is measured in microseconds.
>> +
>
> Nit/bikeshed: "last_total" seems less straightforward then it should
> be? Maybe "total_suspend_time" instead?
I initially thought the same thing but I feel like you can make the same
argument about "success" or other files in the "suspend_stats" directory.
>
>> diff --git a/kernel/power/main.c b/kernel/power/main.c
>> index 31ec4a9b9d70..f33012860699 100644
>> --- a/kernel/power/main.c
>> +++ b/kernel/power/main.c
>> @@ -6,6 +6,7 @@
>> * Copyright (c) 2003 Open Source Development Lab
>> */
>>
>> +#include <linux/acpi.h>
>> #include <linux/export.h>
>> #include <linux/kobject.h>
>> #include <linux/string.h>
>> @@ -54,6 +55,11 @@ void unlock_system_sleep(unsigned int flags)
>> }
>> EXPORT_SYMBOL_GPL(unlock_system_sleep);
>>
>> +void pm_account_suspend_time(const struct timespec64 t)
>> +{
>> + suspend_stats.last_total = timespec64_add(suspend_stats.last_total, t);
>> +}
>> +
>> void ksys_sync_helper(void)
>> {
>> ktime_t start;
>> @@ -377,6 +383,14 @@ static ssize_t last_failed_step_show(struct kobject *kobj,
>> }
>> static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step);
>>
>> +static ssize_t last_total_show(struct kobject *kobj,
>> + struct kobj_attribute *attr, char *buf)
>> +{
>> + return sysfs_emit(buf, "%llu\n",
>> + timespec64_to_ns(&suspend_stats.last_total) / NSEC_PER_USEC);
>> +}
>> +static struct kobj_attribute last_total = __ATTR_RO(last_total);
>> +
>> static struct attribute *suspend_attrs[] = {
>> &success.attr,
>> &fail.attr,
>> @@ -391,6 +405,7 @@ static struct attribute *suspend_attrs[] = {
>> &last_failed_dev.attr,
>> &last_failed_errno.attr,
>> &last_failed_step.attr,
>> + &last_total.attr,
>> NULL,
>> };
>
> While not identical, this has some overlap with the logic in
> kernel/time/timekeeping_debug.c
> I wonder if it would make sense to consolidate some of this accounting?
Sure. If the consensus is to stick to this approach of exporting the
total time I'll look into that.
>
> thanks
> -john
next prev parent reply other threads:[~2022-11-16 2:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=8ab6048e-26fe-5cc1-9116-c25fdc742a65@amd.com \
--to=mario.limonciello@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=david.e.box@intel.com \
--cc=hdegoede@redhat.com \
--cc=irenic.rajneesh@gmail.com \
--cc=jstultz@google.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rajatja@google.com \
--cc=rrangel@chromium.org \
--cc=sboyd@kernel.org \
--cc=svenva@chromium.org \
--cc=tglx@linutronix.de \
/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 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®