Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp301693lqj; Wed, 10 Apr 2024 10:48:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSRZ3SQC2mj7IxU3Dg1+niHo2SGw3M86ZrOPmUgEPu6mF0/eGpkzZMluDhIRImtg9ZwrjBDrH7K0GY8Qs9xjD5UsftEB5G72UCB9bb5A== X-Google-Smtp-Source: AGHT+IFuhMSta2legfum2O1H9ToUN5NG/5VyPf0oopTEJmvE5a/Fx0JvtzBFO+ORqXG2Zu5DUO9o X-Received: by 2002:a05:6830:1401:b0:6ea:2b38:7dda with SMTP id v1-20020a056830140100b006ea2b387ddamr3584641otp.22.1712771285189; Wed, 10 Apr 2024 10:48:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712771285; cv=pass; d=google.com; s=arc-20160816; b=TnlU/MUB7tm5kRR0VkvKYF4i3LkWcK39sW4bM0EIg4uy6gBecsLrGkQ/MIxz8wqfP7 I10Ccn6WGLiQU3Zvwa2L5VUJc5M/bm572msy9ypuqbb+Zw0vCYcQ8qGQADqYrKe7k8jl a2+s1v9vazkRydECTE/EhaKMgxwHb1sWoykSAJqHckQqrfOkGOHEA8WjqvwNJcnbzntE 3L5+MtVdTbbt7TU+V0+3HG2XWwtdWuKY8Jc1HjSyK1Bg9R3NPjcIPtmSAR0g7E/oG6dW aR3ZQzZ4ps2g1SEjb80blDBEGJWGuPL60Slzb1RZA7UjeePSIKtHCRwfcyBBvcY8sAyD CrrA== 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=GJDwTbWY6qLU9TIRoUmIACpjI86FZI4/f9RdElecKcA=; fh=0I/rqIlL4373pOps8oaBYF1ECx5xbCzL9wLU5PgpMhU=; b=ptmm6HTgIb8GfcgoXEIUF2h6SvTIRyvhozDsEiIcTLw9SE9qG8K6EJqSpQBHiqnypV IhGFZ3rGlY14fsRtjzvx2J8tQvLWwpsdvjFPxl1DdVMH5bjkvq2FtRsmhk+/fBnL/CA2 vq00HSI85qm38Qxmo6OEQQJRmtOPOsKp9CSUamTo/9HrzFTIDuVqcQi9/D9HGHoSvhVA 4eJRSTmKoDMS9wQ+K0TsqkpHQva/mI4T78SXbTiBVKJ4O8bQO2J37QltlIZiwwXsq/1l GFXcwsDhUA8QQW21Qi6Bc6tUcXofDFIp+/nAapWOfeLAneuNFray7N7TRz9A9wvJBZol 6TKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=XlQ7hpRB; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139133-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j2-20020a37ef02000000b0078a56957c2bsi12551663qkk.731.2024.04.10.10.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:48:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=XlQ7hpRB; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139133-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 48D641C23337 for ; Wed, 10 Apr 2024 17:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 185D919068A; Wed, 10 Apr 2024 17:45:06 +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="XlQ7hpRB" 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 3207517F39D; Wed, 10 Apr 2024 17:44:58 +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=1712771103; cv=none; b=t/f5I0FsXDy8gH90PR7Z7Aq4RQVv/2aSSPj6Oag5TIwjv10IhtcOJkvRwYmJPC2avXkY8swqZ+S4V8ZTaGr7VvQSM0PzUPWF6YWROvF7whMnptL7Fgu4eshdo3I7RQUejBh+QyLf6Mcd5+5hRh9OmSiUD57WRnTxNaIgRUkjAjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771103; c=relaxed/simple; bh=CifjVrjUKG+0XiMiN+5J1c80gqRxTGj0TWQ+VlD1gpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mxa1H4VvwcWlecHJxsw5+4pczpTwTwl3lwhALm6QBCHUzA0pPt2sR2Os6nwwWL5wmIGGeB+KiBEmEZRu1ISUegt+pKL2UOZqWVTLal6xZJASuIwD93wMU6VzFclNESqzjrRgCY6JFUUg+9q/YeaQN2TUOhBAn6xuAVBOhP3R828= 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=XlQ7hpRB 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 7f3fb694b8305f10; Wed, 10 Apr 2024 19:44:51 +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 17AB566C66F; Wed, 10 Apr 2024 19:44:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1712771091; bh=CifjVrjUKG+0XiMiN+5J1c80gqRxTGj0TWQ+VlD1gpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XlQ7hpRB3aaato4ZrW3UEMBhSR3zgyzYkSR3z0FfTX9J3mfCPfsSxsiq48K1qKaTk GGIOk7L5XTDBcwqgK3vqhJTCOCHnWMionLjtcAewNCve7GLBeqnoJ6+eej3bAsF1c5 9qwdLj3JOV+IURbJfc+UOV9I8bNYCgPJMmmsJ4EgU99HsFICyJ12JtCukOhwgnwBb+ tudBy84msFDYgBJuPA5uGGWFISVDK/7IAfbYdTE2Crn+cDyBHmJrK9oIxk1VK7PNu5 hxwSEUhusjbWO+dYMw4bf8h9+udNZpkmgvI+SJYMXmIcpPnOBE9aBfhEBfsVOAQ1Xr FZNnBL0D9Fqjw== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Srinivas Pandruvada Subject: [PATCH v1 12/16] thermal: gov_fair_share: Use trip thresholds instead of trip temperatures Date: Wed, 10 Apr 2024 18:58:56 +0200 Message-ID: <5484095.Sb9uPGUboI@kreacher> In-Reply-To: <13515747.uLZWGnKmhe@kreacher> References: <13515747.uLZWGnKmhe@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: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedguddufecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki In principle, the Fair Share governor should take trip hystereses into account. After all, once a trip has been crossed on the way up, mitigation is still needed until it is crossed on the way down. For this reason, make it use trip thresholds that are computed by the core when trips are crossed, so as to apply mitigations if the zone temperature is in a hysteresis rage of one or more trips that were crossed on the way up, but have not been crossed on the way down yet. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/gov_fair_share.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) Index: linux-pm/drivers/thermal/gov_fair_share.c =================================================================== --- linux-pm.orig/drivers/thermal/gov_fair_share.c +++ linux-pm/drivers/thermal/gov_fair_share.c @@ -17,28 +17,26 @@ static int get_trip_level(struct thermal_zone_device *tz) { - const struct thermal_trip *level_trip = NULL; + const struct thermal_trip_desc *level_td = NULL; const struct thermal_trip_desc *td; int trip_level = -1; for_each_trip_desc(tz, td) { - const struct thermal_trip *trip = &td->trip; - - if (trip->temperature >= tz->temperature) + if (td->threshold > tz->temperature) continue; trip_level++; - if (!level_trip || trip->temperature > level_trip->temperature) - level_trip = trip; + if (!level_td || td->threshold > level_td->threshold) + level_td = td; } /* Bail out if the temperature is not greater than any trips. */ if (trip_level < 0) return 0; - trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip), - level_trip->type); + trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, &level_td->trip), + level_td->trip.type); return trip_level; }