Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2196980lqt; Mon, 22 Apr 2024 04:35:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxoexm88ARPJD9W22Kvkdpv92hkE8s9GAKj0N5nE9ljg3Byls+inqeTRtmUZxQ23ZY4zupyHNv28316L6/07YKTwsL/bisK13Yc+0ZQA== X-Google-Smtp-Source: AGHT+IGVWiPSM1uy0RDjfCxO6iYmUzIvQpa9g/Sxd/tMhQbl4loTtux80P95T50lFooLzWS/Xecq X-Received: by 2002:a17:902:784f:b0:1e4:d548:818f with SMTP id e15-20020a170902784f00b001e4d548818fmr9574264pln.58.1713785719846; Mon, 22 Apr 2024 04:35:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713785719; cv=pass; d=google.com; s=arc-20160816; b=o0E8WPm4VTTYEpp04U3VjFdsNwbbZylFS63GdVKsxPs92/CaIPBYr8VBQ+6JvXe8sA G88bKSqJnbxvrAOiEVkYFdUHb6woT1afcaPRi1cxv59DEqGShMq3uo1Ntk9DoUtCuAQl vZ6KHQ4QetN025r5VCh5CVgyXdvQSSVWmlVbmW/a+1WK8Lun6WIWRYPHWYSdSyaEWoNH 0vZdVzU72eauCXwThdFWJLKLX3A/TaXUEKiTMNrdj64eimi78LDsMFVfnbcLs+hyszmv YVluXrrZDuq7K/a1j37G3641+Jq5CDYIOayZYCudtfSnnkAmRdRdq9ZJ2uxl+uzBdDWq cirA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=dIf1Hva7BksV6CTSG04cYP/KyBLNZUnGIeJL9x9fhWA=; fh=wOhU+RfGR6AETSQpmLn4c4kjE8Q9JmYwekkxN+5ihyo=; b=op5kQzqR1v7j/cjgwfZ/YdB26UwUpuqVGPo+x2w5XGeF4bl1J64bbjFziyec0Ptptz fQrWC/fm0xF6IB+PKivYhTHYR8SK1mOiIDor9rD4nHDWJ84/iBSuORBHhfwZ4Y1HGv6+ PH27oIjeTYISu5IzMJikb0de+bKNdKQN3upKsUTHUl2O41986tE8eVOFeTZ8JAVLp28p WDIsro0+32IDqKgB3xaHTZkpxFnIzrp1Vt2Ygm2Ho5epvG1mbq/Fi0SSGkXJLGHIMMax LPKWZla8Ukr9yApmP/Gr+/xjpHUF6SAcMlS68g+5/6MjWzFTwpn7VqLohG3Ao1I8TO4m Rgvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-153276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lv16-20020a1709032a9000b001e5373b0e46si7913702plb.66.2024.04.22.04.35.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 04:35:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-153276-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 15F8E285980 for ; Mon, 22 Apr 2024 11:15:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7ED7D146D75; Mon, 22 Apr 2024 11:14:51 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90775146A6F; Mon, 22 Apr 2024 11:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713784491; cv=none; b=Xv//Wums4SbeBkWnmOJFdji8h5xmR+xy0ATEXaFdV5kP2jErkuBjIifdN8Ozo26rLvUavXJyqzHWGu59kcRkIURp59WBpQ66Gg9eZxvuCiJtn5RbLaHprNTMplUI/KbNL6VGDp4VGoRxu97/5dH2iO7lfxp+5dM65z0toa703aQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713784491; c=relaxed/simple; bh=9nemOUTQvwBWQ8gRNksNJmnj7GhJzwX5Qhmg5BnR3RU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rCXDNB6WYh156OLDAs0/xhFY/qs604K+vHWZlrCsrEmTmBOsaiD4S6Yf8rbI2pgR28argKWjtkufv/kbPzWCjk3ITI7E5GBnpx3NQRWzNAWYgApo9cf0F9uQWwPHJK6S0Oc8Itr4nZMzfb9EAUq+zHJ7ASceznaajfPLOi/WFpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3DBB6339; Mon, 22 Apr 2024 04:15:17 -0700 (PDT) Received: from [10.57.75.149] (unknown [10.57.75.149]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FBBE3F7BD; Mon, 22 Apr 2024 04:14:47 -0700 (PDT) Message-ID: Date: Mon, 22 Apr 2024 12:14:56 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/3] thermal/debugfs: Avoid excessive updates of trip point statistics To: "Rafael J. Wysocki" Cc: LKML , Linux PM , "Rafael J. Wysocki" , Daniel Lezcano References: <4918025.31r3eYUQgx@kreacher> <4890052.GXAFRqVoOG@kreacher> Content-Language: en-US From: Lukasz Luba In-Reply-To: <4890052.GXAFRqVoOG@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/17/24 14:09, Rafael J. Wysocki wrote: > 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); > > > > Reviewed-by: Lukasz Luba