Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4692677rdb; Tue, 12 Dec 2023 06:58:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTnS/9qvs5fm6nH8SCkCOYOpHr/VfkwVI6YTUHnYoRg/ZIrC4SCvjP0C4dfkdikcdEutb9 X-Received: by 2002:a05:6a20:da9b:b0:18f:97c:5b8b with SMTP id iy27-20020a056a20da9b00b0018f097c5b8bmr3127948pzb.89.1702393097170; Tue, 12 Dec 2023 06:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702393097; cv=none; d=google.com; s=arc-20160816; b=xiGkc1vrkwfixR8ZCEqs1AyDmfHfxMRmkdlaI7Uedxw+R1YwaghM7JUs5gpPuyzTQe fTiLrwYmPUQ0U7BYyHZiHibGPOmjru849EH3lH6+mnCnCT2aAtUMYTtsoXmcKiKSicGn +eeXC7Mgwd8FoYfIfzDqeh7xhc54oD9Yne9Z0c4cIW+ZpgD70YP2SgqDiL0M/VslEQWG 3pRGM0cK0Bua1QQDvyahrJYXQ3t0lnrc0vGXRRKFeVCZBxdLdyPjFTBcdljgigwdLO4h /Z9mhEkjxai8N1Uabz3HKhhevpV/w2P360Q0DRbT2RkREaq3z23lUIeC4KZ69PXUsnLR tSWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=mr+6ggmCPGZ4iZxNKfQ5x18JiJbheuvL0olNh56ZNuk=; fh=g8Uah7JaacrJ9eJTqgPSzkY64EXVE9sBPiTtZsPwZ+s=; b=bnTFtVzTzFPXf/7jy+hg0RVGKYSu7aR+ahwujegq7Jr0WSp5rp6Nm4Xn2pPQouR6zT 4TL4EkWg29kEMebQrXCBzANFvJNYa7DNK9e1is5Us3kLHa4iAsLIhsvCGZ/5q7dGeTN+ 9AwsMA/UWVW1VMpcIqCvkJx8GTRGs3XSrGTOg1ZrSUscyAlpdZANhz7Qu8i+JrJqtc/g CwoacwYZ6IzseZrwMkkllJRI02HR2LDa07RkNUseTSDayD99lq3e1kQPWoZB4dwOKOy8 oBMBggnqJOWF/TUrgnmN81lVBPip3VoeiKtRPnYN5wF7Z2Xzwk7y4R1Hupc/tlMIvuz+ IeHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s15-20020a65690f000000b005c6c1edaaa5si7972428pgq.520.2023.12.12.06.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 06:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A4E1D801C888; Tue, 12 Dec 2023 06:58:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232659AbjLLO57 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Dec 2023 09:57:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbjLLO55 (ORCPT ); Tue, 12 Dec 2023 09:57:57 -0500 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1210C3; Tue, 12 Dec 2023 06:58:03 -0800 (PST) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6da09f8ce35so710475a34.0; Tue, 12 Dec 2023 06:58:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702393083; x=1702997883; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uI7/niVPwJXrqn+aODJkyH9Zg/KMSJ6EEIEaKjbnNpY=; b=otyzK4LO7asNGssByl2eJz5+J44qgQgCNdAd5TrA2L3M/S0fbh600e12HlDcnlbg96 9uy94ntnzniIb3QZl05FwmsoVGkUJxEDz/GsxdmnvRIPla7moqOLp4VXuZWbN6CdQoxr Az41+V9xyI24qV/emrdw7dzlTt7rgick4LS6pDZCi98tSnKv/15SkOE2xp21ZoUYQj06 +fXdYKyrtSQugGVQ7p4UJymMIQ+vGdcKwjwbseWqirmfwun+L/0VjebFDaldlj4qJu/d 7ynEClg90t5NeOMj3LDy88v/CLMw6zDPuFpq+LdQTg1Ikrncgiub6CGwKVZywbmgE5X9 IZpg== X-Gm-Message-State: AOJu0YwPzQ2jSKrNnylq083/NetHKuvIYgnJ6I2XoRoxh2+6XwjCKfDc 0ntlgR6aSDJKhKWPjOD0jp0S/pG7ZCIf+mQERGw= X-Received: by 2002:a4a:da02:0:b0:590:8a57:8012 with SMTP id e2-20020a4ada02000000b005908a578012mr10635729oou.0.1702393083230; Tue, 12 Dec 2023 06:58:03 -0800 (PST) MIME-Version: 1.0 References: <170108151076.780347.2482745314490930894.stgit@mhiramat.roam.corp.google.com> <170108152012.780347.6355289232990337333.stgit@mhiramat.roam.corp.google.com> <20231212233245.14ae64258bdf07ae1d2f2ff9@kernel.org> In-Reply-To: <20231212233245.14ae64258bdf07ae1d2f2ff9@kernel.org> From: "Rafael J. Wysocki" Date: Tue, 12 Dec 2023 15:57:52 +0100 Message-ID: Subject: Re: [PATCH v5] PM: sleep: Expose last succeeded resumed timestamp in sysfs To: Masami Hiramatsu 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 06:58:14 -0800 (PST) On Tue, Dec 12, 2023 at 3:32 PM Masami Hiramatsu wrote: > > Hi Rafael, > > On Tue, 12 Dec 2023 14:39:17 +0100 > "Rafael J. Wysocki" wrote: > > > On Mon, Nov 27, 2023 at 11:38 AM Masami Hiramatsu (Google) > > wrote: > > > > > > From: Masami Hiramatsu > > > > > > Expose last succeeded resumed timestamp as last_success_resume_time > > > attribute of suspend_stats in sysfs. > > > > > > There are some printk()s for printing the similar resume timing to > > > dmesg, but those are recorded with local_clock(), and user can not > > > compare it with current time. We also have tracing events but it > > > requires CAP_SYS_ADMIN to use it. > > > > > > This suspend_stats attribute is easy to access and only expose the > > > timestamp in CLOCK_MONOTONIC. > > > > Why CLOCK_MONOTONIC? > > CLOCK_MONOTONIC is the simplest clock which can be used in both user > space and kernel space. If we use the CLOCK_LOCAL here, user can not > know the actual time delta from the succeeded resume. So what does user space need to do to use this value? > > > > > So user can find the actual resumed > > > time and measure the elapsed time from the time when the kernel > > > finished the resume to the user-space action (e.g. display the UI). > > > > Can you please say a bit more about why this is useful? > > This is a reference timestamp from the user space to measure their > processing time for resuming. The kernel side is OK to just trace > or printk the each component or subsystem internally. But the user > space needs to know when the kernel resume has been done for measuring > its component or processes done. Why does it need to know that? > Actually this is obscure because the > end of resuming in userspace is defined by the user-space application > or desktop systems. But anyway if there is a reference point, user > process can calculate the delta at any point from that. > > > > > The time stamp is taken at the point when user space has been already > > running for some time, so what's the exact benefit of it? > > Yes, but that timestamp can be scheduled afterwards so it may not > be so accurate. This can provide the accurate time of the kernel > resume. I'm talking about the timestamp added by this patch, that is /sys/power/suspend_stats/last_success_resume_time. By the time ktime_get_ts64() in pm_suspend() is called, user space has already been thawed and is running, so why is this useful?