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]
Date:   Thu, 21 Sep 2023 19:54:02 +0200
From:   "Rafael J. Wysocki" <rjw@...ysocki.net>
To:     Linux PM <linux-pm@...r.kernel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Linux ACPI <linux-acpi@...r.kernel.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Lukasz Luba <lukasz.luba@....com>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Subject: [PATCH v1 06/13] thermal: gov_fair_share: Rearrange get_trip_level()

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

Make get_trip_level() access the thermal zone's trip table directly
instead of using __thermal_zone_get_trip() which adds overhead related
to the unnecessary bounds checking and copying the trip point data.

Also rearrange the code in it to make it somewhat easier to follow.

The general functionality is not expected to be changed.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
---
 drivers/thermal/gov_fair_share.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 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
@@ -21,23 +21,21 @@
  */
 static int get_trip_level(struct thermal_zone_device *tz)
 {
-	struct thermal_trip trip;
-	int count;
+	const struct thermal_trip *trip = tz->trips;
+	int i;
 
-	for (count = 0; count < tz->num_trips; count++) {
-		__thermal_zone_get_trip(tz, count, &trip);
-		if (tz->temperature < trip.temperature)
+	if (tz->temperature < trip->temperature)
+		return 0;
+
+	for (i = 0; i < tz->num_trips - 1; i++) {
+		trip++;
+		if (tz->temperature < trip->temperature)
 			break;
 	}
 
-	/*
-	 * count > 0 only if temperature is greater than first trip
-	 * point, in which case, trip_point = count - 1
-	 */
-	if (count > 0)
-		trace_thermal_zone_trip(tz, count - 1, trip.type);
+	trace_thermal_zone_trip(tz, i, tz->trips[i].type);
 
-	return count;
+	return i;
 }
 
 static long get_target_state(struct thermal_zone_device *tz,



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ