Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp85167rdb; Tue, 16 Jan 2024 16:07:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxTeDrGTQAQWzIjVO3WgTe0FuY3W5VIy54SRMLzBfIu9Wj2OyVGQhnNkLrFzcLaCbOwalJ X-Received: by 2002:a05:620a:819:b0:783:1b94:54dd with SMTP id s25-20020a05620a081900b007831b9454ddmr9183319qks.105.1705450055460; Tue, 16 Jan 2024 16:07:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705450055; cv=pass; d=google.com; s=arc-20160816; b=D2zWSfarK/0H2YyT1C5a/S37Nec6CitlfdzNODR9n0DX9SZl7C8m0eeyS3KbvgeBJH ok45sx5/+lekAibhtFRDdMUPdev4iI3w3KPtchoMRVN87h+YbyyZHaFpUUIZhCQTpaiE MBWFZPmgI9FcBHml92mnupNvOVqQ7M9zXRxZrSPntRMDORSgH8FH789SDGhKr/HYRdE6 Q2YbDNJ2qmS9S/4LhOLYFkA9c+rp79nV2Kf2o6Man8tkhcrzTujQhD0NR98eh3u2NFzY ayp3mXESrbRMzQF73k495J7XczqNpteEMrXdcabzZE7wUlFo/ubzlOUJji7xKZDUNQy5 kqjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=boLf3yG6yg/Mre7TxYIsmQ56BlrxLY1yktexyd95eTY=; fh=cA+RPzrazC6tFNyRrGagC+dmojgtDolmL6yu3N7/dMs=; b=ngjYN9EWX38a6GdthLLZoFFR+2sodfjc7ANwMgDsqkwQ7NoPaLrt0bmHDsJ34c43GU hwU+1lsi195FooUf2GdqwY2wkAfGROTnvCs8ByH2uePwXyiIsX9TEMpAzj9ahIna5LnE 8RyFzehwZXATGjLegVwJNbDmhIfj8ZfYwDwKbvYOczs4GhrISBpBun4dnJSV8wi/98Nc CoWVbG+Q2015UZGRNHNMfFJyYR3t96+RwQ4/0M9M8oh8yiS/w3Uxpu4AtTbyhFeAsIg1 i7Xu2MQJX+xMcVTS4Z6UEo27QXpy6LejphVZRVUfkw+MUOtDiBj4GMgultRveIGnbGel H7Yw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GUjUBt6U; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-28388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m17-20020ae9e011000000b00781d517df64si10785388qkk.429.2024.01.16.16.07.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 16:07:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GUjUBt6U; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-28388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2BF811C249FB for ; Wed, 17 Jan 2024 00:07:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7ECD728F0; Wed, 17 Jan 2024 00:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GUjUBt6U" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 814381C11; Wed, 17 Jan 2024 00:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705450031; cv=none; b=eGocDtGpJDd/H8abnzK0psLMsxQjEQj7U0WoUEXG9RElCMot3vqpfm79nVPjB+hHCPJEIJGQETyrfhaueiiqzPJ309plKbvca3VunGIcengUsuJen6xmT7lVDrskp1rpKxQoopcNtbGq6RNkiwM0fsSSzGW/Ce8vurBtC6XmESo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705450031; c=relaxed/simple; bh=Hi3WbUEYSIhh0hiaezg7Ec88eCvYKaiPi+jMfAgJqZQ=; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; b=qNVquky+C0styvnzj88HnbiQxLehcdRpnxextg7+ddlZkbvzZeZ6uhkimJdVERvfV8l+EmMa02svyHu1i8IcZ48iW20YInHND4sUTTOZOwaslsAO8EpCLOawAgU+dGgFOGNPsOeqO1/L2HbHiR3m05GD5Bsfbg69e90fs3/2fj8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GUjUBt6U; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5BC0C433C7; Wed, 17 Jan 2024 00:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705450031; bh=Hi3WbUEYSIhh0hiaezg7Ec88eCvYKaiPi+jMfAgJqZQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GUjUBt6UCxqauu6S3cOUPnGnccJbsNUC8vy9MDjumfcVmIlMe+BXnTGgKGCrfGHA7 VLXHHFDhomKGiCvNlp1Ba7g3hVBfrvcqeuKFUTjZdMmKvsTcXmxlwF+oggd/PGi2lh 26Y/nd0kOyFwpdwgbjDUY4GjzLKHhKMxgBFBO5RHCFcmxG76uxIzvFZ5yIDbpKry7B DwO0XRcx0VIHyVi5mx0Kz3CJ46HLk95jg+7kU4lUi+aPHm7qHiJ3+ceb8BGIha6Vdr +SC9dQU2g13sPBhyZEM53apxdIbAPTjQo+lo0XJo2fIFtyRgeHfQI91pi3gfVar/zz FiXdgio969IxA== Date: Wed, 17 Jan 2024 09:07:06 +0900 From: Masami Hiramatsu (Google) To: "Masami Hiramatsu (Google)" Cc: "Rafael J . Wysocki" , Pavel Machek , Len Brown , Randy Dunlap , suleiman@google.com, briannorris@google.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v7] PM: sleep: Expose last succeeded resumed timestamp in sysfs Message-Id: <20240117090706.3522d23763fab9dcea21aee1@kernel.org> In-Reply-To: <170359669607.1864392.5078004271237566637.stgit@mhiramat.roam.corp.google.com> References: <170359668692.1864392.6909734045167510522.stgit@mhiramat.roam.corp.google.com> <170359669607.1864392.5078004271237566637.stgit@mhiramat.roam.corp.google.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Gently ping, I would like to know this is enough or I should add more info/update. Thank you, On Tue, 26 Dec 2023 22:18:16 +0900 "Masami Hiramatsu (Google)" wrote: > From: Masami Hiramatsu > > Expose last succeeded resumed timestamp as last_success_resume_time > attribute of suspend_stats in sysfs so that user can use this time > stamp as a reference point of resuming user space. > > On some system like the ChromeOS, the system suspend and resume are > controlled by a power management process. The user-space tasks will be > noticed the suspend and the resume signal from it. > To improve the suspend/resume performance and/or to find regressions, > we would like to know how long the resume processes are taken in kernel > and in user-space. > For this purpose, expose the accarate time when the kernel is finished > to resume so that we can distinguish the duration of kernel resume and > user space resume. > > This suspend_stats attribute is easy to access and only expose the > timestamp in CLOCK_MONOTONIC. User can find the accarate time when the > kernel finished to resume its drivers/subsystems and start thawing, and > measure the elapsed time from the time when the kernel finished the > resume to a user-space action (e.g. displaying the UI). > > Signed-off-by: Masami Hiramatsu (Google) > --- > Changes in v7: > - Update patch description. > - Update sysfs documentation to say the exact timing. > - Update the comment. > Changes in v6: > - Fix to record resume time before thawing user processes. > Changes in v5: > - Just updated for v6.7-rc3. > Changes in v4.1: > - Fix document typo (again). > Changes in v4: > - Update description to add why. > - Fix document typo. > Changes in v3: > - Add (unsigned long long) casting for %llu. > - Add a line after last_success_resume_time_show(). > Changes in v2: > - Use %llu instead of %lu for printing u64 value. > - Remove unneeded indent spaces from the last_success_resume_time > line in the debugfs suspend_stat file. > --- > Documentation/ABI/testing/sysfs-power | 11 +++++++++++ > include/linux/suspend.h | 2 ++ > kernel/power/main.c | 15 +++++++++++++++ > kernel/power/suspend.c | 9 +++++++++ > 4 files changed, 37 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power > index a3942b1036e2..ee567e7e9d4a 100644 > --- a/Documentation/ABI/testing/sysfs-power > +++ b/Documentation/ABI/testing/sysfs-power > @@ -442,6 +442,17 @@ Description: > 'total_hw_sleep' and 'last_hw_sleep' may not be accurate. > This number is measured in microseconds. > > +What: /sys/power/suspend_stats/last_success_resume_time > +Date: Dec 2023 > +Contact: Masami Hiramatsu > +Description: > + The /sys/power/suspend_stats/last_success_resume_time file > + contains the timestamp of when the kernel successfully > + resumed drivers/subsystems from suspend/hibernate. This is > + just before thawing the user processes. > + This floating point number is measured in seconds by monotonic > + clock. > + > What: /sys/power/sync_on_suspend > Date: October 2019 > Contact: Jonas Meurer > diff --git a/include/linux/suspend.h b/include/linux/suspend.h > index ef503088942d..ddd789044960 100644 > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > #include > > #ifdef CONFIG_VT > @@ -71,6 +72,7 @@ struct suspend_stats { > u64 last_hw_sleep; > u64 total_hw_sleep; > u64 max_hw_sleep; > + struct timespec64 last_success_resume_time; > enum suspend_stat_step failed_steps[REC_FAILED_NUM]; > }; > > diff --git a/kernel/power/main.c b/kernel/power/main.c > index f6425ae3e8b0..2ab23fd3daac 100644 > --- a/kernel/power/main.c > +++ b/kernel/power/main.c > @@ -421,6 +421,17 @@ 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_success_resume_time_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + return sprintf(buf, "%llu.%llu\n", > + (unsigned long long)suspend_stats.last_success_resume_time.tv_sec, > + (unsigned long long)suspend_stats.last_success_resume_time.tv_nsec); > +} > + > +static struct kobj_attribute last_success_resume_time = > + __ATTR_RO(last_success_resume_time); > + > static struct attribute *suspend_attrs[] = { > &success.attr, > &fail.attr, > @@ -438,6 +449,7 @@ static struct attribute *suspend_attrs[] = { > &last_hw_sleep.attr, > &total_hw_sleep.attr, > &max_hw_sleep.attr, > + &last_success_resume_time.attr, > NULL, > }; > > @@ -514,6 +526,9 @@ static int suspend_stats_show(struct seq_file *s, void *unused) > suspend_step_name( > suspend_stats.failed_steps[index])); > } > + seq_printf(s, "last_success_resume_time:\t%-llu.%llu\n", > + (unsigned long long)suspend_stats.last_success_resume_time.tv_sec, > + (unsigned long long)suspend_stats.last_success_resume_time.tv_nsec); > > return 0; > } > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index fa3bf161d13f..2d0f46b4d0cf 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -595,6 +595,15 @@ static int enter_state(suspend_state_t state) > Finish: > events_check_enabled = false; > pm_pr_dbg("Finishing wakeup.\n"); > + > + /* > + * Record last succeeded resume timestamp just before thawing processes. > + * This is for helping users to measure user-space resume performance > + * for improving their programs or finding regressions. > + */ > + if (!error) > + ktime_get_ts64(&suspend_stats.last_success_resume_time); > + > suspend_finish(); > Unlock: > mutex_unlock(&system_transition_mutex); > -- Masami Hiramatsu (Google)