lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4918593.31r3eYUQgx@kreacher>
Date: Mon, 15 Jan 2024 18:55:13 +0100
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Linux PM <linux-pm@...r.kernel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, Daniel Lezcano <daniel.lezcano@...aro.org>, Lukasz Luba <lukasz.luba@....com>, Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>, Zhang Rui <rui.zhang@...el.com>
Subject: [PATCH  v1 1/2] thermal: gov_fair_share: Fix dependency on trip points ordering

From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

The computation in the fair share governor's get_trip_level() function
currently works under the assumption that the temperature ordering of
trips[] in a thermal zone is ascending, which need not be the case.

However, get_trip_level() can be made work regardless of whether or not
the trips table is ordered by temperature in any way, so change it
accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
---
 drivers/thermal/gov_fair_share.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 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
@@ -18,22 +18,24 @@
 static int get_trip_level(struct thermal_zone_device *tz)
 {
 	const struct thermal_trip *trip, *level_trip = NULL;
-	int trip_level;
+	int trip_level = -1;
 
 	for_each_trip(tz, trip) {
 		if (trip->temperature >= tz->temperature)
-			break;
+			continue;
 
-		level_trip = trip;
+		trip_level++;
+
+		if (!level_trip || trip->temperature > level_trip->temperature)
+			level_trip = trip;
 	}
 
 	/*  Bail out if the temperature is not greater than any trips. */
-	if (!level_trip)
+	if (trip_level < 0)
 		return 0;
 
-	trip_level = thermal_zone_trip_id(tz, level_trip);
-
-	trace_thermal_zone_trip(tz, trip_level, level_trip->type);
+	trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip),
+				level_trip->type);
 
 	return trip_level;
 }




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ