Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp613092lqb; Wed, 17 Apr 2024 06:22:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWghhH8BdRaZ0HJTvxyIkCCbRUenehILLO587hr0wDQt6tT02gixctn/RsTz5pZuRsqlJu+6MuJxUa/P7fXwyIGyhAokCtS9utSusET8Q== X-Google-Smtp-Source: AGHT+IFLC3RPoKojpk/ImP8Grkml1vgv+uhIGMXiDN/S/e/BSSoNNTuQFn6tUPcJgfLn0Zb98Zm1 X-Received: by 2002:a50:c047:0:b0:570:2198:b3ca with SMTP id u7-20020a50c047000000b005702198b3camr7967822edd.14.1713360124580; Wed, 17 Apr 2024 06:22:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713360124; cv=pass; d=google.com; s=arc-20160816; b=yhLWxhK0oGH+2tOTg2Hpv716UNhXHerts9tlFHBV3wsNXlRASoMYs2kgYJOGZrQuEj Ylmoz1KfaOx/pZYsCZER975cyhy+6l2IOMfhOUhHzBahE3pIRo4hcgWHziNH6OaIZ3Kw a6oF69RzY1rKUy523MrmHEJ85FRPEBqMl5Eq6YQCzV/ROAKx61Sf0GPIBPi7rRXcdQ8O VUbxzMjexJXlSPB93H0TuBgASLYiQF+8EMIPjMsXfnc6i4b+GUC3wJFgG7IDhArDbd3D /99PHMA19lcPSW9Zfe0ozE40OkRN7rTjLlN3oXdOEla67RcViUMV8oZfs41PoyRzluBu KHaA== 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=tvXJxKxRWEI3ZXELLeAeurDbyrZHijTH0OLIJbr0ZfI=; fh=HP39+yda0QHsXMT3XaLy3KM419Yj59UqEZWQZo+gOsI=; b=YKP33HQfMw9YVF9/J/yenut3ZIhwgcS3NT+EPwxg7wFk6K0KRbX2z2zr4EhJ2sBxzn Opeb71HREsbE6x+i5YZaXyox+M5v0znvrqA/WW+e50GsGVHfzCL2PFDogFEuADHDzVXS uhH5xsg3WSFGkoPzMP18fdEiB0ea/sbNVAOgk4ggTL9lrAltYZrLqryEWWssJrWxagV7 obKIwR8i8EsoGXZRS89zYdNGwOOfcmcE1dfNAzmysgacmESB0275sQNOS73y1RXwTy2m 9J4GuGNg4GQkmefIRyPTTj8gQK5Isq7DoovqR/o1J8BIeUYvFBOhpsfAbT6YldH7xpeB BFQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=FtBWrzas; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-148523-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148523-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 c24-20020a50f618000000b005709c93d4a8si352098edn.433.2024.04.17.06.22.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 06:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148523-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=FtBWrzas; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-148523-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148523-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 B218B1F25895 for ; Wed, 17 Apr 2024 13:13:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 839ED13D2A9; Wed, 17 Apr 2024 13:12:10 +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="FtBWrzas" 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 DD00913F420; Wed, 17 Apr 2024 13:12:06 +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=1713359529; cv=none; b=CfpbCqt25eNDvyBmy987H2VgdbBwBo3dNMG/vJHZeIzKn/SpbVXqMKGR4Cl4QddQb5JPpjk8JmZQT4GtCZRBtYhnyjnxdUi7nsZfmiJfLMrTkmPVhbLX7g1UusrarhciNikFAzNxgQ1q/0qdpYckplPep+Ln6GdZXfEaxyc7OHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359529; c=relaxed/simple; bh=AiW/0Dtry5H3PJpVJs+HnEugJ5BjdEdzU+HcYJktYVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ar7UmGurr3LEHLVeJlVdsG+RtIzHw1T60yJJHzU4j/8bcTZ3QveC2+wWnPxRCnzAD151vy+alEe4EO7Ip/FwIzOWuPx6yGlI2+VGguaRPilj4vmA26w2uRlmqmDJwChQy0P+b6zzmDeuL2VoOrkcSnNVIQfUIvs1u1/jIH9JO/4= 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=FtBWrzas 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 e2b5c418384b6776; Wed, 17 Apr 2024 15:11:58 +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 63B2A66D25E; Wed, 17 Apr 2024 15:11:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1713359518; bh=AiW/0Dtry5H3PJpVJs+HnEugJ5BjdEdzU+HcYJktYVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FtBWrzas8MbmLhMm6q17mF//aXY8FGZvDSE+m8UEinpFZFraQ0du9DkeZ1XtMfuq/ lWeaFADwcVxYAhO6apI/DqIdPRCT118mRAVUEOCTAYkEqpaAbxcvETGncPKFPy7+ls YBzIb9O5KSgXqL6na+hMf3qikOth4GRLbkbQVbxTwYssfSUtiskgkrUp1QvFG+syi8 1W7C7LeAO1LOI0WVDY5+hv3r2S7fiND1DHhkliewxZyARwPOaYcZqVvqDJADtM2XLx NrB4HR45wdIfpNPSjGuyoUGkZJw1TvDZQ9r9eDmc6gA3aWf6b+Ea9X5ebYaZvRb9u3 R112Vm9Zhkf2w== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano Subject: [PATCH v1 1/3] thermal/debugfs: Avoid excessive updates of trip point statistics Date: Wed, 17 Apr 2024 15:09:46 +0200 Message-ID: <4890052.GXAFRqVoOG@kreacher> In-Reply-To: <4918025.31r3eYUQgx@kreacher> References: <4918025.31r3eYUQgx@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit 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: gggruggvucftvghtrhhoucdtuddrgedvledrudejkedgiedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopegurghnihgvlhdrlhgviigt rghnoheslhhinhgrrhhordhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki Since thermal_debug_update_temp() is called before invoking thermal_debug_tz_trip_down() for the trips that were crossed by the zone temperature on the way up, it updates the statistics for them as though the current zone temperature was above the low temperature of each of them. However, if a given trip has just been crossed on the way down, the zone temperature is in fact below its low temperature, but this is handled by thermal_debug_tz_trip_down() running after the update of the trip statistics. The remedy is to call thermal_debug_update_temp() after thermal_debug_tz_trip_down() has been invoked for all of the trips in question, but then thermal_debug_tz_trip_up() needs to be adjusted, so it does not update the statistics for the trips that has just been crossed on the way up, as that will be taken care of by thermal_debug_update_temp() down the road. Modify the code accordingly. Fixes: 7ef01f228c9f ("thermal/debugfs: Add thermal debugfs information for mitigation episodes") Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 3 ++- drivers/thermal/thermal_debugfs.c | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -427,7 +427,6 @@ static void update_temperature(struct th trace_thermal_temperature(tz); thermal_genl_sampling_temp(tz->id, temp); - thermal_debug_update_temp(tz); } static void thermal_zone_device_check(struct work_struct *work) @@ -505,6 +504,8 @@ void __thermal_zone_device_update(struct if (governor->manage) governor->manage(tz); + thermal_debug_update_temp(tz); + monitor_thermal_zone(tz); } Index: linux-pm/drivers/thermal/thermal_debugfs.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_debugfs.c +++ linux-pm/drivers/thermal/thermal_debugfs.c @@ -545,7 +545,6 @@ void thermal_debug_tz_trip_up(struct the struct tz_episode *tze; struct tz_debugfs *tz_dbg; struct thermal_debugfs *thermal_dbg = tz->debugfs; - int temperature = tz->temperature; int trip_id = thermal_zone_trip_id(tz, trip); ktime_t now = ktime_get(); @@ -614,12 +613,6 @@ void thermal_debug_tz_trip_up(struct the tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); tze->trip_stats[trip_id].timestamp = now; - tze->trip_stats[trip_id].max = max(tze->trip_stats[trip_id].max, temperature); - tze->trip_stats[trip_id].min = min(tze->trip_stats[trip_id].min, temperature); - tze->trip_stats[trip_id].count++; - tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg + - (temperature - tze->trip_stats[trip_id].avg) / - tze->trip_stats[trip_id].count; unlock: mutex_unlock(&thermal_dbg->lock);