Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4950600rdb; Tue, 12 Dec 2023 14:19:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUO1HGzQebwlZXBNEoXwscDeDkifCAeLhBmBSJXLd1wJ34PzxMWN9PULRQPHEY2KEam5BU X-Received: by 2002:a05:6870:9a26:b0:1fb:75b:2fc5 with SMTP id fo38-20020a0568709a2600b001fb075b2fc5mr7796036oab.92.1702419571953; Tue, 12 Dec 2023 14:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702419571; cv=none; d=google.com; s=arc-20160816; b=S7yE9qNC66SAyJ6gTFkrNzJ0P8uBRtL0a1BEzgfqB4DFxAa1slT9UanlFRj/q41R20 OTncCbs6o68TKBteeesj8/j4FHQPTh2/Re25M9ZfISjsgPmVgZT2gUfimFugD/gJxXUa Y/ZumKnf+yH5sTq+k4EVXQYdgJGGVlS9w8qa6BTXISEnCmJiaklUasN8t7V8/3iVmHw8 bflAqgrL77IQ+3HArp9p4a2euWYspdu/EZWBL85/774O5s8Ho1o/0HsvH4WMAZkrc4rv LRqDLL/gngmBEUGvlWrr/W9jKW+BXOQ2M8o3qHChToo5mjZpf8TPELdswWAu9CM3YMo2 U8bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=dfDolGEcI25psdgp/XqFbXZMPxmCHVpULHJW3tD8O9s=; fh=5j0o6OFEu24fOrQaZO/hNst8I/Ql2AMTO7dm3pTN+tw=; b=QVDbqDhzFGLvtDM1cu+Epk33xHTy6vF1zfLfOYaPNUMwcEGqc8SHP1178THbmCPajI 94ZKQxo5Z8YCCjFo22VXtaj4qCGR6XnCEWJXKQ+WFZV5r+Vwdul98rjtcSxcjBCmUDNT HYA9WNu7+pO8DVh2ad5Uwr8ywuVABrGBgq4b5j317v5g0EZcpYJ5A9ufelclmTbIiknL WX5QNJKDYHWN6vyP8vORABtiN+4X0TOJAE0/8YAXObaHS6nHwwU6yuhHfVNB8VtXyBvb PDQjhQULh6drRpyxlTfjM8+Neli0cEg7Uo22zBwF9nPz7HQ1R2Io/m7awNTNcY3TacGD XvIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="H/kDWIJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id p3-20020a056a000b4300b006cbd3f3a2fcsi8255704pfo.77.2023.12.12.14.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 14:19:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="H/kDWIJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 22026801C919; Tue, 12 Dec 2023 14:19:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377794AbjLLWTI (ORCPT + 99 others); Tue, 12 Dec 2023 17:19:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377775AbjLLWTD (ORCPT ); Tue, 12 Dec 2023 17:19:03 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FBCDD2 for ; Tue, 12 Dec 2023 14:19:10 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E254C433C9; Tue, 12 Dec 2023 22:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702419549; bh=DIQcaPKuaymhD7B2Ud9Fhf3u0xd2DS9jqqZCj0jIqJU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=H/kDWIJ/MGPcXG58F38GqOruqiolfunk087bx8xzx9mNA/BNlFg4KI+5ldrxsGVQK z3D+Hj2NM1rrahKwTnw1hBpbDwNd7dEbuLbA0wjcImx/XoOtHdI3N14llKgKm/uS+p xHfL/CHEPVspOmxqMhIddyD0nrvlDw+tKwNEfGaNTXamRg1YwIwqs9qgwp4qQlBONH opWnYumzBfReu/Q2Er9atvwSWPw6eXyIz4cOQ0l9YqNiGWz/vd2UqAvbnGEdSAECu1 Y3Ie7RSdOKtgj25Knq2wvUR6UfEHh7MKBhm/tudZh+fbkcncPXpUtY48s88pc0NxD2 C5bu8mzHtpk/w== Date: Wed, 13 Dec 2023 07:19:04 +0900 From: Masami Hiramatsu (Google) To: "Rafael J. Wysocki" Cc: 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 v5] PM: sleep: Expose last succeeded resumed timestamp in sysfs Message-Id: <20231213071904.c466432fcf085b71d6bd97da@kernel.org> In-Reply-To: References: <170108151076.780347.2482745314490930894.stgit@mhiramat.roam.corp.google.com> <170108152012.780347.6355289232990337333.stgit@mhiramat.roam.corp.google.com> <20231212233245.14ae64258bdf07ae1d2f2ff9@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, 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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 14:19:28 -0800 (PST) On Tue, 12 Dec 2023 15:57:52 +0100 "Rafael J. Wysocki" wrote: > 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? This will be used to measure the delay of the user-space resuming as a metric of system health. > > > > > > > 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? For the metrics, the kernel side resume time and user-side resume time are important to know if any update caused regressions and separate the issue. > > > 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? Aaah, good catch! It should be right before thawing process, right? Thank you, -- Masami Hiramatsu (Google)