Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3163150lqt; Tue, 23 Apr 2024 12:03:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7AKpHA/ONUZ4O8N1Rf2t1DOYz8Qi8BT1CLkOLsi/67s3FUS8mn1RnDjyEu7IOiPHIMAtnoW3PBIJlPOT02meZ0gMnifeeuHgJm47BbQ== X-Google-Smtp-Source: AGHT+IFniD38C5Wj79Xjk/ij3zcjNAr/+B5zwm/g2z+eVW7vqRIFnMTvdWhJlevx7grtJ7+U+qGW X-Received: by 2002:a17:906:f2da:b0:a46:cef3:4aba with SMTP id gz26-20020a170906f2da00b00a46cef34abamr133496ejb.75.1713899025596; Tue, 23 Apr 2024 12:03:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713899025; cv=pass; d=google.com; s=arc-20160816; b=XuqUG0/47ZEja30gt957+Ha92IvkXbqW0GAVl1oFeJKqAhe2wbystzUoXYNEJF5dlT K2wRxAoe+zh6vbe0Zb/HV7/6dBJWH2Pw9T4XRlqZlkbZ/KsF+jnYpbcopNmCs7Bj69L5 vLjbIqGXiHSGNbt9DwgEHd1b7iPatps42MrwIQJb4G2+eaoFPU+WrcbspJTZY/nq/SS+ /yXZfxuYpwUZ/4SNQyI1ABn2dJw9nf0N/+32zA2sw0E04q04qut02MEsBBeK5gh4GTEZ Y1jX1xXHT4QCtNHm1QnunmwkPNUI2RM8Os4GJF7zJDuZMqAy4fGHS+FsDJl7am5BLyV2 m5yg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=T16PmUM0AjBrnc4T+4GtjCVdGUrfuXSkUT9OSghqlLA=; fh=HP39+yda0QHsXMT3XaLy3KM419Yj59UqEZWQZo+gOsI=; b=Zfu3HVLkOBkkrrR9T9jy0ijHBWf3A6GmJ51yv9LTw3qfMH8JX9tnPfMylLeYDJypg0 cvZlg7QBU3/kq/7iKSiZKbn+OpdOC+WVSPmey38s0TMLQO5/gqlLJN5Osb7Fc8a8Jz+M sGV2UOw8PelpdHVMw/SmEBx6bVflb1O9RyYNk5gISB2t4EBQ/zXGxrGoRq29Bldgw2CW qklpE2dptep4LXCbbIf3v3gNqDA4fsjwK+umPgojaJwOOEe/WAInqZ2/8vNBeW5xYzQ5 7iQYq84XShKmuAN62hjV+sdYSwlPK1kXu+P1/P4a+zGBjDRfVcHd9AbA0wygnVqMwzC6 eq3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=RgqrazB8; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-155776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155776-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m11-20020a1709062acb00b00a4e36c33910si7562818eje.479.2024.04.23.12.03.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 12:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=RgqrazB8; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-155776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155776-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1963A1F24253 for ; Tue, 23 Apr 2024 19:03:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52FB41411E6; Tue, 23 Apr 2024 19:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="RgqrazB8" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 4EB0E13FD8C; Tue, 23 Apr 2024 19:03:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713899001; cv=none; b=aGpO1JUjM2W6uiEw0x1z4wymy1Kr0IguOEVRkyRWfBeexrZHG13IjlwQsMO00FkcZajA4ESZV7gL7xpu55Hj6uZkZ43IUc7kTLPr2lEsA68lVV0N6v13LzVLXjIYZrYkBIOgwF/VnwgJfgNOvrT1veU3E1UOn8Oen+11K8TWmhI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713899001; c=relaxed/simple; bh=Bv3kllpQAlF6/y8cUblx2UV+ugsq2CFF5/mk5tDG3sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FqOK3+KHK3OqTvGcbv+CpaRc8uHPbIyNlKZuzs7aNq1T2JcJejFZZWq691CBHwLjmj/9s5WNFfwAGgB3dZ8wyH67iUrGTRQkNpQ/zja9arb2EGcLAZ3Nb8vWaY01P+Td64S09kUNX0aXoNWMtogUg13QnX6rdGISfga533t9HyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=RgqrazB8 reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 49a53ae6f26f328d; Tue, 23 Apr 2024 20:03:17 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 14FA466DB86; Tue, 23 Apr 2024 20:03:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1713895397; bh=Bv3kllpQAlF6/y8cUblx2UV+ugsq2CFF5/mk5tDG3sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RgqrazB8H4YffU3uZ1a/E7XDvYFy3CfPZIdF9BDc6LBUtY2N+n1NBvSLafrDD74Uz xTHmrcUAytZhLBf+ulCBNNYMR32U2PKF16iZ3iv06d6JuwQ8G1Wm4WfliLfOoralHn mijTmEaxYlIc3wDLc1PCvBRFcabgpy4ZppPFQPa3F7K9Z67mFMdqm3xuiT4uJgxZaw P9/DnehWPuVCJqwnGvftwNFNwgeBA6R860CdIMhn4UNthN0o9UwNy6OZiKlLh6CJFu LN2ft37U+8ji6XIbfDfilq7nnxl9E5fVAPR63WU4Ya5/3bpMlAKdbiV/hsoA/Hg+ON o/KAfCJm+Z/0Q== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano Subject: [PATCH v1 3/3] thermal/debugfs: Avoid printing zero duration for mitigation episodes in progress Date: Tue, 23 Apr 2024 20:02:16 +0200 Message-ID: <2933330.e9J7NaK4W3@kreacher> In-Reply-To: <5774279.DvuYhMxLoT@kreacher> References: <5774279.DvuYhMxLoT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudeluddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthhqredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedtvdefgeelvdefvdevveehvdetfeefhedvueeiudekieeltdetgfdviefhgfetteenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgii tggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 =46rom: Rafael J. Wysocki If a thermal mitigation event is in progress, its duration value has not been updated yet, so 0 will be printed as the event duration by tze_seq_show() which is confusing. Avoid doing that by marking the beginning of the event with the KTIME_MIN duration value and making tze_seq_show() compute the current event duration on the fly, in which case '>' will be printed instead of '=3D' in the event duration value field. Similarly, for trip points that have been crossed on the down, mark the end of mitigation with the KTIME_MAX timestamp value and make tze_seq_show() compute the current duration on the fly for the trip points still involved in the mitigation, in which cases the duration value printed by it will be prepended with a '>' character. =46ixes: 7ef01f228c9f ("thermal/debugfs: Add thermal debugfs information fo= r mitigation episodes") Signed-off-by: Rafael J. Wysocki =2D-- drivers/thermal/thermal_debugfs.c | 39 ++++++++++++++++++++++++++++++++-= =2D---- 1 file changed, 33 insertions(+), 6 deletions(-) Index: linux-pm/drivers/thermal/thermal_debugfs.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- linux-pm.orig/drivers/thermal/thermal_debugfs.c +++ linux-pm/drivers/thermal/thermal_debugfs.c @@ -530,6 +530,7 @@ static struct tz_episode *thermal_debugf =20 INIT_LIST_HEAD(&tze->node); tze->timestamp =3D now; + tze->duration =3D KTIME_MIN; =20 for (i =3D 0; i < tz->num_trips; i++) { tze->trip_stats[i].min =3D INT_MAX; @@ -665,6 +666,9 @@ void thermal_debug_tz_trip_down(struct t tze->trip_stats[trip_id].duration =3D ktime_add(delta, tze->trip_stats[trip_id].duration); =20 + /* Mark the end of mitigation for this trip point. */ + tze->trip_stats[trip_id].timestamp =3D KTIME_MAX; + /* * This event closes the mitigation as we are crossing the * last trip point the way down. @@ -742,15 +746,25 @@ static int tze_seq_show(struct seq_file struct thermal_trip_desc *td; struct tz_episode *tze; const char *type; + u64 duration_ms; int trip_id; + char c; =20 tze =3D list_entry((struct list_head *)v, struct tz_episode, node); =20 =2D seq_printf(s, ",-Mitigation at %lluus, duration=3D%llums\n", =2D ktime_to_us(tze->timestamp), =2D ktime_to_ms(tze->duration)); + if (tze->duration =3D=3D KTIME_MIN) { + /* Mitigation in progress. */ + duration_ms =3D ktime_to_ms(ktime_sub(ktime_get(), tze->timestamp)); + c =3D '>'; + } else { + duration_ms =3D ktime_to_ms(tze->duration); + c =3D '=3D'; + } + + seq_printf(s, ",-Mitigation at %lluus, duration%c%llums\n", + ktime_to_us(tze->timestamp), c, duration_ms); =20 =2D seq_printf(s, "| trip | type | temp(=C2=B0mC) | hyst(=C2=B0mC) | d= uration | avg(=C2=B0mC) | min(=C2=B0mC) | max(=C2=B0mC) |\n"); + seq_printf(s, "| trip | type | temp(=C2=B0mC) | hyst(=C2=B0mC) | dur= ation | avg(=C2=B0mC) | min(=C2=B0mC) | max(=C2=B0mC) |\n"); =20 for_each_trip_desc(tz, td) { const struct thermal_trip *trip =3D &td->trip; @@ -782,12 +796,25 @@ static int tze_seq_show(struct seq_file else type =3D "hot"; =20 =2D seq_printf(s, "| %*d | %*s | %*d | %*d | %*lld | %*d | %*d | %*d |\n", + if (trip_stats->timestamp !=3D KTIME_MAX) { + /* Mitigation in progress. */ + ktime_t delta =3D ktime_sub(ktime_get(), + trip_stats->timestamp); + + delta =3D ktime_add(delta, trip_stats->duration); + duration_ms =3D ktime_to_ms(delta); + c =3D '>'; + } else { + duration_ms =3D ktime_to_ms(trip_stats->duration); + c =3D ' '; + } + + seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d | %*d |\n", 4 , trip_id, 8, type, 9, trip->temperature, 9, trip->hysteresis, =2D 10, ktime_to_ms(trip_stats->duration), + c, 10, duration_ms, 9, trip_stats->avg, 9, trip_stats->min, 9, trip_stats->max);