2024-04-02 19:05:05

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH v3 6/6] thermal: core: Relocate critical and hot trip handling

From: Rafael J. Wysocki <[email protected]>

Modify handle_thermal_trip() to call handle_critical_trips() only after
finding that the trip temperature has been crossed on the way up and
remove the redundant temperature check from the latter.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/thermal/thermal_core.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -349,10 +349,6 @@ void thermal_zone_device_critical_reboot
static void handle_critical_trips(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{
- /* If we have not crossed the trip_temp, we do not care. */
- if (trip->temperature <= 0 || tz->temperature < trip->temperature)
- return;
-
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);

if (trip->type == THERMAL_TRIP_CRITICAL)
@@ -404,12 +400,15 @@ static void handle_thermal_trip(struct t
list_add_tail(&td->notify_list_node, way_up_list);
td->notify_temp = trip->temperature;
td->threshold -= trip->hysteresis;
+
+ if (trip->type == THERMAL_TRIP_CRITICAL ||
+ trip->type == THERMAL_TRIP_HOT) {
+ handle_critical_trips(tz, trip);
+ return;
+ }
}

- if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
- handle_critical_trips(tz, trip);
- else
- handle_non_critical_trips(tz, trip);
+ handle_non_critical_trips(tz, trip);
}

static void update_temperature(struct thermal_zone_device *tz)





2024-04-04 09:03:52

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] thermal: core: Relocate critical and hot trip handling

On Tue, Apr 2, 2024 at 9:04 PM Rafael J. Wysocki <[email protected]> wrote:
>
> From: Rafael J. Wysocki <[email protected]>
>
> Modify handle_thermal_trip() to call handle_critical_trips() only after
> finding that the trip temperature has been crossed on the way up and
> remove the redundant temperature check from the latter.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

This change is premature, as it will cause handle_non_critical_trips()
to be called for hot/critical trips which is questionable, so I'm
withdrawing it for now.

The rest of the series is still applicable, though.


> ---
> drivers/thermal/thermal_core.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -349,10 +349,6 @@ void thermal_zone_device_critical_reboot
> static void handle_critical_trips(struct thermal_zone_device *tz,
> const struct thermal_trip *trip)
> {
> - /* If we have not crossed the trip_temp, we do not care. */
> - if (trip->temperature <= 0 || tz->temperature < trip->temperature)
> - return;
> -
> trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
>
> if (trip->type == THERMAL_TRIP_CRITICAL)
> @@ -404,12 +400,15 @@ static void handle_thermal_trip(struct t
> list_add_tail(&td->notify_list_node, way_up_list);
> td->notify_temp = trip->temperature;
> td->threshold -= trip->hysteresis;
> +
> + if (trip->type == THERMAL_TRIP_CRITICAL ||
> + trip->type == THERMAL_TRIP_HOT) {
> + handle_critical_trips(tz, trip);
> + return;
> + }
> }
>
> - if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT)
> - handle_critical_trips(tz, trip);
> - else
> - handle_non_critical_trips(tz, trip);
> + handle_non_critical_trips(tz, trip);
> }
>
> static void update_temperature(struct thermal_zone_device *tz)
>
>
>
>

2024-04-05 07:36:02

by Lukasz Luba

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] thermal: core: Relocate critical and hot trip handling

Hi Rafael,

On 4/4/24 10:03, Rafael J. Wysocki wrote:
> On Tue, Apr 2, 2024 at 9:04 PM Rafael J. Wysocki <[email protected]> wrote:
>>
>> From: Rafael J. Wysocki <[email protected]>
>>
>> Modify handle_thermal_trip() to call handle_critical_trips() only after
>> finding that the trip temperature has been crossed on the way up and
>> remove the redundant temperature check from the latter.
>>
>> Signed-off-by: Rafael J. Wysocki <[email protected]>
>
> This change is premature, as it will cause handle_non_critical_trips()
> to be called for hot/critical trips which is questionable, so I'm
> withdrawing it for now.
>
> The rest of the series is still applicable, though.
>
>

Could you explain your concerns about this, please?
Is about the extra execution time for the non-critical trip,
while we are in section of handling critical ASAP?
(also it would require that extra sorting there IMO)

Regards,
Lukasz

2024-04-10 15:59:41

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] thermal: core: Relocate critical and hot trip handling

Hi Lukasz,

On Fri, Apr 5, 2024 at 9:35 AM Lukasz Luba <[email protected]> wrote:
>
> Hi Rafael,
>
> On 4/4/24 10:03, Rafael J. Wysocki wrote:
> > On Tue, Apr 2, 2024 at 9:04 PM Rafael J. Wysocki <rjw@rjwysockinet> wrote:
> >>
> >> From: Rafael J. Wysocki <[email protected]>
> >>
> >> Modify handle_thermal_trip() to call handle_critical_trips() only after
> >> finding that the trip temperature has been crossed on the way up and
> >> remove the redundant temperature check from the latter.
> >>
> >> Signed-off-by: Rafael J. Wysocki <[email protected]>
> >
> > This change is premature, as it will cause handle_non_critical_trips()
> > to be called for hot/critical trips which is questionable, so I'm
> > withdrawing it for now.
> >
> > The rest of the series is still applicable, though.
> >
> >
>
> Could you explain your concerns about this, please?
> Is about the extra execution time for the non-critical trip,
> while we are in section of handling critical ASAP?
> (also it would require that extra sorting there IMO)

No, it is mostly about exposing the critical and hot trips to the
governor code that may not be ready for seeing them and get somewhat
surprised. In particular, this would cause the User Space governor to
send uevents regarding critical and hot trip points which it has not
been doing so far and so user space may get confused.

2024-04-11 06:45:15

by Lukasz Luba

[permalink] [raw]
Subject: Re: [PATCH v3 6/6] thermal: core: Relocate critical and hot trip handling



On 4/10/24 16:56, Rafael J. Wysocki wrote:
> Hi Lukasz,
>
> On Fri, Apr 5, 2024 at 9:35 AM Lukasz Luba <[email protected]> wrote:
>>
>> Hi Rafael,
>>
>> On 4/4/24 10:03, Rafael J. Wysocki wrote:
>>> On Tue, Apr 2, 2024 at 9:04 PM Rafael J. Wysocki <[email protected]> wrote:
>>>>
>>>> From: Rafael J. Wysocki <[email protected]>
>>>>
>>>> Modify handle_thermal_trip() to call handle_critical_trips() only after
>>>> finding that the trip temperature has been crossed on the way up and
>>>> remove the redundant temperature check from the latter.
>>>>
>>>> Signed-off-by: Rafael J. Wysocki <[email protected]>
>>>
>>> This change is premature, as it will cause handle_non_critical_trips()
>>> to be called for hot/critical trips which is questionable, so I'm
>>> withdrawing it for now.
>>>
>>> The rest of the series is still applicable, though.
>>>
>>>
>>
>> Could you explain your concerns about this, please?
>> Is about the extra execution time for the non-critical trip,
>> while we are in section of handling critical ASAP?
>> (also it would require that extra sorting there IMO)
>
> No, it is mostly about exposing the critical and hot trips to the
> governor code that may not be ready for seeing them and get somewhat
> surprised. In particular, this would cause the User Space governor to
> send uevents regarding critical and hot trip points which it has not
> been doing so far and so user space may get confused.

Got it, thanks!