History

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

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.

Rafael J. Wysocki committed 2 years ago

Commit b552f631 parent 0bbac3f1 file · +1 −0Browse files

Unified · Split

drivers/thermal/thermal_debugfs.c+1−0
@@ -616,6 +616,7 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, · 615 unmodified lines
616 tze->trip_stats[trip_id].timestamp = now;616 tze->trip_stats[trip_id].timestamp = now;
617 tze->trip_stats[trip_id].max = max(tze->trip_stats[trip_id].max, temperature);617 tze->trip_stats[trip_id].max = max(tze->trip_stats[trip_id].max, temperature);
618 tze->trip_stats[trip_id].min = min(tze->trip_stats[trip_id].min, temperature);618 tze->trip_stats[trip_id].min = min(tze->trip_stats[trip_id].min, temperature);
619 tze->trip_stats[trip_id].count++;
619 tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg +620 tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg +
620 (temperature - tze->trip_stats[trip_id].avg) /621 (temperature - tze->trip_stats[trip_id].avg) /
621 tze->trip_stats[trip_id].count;622 tze->trip_stats[trip_id].count;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t