Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp198804rdb; Thu, 25 Jan 2024 12:19:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IETsKzuMKFNS5nnGTMa3pomxMab+BRa+obvqArtcPxNbVHyB8LX4S+6fwGnFlDWnxqoGf18 X-Received: by 2002:a17:902:7004:b0:1d7:81dc:f65 with SMTP id y4-20020a170902700400b001d781dc0f65mr248816plk.90.1706213971930; Thu, 25 Jan 2024 12:19:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706213971; cv=pass; d=google.com; s=arc-20160816; b=AVgdnillP3p5M474Kleqkmh+J75HaI23uxXmestRs92YtjDWF4eOVaALrigJFUIXCA gfwT8MYKItbnFtaW7N/xyDk/s2Ebl92fqv5Ou6R3aO7zyd5hF+T/9Pbm9uo7wMaiKQhN +kT3P02TIo2pKVwCesrXhokUvqu/20e0T3Bo3b25gEcH/Ox/ed0J1OPpLmTIPeevx19B sXOjN58rhqc6rOyLzoCdmlN1PfDJyC93qMCH2XOap4EeqVFpbRONEpxxjvt5ANKBayvX k5ZBQ3bVQEcVLZdoSekx4YW0t8jSAc/6N4U8stg65a9dxvx+35StKmUINKDXyKzlNtY8 nZ2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=dvJqcfERuxA2PaIU85t1WCbw/9zN6boVzq5sjthkjTM=; fh=GyNL4qsvNkB9EQhlhzfe38SzEM4UrnuuXUivniPddxQ=; b=zNaldZ9ctt2n0Pc1ASXzauEas3+0tMXxiNUA2Ixx/Dg+K+GAbb3+OHRsriR7/DiI5w CZRwxzp8636IrMRY9nwiy5ERw6EJEewy6rqnVG+b9Y5sHx8cgR51kAgvEvfzA7qSS9O/ Qejx1yuOWsZmyX7tv3RBO4vh0yV0eYArl9D785pUE860xV5B075AwAeThFfEWjpUGTz9 r+wTDoQkSJHIFc1x6IT2ArOtOc1bmz2Fg9zkjA6unYtlhGZ3A1FUvU7UhjOWQCwuJnnM hT1DTX8Sn60ThXNTwf5dlxKGJ7M07xOy5fXP4cU4z9czsqoRclG7t5YEQQuCqB1YaEyg 8jWQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-39241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o6-20020a1709026b0600b001d5e247e336si13620576plk.628.2024.01.25.12.19.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 12:19:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-39241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39241-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8E98D2950A5 for ; Thu, 25 Jan 2024 20:19:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0B5B137C25; Thu, 25 Jan 2024 20:19:22 +0000 (UTC) Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6F5313664C; Thu, 25 Jan 2024 20:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706213962; cv=none; b=F+RbDwgmp1wOvf8sLGAu0ApsV44QF/n7PqR9kOoy15RqY/5ydyhlI1kEVmUy8dijIOLJEHDtvO+xcaueRMdg1eWP1UkgvtUA9oPa7vmPnEHF6Q8K+3NQVuAWkD2ClUTKss81D+YVhoaakZ4p4Wzk5PD4NXK2ak9/bU+6CTITkNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706213962; c=relaxed/simple; bh=ipLhhFgZ90F56vmCiTIpx4S2UFI4/MpHlqyOUteNJhE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lg6ZweFIwIiXg1whYwWkAD9lOx+uuAJ9h0YtvskZaZ4dJk8MIgQUbQzmgMN79YnMn4llzM/lhfbkkXEoROuvM6g0Dwo3+WcDfVyWkuYVx89JCNWBlggFZsxXFl+samFjyTtVzrpOBzlwA9IDndRdomUuHmnINHBBx6MwVhnjkGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-214df50177fso14513fac.1; Thu, 25 Jan 2024 12:19:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706213960; x=1706818760; 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=dvJqcfERuxA2PaIU85t1WCbw/9zN6boVzq5sjthkjTM=; b=gbA3pABPggjlWLNrWqeECoXGlI7BIDDiwaB8WGS8xv8XAVIWNk5zGKXl21cGVp9WK8 DxDvCqpT45YVK+t0DzU39i4eWUf1G8qvYv8AXlB1RArUxHvMSZO87UmuARg1tFZBMfrm f1L5DL364J150VPwg7xDaUJZWnFHbD4H+3GUghjB86eQRVEP8ic4xoiE9y3Dxaaq/ueR J2oOpLtkSq8ctl0zj5F3DJqVJHrviabNo0+1BOhzcjUwXiUBHFQuZ0YZOslDuouwwALx rkoNoXNZmDgg7DR48OOmrgHNZDILW56pwOc8moxyqBdlQF6SIhbfBnB9/l8+vp/O3OOp QbnA== X-Gm-Message-State: AOJu0Yy/JArVd1Gpurw8YMSUxxzMrHugKA1jh87lz8/Ct4LL2cX+lAhI ORYlqXRzMw6HkNk31V7YEAd6KveO5aNRqXrpsYeYLnnY38Hr6QYQWfL1H1EsWWURBbpGo9QHA1R LS4qH7/5VoXfSCe/ox8eXNoqxiv3NqPjf X-Received: by 2002:a05:6871:53ca:b0:214:b796:73c with SMTP id hz10-20020a05687153ca00b00214b796073cmr447136oac.5.1706213959875; Thu, 25 Jan 2024 12:19:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <170359668692.1864392.6909734045167510522.stgit@mhiramat.roam.corp.google.com> <170359669607.1864392.5078004271237566637.stgit@mhiramat.roam.corp.google.com> <20240117090706.3522d23763fab9dcea21aee1@kernel.org> <20240125094320.13a0844614375deb8bb06db6@kernel.org> In-Reply-To: <20240125094320.13a0844614375deb8bb06db6@kernel.org> From: "Rafael J. Wysocki" Date: Thu, 25 Jan 2024 21:19:07 +0100 Message-ID: Subject: Re: [PATCH v7] PM: sleep: Expose last succeeded resumed timestamp in sysfs To: Masami Hiramatsu Cc: Brian Norris , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Randy Dunlap , suleiman@google.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024 at 1:43=E2=80=AFAM Masami Hiramatsu wrote: > > On Mon, 22 Jan 2024 18:08:22 -0800 > Brian Norris wrote: > > > On Fri, Jan 19, 2024 at 1:08=E2=80=AFPM Rafael J. Wysocki wrote: > > > On Wed, Jan 17, 2024 at 1:07=E2=80=AFAM Masami Hiramatsu wrote: > > > > > > > > Gently ping, > > > > > > > > I would like to know this is enough or I should add more info/updat= e. > > > > > > I still am not sure what this is going to be useful for. > > > > > > Do you have a specific example? > > > > Since there seems to be some communication gap here, I'll give it a try= . > > > > First, I'll paste the key phrase of its use case from the cover letter: > > > > "we would like to know how long the resume processes are taken in ker= nel > > and in user-space" > > > > This is a "system measurement" question, for use in tests (e.g., in a > > test lab for CI or for pre-release testing, where we suspend > > Chromebooks, wake them back up, and measure how long the wakeup took) > > or for user-reported metrics (e.g., similar statistics from real > > users' systems, if they've agreed to automatically report usage > > statistics, back to Google). We'd like to know how long it takes for a > > system to wake up, so we can detect when there are problems that lead > > to a slow system-resume experience. The user experience includes both > > time spent in the kernel and time spent after user space has thawed > > (and is spending time in potentially complex power and display manager > > stacks) before a Chromebook's display lights back up. > > Thanks Brian for explaining, this is correctly explained how we are > using this for measuring resume process duration. > > > If I understand the whole of Masami's work correctly, I believe we're > > taking "timestamps parsed out of dmesg" (or potentially out of ftrace, > > trace events, etc.) to measure the kernel side, plus "timestamp > > provided here in CLOCK_MONOTONIC" and "timestamp determined in our > > power/display managers" to measure user space. > > Yes, I decided to decouple the kernel and user space because the clock > subsystem is adjusted when resuming. So for the kernel, we will use > local clock (which is not exposed to user space), and use CLOCK_MONOTONIC > for the user space. The problem with this split is that you cannot know how much time elapses between the "successful kernel resume time" and the time when user space gets to resume. As of this patch, the kernel timestamp is taken when the kernel is about to thaw user space and some user space tasks may start running right away. Some other tasks, however, will wait for what happens next in the kernel (because it is not done with resuming yet) and some of them will wait until explicitly asked to resume by the resume process IIUC. Your results depend on which tasks participate in the "user experience", so to speak. If they are the tasks that wait to be kicked by the resume process, the kernel timestamp taken as per the above is useless for them, because there is quite some stuff that happens in the kernel before they will get kicked. Moreover, some tasks will wait for certain device drivers to get ready after the rest of the system resumes and that may still take some more time after the kernel has returned to the process driving the system suspend-resume. I'm not sure if there is a single point which can be used as a "user space resume start" time for every task, which is why I'm not convinced about this patch. BTW, there is a utility called sleepgraph that measures the kernel part of the system suspend-resume. It does its best to measure it very precisely and uses different techniques for that. Also, it is included in the kernel source tree. Can you please have a look at it and see how much there is in common between it and your tools? Maybe there are some interfaces that can be used in common, or maybe it could benefit from some interfaces that you are planning to add.