Skip to content

Commit 0a293c7

Browse files
committed
thermal/debugfs: Avoid excessive updates of trip point statistics
Since thermal_debug_update_temp() is called before invoking thermal_debug_tz_trip_down() for the trips that were crossed by the zone temperature on the way up, it updates the statistics for them as though the current zone temperature was above the low temperature of each of them. However, if a given trip has just been crossed on the way down, the zone temperature is in fact below its low temperature, but this is handled by thermal_debug_tz_trip_down() running after the update of the trip statistics. The remedy is to call thermal_debug_update_temp() after thermal_debug_tz_trip_down() has been invoked for all of the trips in question, but then thermal_debug_tz_trip_up() needs to be adjusted, so it does not update the statistics for the trips that has just been crossed on the way up, as that will be taken care of by thermal_debug_update_temp() down the road. Modify the code accordingly. Fixes: 7ef01f2 ("thermal/debugfs: Add thermal debugfs information for mitigation episodes") Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 2ae0998 commit 0a293c7

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

drivers/thermal/thermal_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ static void update_temperature(struct thermal_zone_device *tz)
427427
trace_thermal_temperature(tz);
428428

429429
thermal_genl_sampling_temp(tz->id, temp);
430-
thermal_debug_update_temp(tz);
431430
}
432431

433432
static void thermal_zone_device_check(struct work_struct *work)
@@ -505,6 +504,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
505504
if (governor->manage)
506505
governor->manage(tz);
507506

507+
thermal_debug_update_temp(tz);
508+
508509
monitor_thermal_zone(tz);
509510
}
510511

drivers/thermal/thermal_debugfs.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
545545
struct tz_episode *tze;
546546
struct tz_debugfs *tz_dbg;
547547
struct thermal_debugfs *thermal_dbg = tz->debugfs;
548-
int temperature = tz->temperature;
549548
int trip_id = thermal_zone_trip_id(tz, trip);
550549
ktime_t now = ktime_get();
551550

@@ -614,12 +613,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
614613

615614
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
616615
tze->trip_stats[trip_id].timestamp = now;
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);
619-
tze->trip_stats[trip_id].count++;
620-
tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg +
621-
(temperature - tze->trip_stats[trip_id].avg) /
622-
tze->trip_stats[trip_id].count;
623616

624617
unlock:
625618
mutex_unlock(&thermal_dbg->lock);

0 commit comments

Comments
 (0)