Patch "thermal/debugfs: Add missing count increment to thermal_debug_tz_trip_up()" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    thermal/debugfs: Add missing count increment to thermal_debug_tz_trip_up()

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     thermal-debugfs-add-missing-count-increment-to-therm.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b4d6a5351c3d1c2c9db5a3d2a52c4f1204c598f9
Author: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Date:   Mon Apr 15 21:02:12 2024 +0200

    thermal/debugfs: Add missing count increment to thermal_debug_tz_trip_up()
    
    [ Upstream commit b552f63cd43735048bbe9bfbb7a9dcfce166fbdd ]
    
    The count field in struct trip_stats, representing the number of times
    the zone temperature was above the trip point, needs to be incremented
    in thermal_debug_tz_trip_up(), for two reasons.
    
    First, if a trip point is crossed on the way up for the first time,
    thermal_debug_update_temp() called from update_temperature() does
    not see it because it has not been added to trips_crossed[] array
    in the thermal zone's struct tz_debugfs object yet.  Therefore, when
    thermal_debug_tz_trip_up() is called after that, the trip point's
    count value is 0, and the attempt to divide by it during the average
    temperature computation leads to a divide error which causes the kernel
    to crash.  Setting the count to 1 before the division by incrementing it
    fixes this problem.
    
    Second, if a trip point is crossed on the way up, but it has been
    crossed on the way up already before, its count value needs to be
    incremented to make a record of the fact that the zone temperature is
    above the trip now.  Without doing that, if the mitigations applied
    after crossing the trip cause the zone temperature to drop below its
    threshold, the count will not be updated for this episode at all and
    the average temperature in the trip statistics record will be somewhat
    higher than it should be.
    
    Fixes: 7ef01f228c9f ("thermal/debugfs: Add thermal debugfs information for mitigation episodes")
    Cc :6.8+ <stable@xxxxxxxxxxxxxxx> # 6.8+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/thermal/thermal_debugfs.c b/drivers/thermal/thermal_debugfs.c
index c617e8b9f0ddf..d78d54ae2605e 100644
--- a/drivers/thermal/thermal_debugfs.c
+++ b/drivers/thermal/thermal_debugfs.c
@@ -616,6 +616,7 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
 	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;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux