Skip to content

Commit

Permalink
thermal/debugfs: Avoid excessive updates of trip point statistics
Browse files Browse the repository at this point in the history
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 <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
  • Loading branch information
Rafael J. Wysocki committed Apr 24, 2024
1 parent 2ae0998 commit 0a293c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion drivers/thermal/thermal_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ static void update_temperature(struct thermal_zone_device *tz)
trace_thermal_temperature(tz);

thermal_genl_sampling_temp(tz->id, temp);
thermal_debug_update_temp(tz);
}

static void thermal_zone_device_check(struct work_struct *work)
Expand Down Expand Up @@ -505,6 +504,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
if (governor->manage)
governor->manage(tz);

thermal_debug_update_temp(tz);

monitor_thermal_zone(tz);
}

Expand Down
7 changes: 0 additions & 7 deletions drivers/thermal/thermal_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
struct tz_episode *tze;
struct tz_debugfs *tz_dbg;
struct thermal_debugfs *thermal_dbg = tz->debugfs;
int temperature = tz->temperature;
int trip_id = thermal_zone_trip_id(tz, trip);
ktime_t now = ktime_get();

Expand Down Expand Up @@ -614,12 +613,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,

tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
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;

unlock:
mutex_unlock(&thermal_dbg->lock);
Expand Down

0 comments on commit 0a293c7

Please sign in to comment.