From patchwork Mon Nov 27 10:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu \(Google\)" X-Patchwork-Id: 749748 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 F112D18C11 for ; Mon, 27 Nov 2023 10:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TyIUHHg4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDF13C433CC; Mon, 27 Nov 2023 10:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701081514; bh=6S5QzfClwV19elQA6yctifho8YSJOuo6Kodrr9D3l60=; h=From:To:Cc:Subject:Date:From; b=TyIUHHg4GYm/FuiPshCH2hFp6IIOnD3uEvwla+8K3u2GfAy+cJgM6839lux7r9wIQ +hN/RqrdPSbx4jjEVKupD3GO5heyv5c+CBEyQrF0HnzU2/PRbJivglT8xwORjIeu/m Chli1Ja2ehX7U3cqHuSzNj9gLzZ9kfLQKyL0DXYJE1KoBDLAiM72SDg0AkEQJHFx33 W0/qR4BZ5QQjFohQ1QCG+SxqzciGZvTMJ8Sp5jnpsmc7V3rtQzic/IFCK2coEcuY7q dWhBEfdry3kQlBBwLA/Gd2yLD656DI7qW/PZ2CudlSe4JC2ePe3INUfYaQzB84elS2 XTrLWmDoxr6Zg== From: "Masami Hiramatsu (Google)" To: "Rafael J . Wysocki" , Pavel Machek , Len Brown , Randy Dunlap Cc: suleiman@google.com, briannorris@google.com, Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v5 0/1] PM: sleep: Expose last succeeded resumed timestamp in sysfs Date: Mon, 27 Nov 2023 19:38:30 +0900 Message-ID: <170108151076.780347.2482745314490930894.stgit@mhiramat.roam.corp.google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi, Here is the 5th version of the patch to expose last succeeded resumed timestamp in sysfs as /sys/power/suspend_stats/last_success_resume_time. This version is just updated for v6.7-rc3. This allows us to find when the kernel resume process successfully done in the sysfs in MONOTONIC clock. Thus we can measure the time taken by the user space resume process at any point in time. This will help us to detect abnormal value (longer time) process in the resuming and quickly decide the root cause is in the kernel or user-space. The kernel side we can use many tools (e.g. printk or ftrace) but for user-space we need to define the starting point of the resuming process. Actually, the kernel side needs to use local clock because the clock subsystem is also suspended. But in that case, user space can not use that timestamp because the local clock is not exposed. So this will be used something like where_the_user_space_resume_finish() { clock_gettime(CLOCK_MONOTONIC, &etime_ts); fileread("/sys/.../last_success_resume_time", stime); convert_timespec(stime, &stime_ts); user_resume_time = timespec_delta(&etime_ts, &stime_ts); ... } Thank you, --- Masami Hiramatsu (1): PM: sleep: Expose last succeeded resumed timestamp in sysfs Documentation/ABI/testing/sysfs-power | 10 ++++++++++ include/linux/suspend.h | 2 ++ kernel/power/main.c | 15 +++++++++++++++ kernel/power/suspend.c | 1 + 4 files changed, 28 insertions(+) -- Masami Hiramatsu (Google)