From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796036261; b=un+OUzg4znFim4GTwbODnwYER3UWj3YT5pKJvOhMPrKOjjI44+yjU6tgSFabIkctV66m tchRRv7j6TJ/IJAuTr0SihaI5eb1PoOOOLTP9MzEBJIPRk5aDw9+kdyvwBK8Jg5rnUY48 aVglPamqaarKAiEhfVKiDSfxzk/yFyi35URjGXkbpOYeUV+3iVRiCFw7Mnji+TqVbWZX+ aJoGlfWLawH1uQjPcRsAm34yAOgEgVMLkpjBZ/a818/xQAXnDsNGEUaF8XIBwZGHDXLpm S8/7lEpD/sZP+M1j1i5nUJd6s03unWZUALn3t/X3wYcBZrDs2mL2nv68PGt3Pi3C7xQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796036261; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=z9nlXbsQq2hDItDSlly1dP7CTknra3LMvbUbCPn3GBY=; b=YXXvG8D3uvh5+tthnVfC6eCmFgJLsPCKjUkuug5i/QRRp848gNKs5TpJXTLplyve6jwT JdBi8pnkuSONEhYwQqFJDpuLNpGQlQyUtoY5nAv+DuI2dx5OEvD1oXrnGJPsydpEspEb4 xf54a1IdBoQII72up0BSTjsULYRzEr+Z4q+A6XIc0I5e+ngIPVC3W8Ksct4ZKks+gOjhs 7GHvYSt8Lq7cFM/BMoHpkx6LvYNlvcEgbgaquBOFnvspxd31qAj80y/3/aPi9u4GlNuJF 9gpEVvkIVhwLFCFSEYK0uynYRUhlvwpTumWzPwYhoN65UIhDNLPuWYfqi5t9QI3bFZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SCIdMryS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5581606A31C; Mon, 30 Nov 2026 10:57:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SCIdMryS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A9FE1F0089A; Mon, 30 Nov 2026 10:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796036261; bh=z9nlXbsQq2hDItDSlly1dP7CTknra3LMvbUbCPn3GBY=; h=From:Subject:Date:To:Cc; b=SCIdMrySC2vAh2krYoK+F4MpwKYjmlMdVscCTacXFgKu90EgQk94/WG7kJNdorhen 5V2vYQsk4SXTiMADYSdLXT9UGg/vrrCroebNC8ILlXAXRLbsCc9zE5VeBGZtevFBA4 nfP+HsVsOL2DGFmuc0zW5lB8hyGFL3NJ52zbM/Nb6yMYits+5bKyHKnQN1A8hFx3Cr xGPnxbAY3PZdPUsd8x9fi6TybCQluXvlypZ+0/L5/89P+3l/EghBcqQZDZVgqaHIiC yWmEtwF4BYim9Y3ongiccXMMNuwoP2YIRvdu/cx8+73aMouPsw0kAYQnPzizYq7skp eWzeAfQi2Hb5A== From: Joshua Crofts Subject: [PATCH v4 0/2] PM: runtime: add new runtime metrics and summary Date: Mon, 30 Nov 2026 11:57:36 +0100 Message-Id: <20261130-pm-runtime-summary-v4-0-154a4c079ea7@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAKBWDWsC/33NQQ6CMBCF4auQrq1hWqjFlfcwLgodoFEKaYFIC He3sMJIXP4vmW9m4tEZ9OQazcThaLxpbYjkFJGiVrZCanRowmImACCmXUPdYHvTIPVD0yg3Uak 1yxRwyfOChMPOYWneG3p/hK6N71s3bT9GWNe/3Ag0psAwL5nkOr/I2xOdxde5dRVZvZHtDXFos GAorqVIk1yVsvwx+M5g/NDgwZCgMiGylCsJX8ayLB9AJ5tXPQEAAA== X-Change-ID: 20261110-pm-runtime-summary-8dd29a1383bc To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Danilo Krummrich , Johan Hovold , Samuel Wu Cc: linux-pm@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, Joshua Crofts X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796036261; l=4394; i=crofts@kernel.org; s=20260422; h=from:subject:message-id; bh=FCYz4szPOD/ziHIMyfD7Kj0BrPY3pX6BUlfav6ropIA=; b=3umLv34uSJKytmMyT9JUJN6RqmsLZIt0tnyc15pkqfXo6n6135evL3Xt0HsZOeWaCLb9RmitZ a2KQ9mmcpglBChm6/m21Fo4RIuIoOY2+z0VZ/fXVb54SnkBudjk48FH X-Developer-Key: i=crofts@kernel.org; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= Add a new set additional PM runtime metrics to improve power management debugging and reporting (these metrics may be useful to userspace utilities such as Powertop). MOTIVATION: The current implementation only measures the duration a device spends in suspended or active mode, which is very limiting. We can't find out how many times a device changed state or what its shortest suspend cycle was. This overview would be useful for detecting power "thrashing" and tuning autosuspend delays. Currently, sysfs only shows the total time a device spent in active and suspended mode; from an energy standpoint, a continuous 50 second suspension is different from a device cycling 1000 times for 50ms each (these transitions can be pretty power-hungry). This could help userspace utilities like PowerTOP to more effectively determine what is causing an increased power consumption. NEW FEATURES: This series introduces the following new metrics: - resume_count : number of successful transitions to active - suspend_count: number of successful transitions to suspended - last_suspended_time: duration of the most recent sleep cycle (ns) - min_suspended_time / max_suspended_time: shortest and longest sleep cycle durations to help detect power thrashing (ns) By reading the debugfs file /sys/kernel/debug/pm_runtime_summary, you get the following table describing the power stats of each device with runtime PM enabled: Device Status Resumes Suspends Active(ms) Suspend(ms) Last(ms) Min(ms) Max(ms) -------------------------------------------------------------------------------------------------------------------------- 0000:00:02.0 active 1 0 45688 0 0 0 0 0000:00:1f.0 active 1 0 45687 0 0 0 0 0000:00:1f.2 active 1 0 45686 0 0 0 0 0000:00:1f.3 suspended 1 1 1658 44028 0 0 0 00:03:0 active 15 14 19627 25899 42 5 14811 00:03:0.0 active 14 13 19626 25900 42 5 14811 TESTING: Tested with an x86_64 defconfig kernel and QEMU. AI ASSISTANCE: Gemini was used to prepare this series. Signed-off-by: Joshua Crofts --- Changes in v4: - Extract #ifdef CONFIG_DEBUG_FS guarded logic into new functions and add their stubs if debugfs isn't enabled (Rafael) - Fix timestamp calculations as pointed out by Sashiko - Link to v3: https://patch.msgid.link/20261123-pm-runtime-summary-v3-0-81a966953a81@kernel.org Changes in v3: - Guard new metrics with #ifdef CONFIG_DEBUG_FS to reduce overhead on non-debugfs enabled systems (Rafael) - Fix runtime status transition fixes flagged by Sashiko - Link to v2: https://lore.kernel.org/r/20261116-pm-runtime-summary-v2-0-a3d8654baf8f@kernel.org Changes in v2: - Drop sysfs patch as it would have a non-negligible impact on boot times and the debugfs summary is enough (Samuel Wu) - Expand cover letter - Fix Sashiko findings - typo in commit message, race condition, duplicate function call - Link to v1: https://lore.kernel.org/r/20261110-pm-runtime-summary-v1-0-12ebf283db78@kernel.org To: "Rafael J. Wysocki" To: Pavel Machek To: Len Brown To: Greg Kroah-Hartman To: Danilo Krummrich To: Johan Hovold Cc: linux-pm@vger.kernel.org Cc: driver-core@lists.linux.dev Cc: linux-kernel@vger.kernel.org --- Joshua Crofts (2): PM: runtime: add additional suspend/resume metrics PM: runtime: add debugfs entry for pm_runtime_summary drivers/base/power/runtime.c | 151 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 18 +++++- 2 files changed, 168 insertions(+), 1 deletion(-) --- base-commit: d40cb8a12ed25789f39404c5f7968a65e98d89c3 change-id: 20261110-pm-runtime-summary-8dd29a1383bc Best regards, -- Joshua Crofts