lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0h3m5LTFW=xn79bcAve3rzNoNCaaub6OFQLQ8YMV_tZ5w@mail.gmail.com>
Date: Wed, 3 Jul 2024 13:20:10 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Rob Herring <robh@...nel.org>, linux-pm@...r.kernel.org, 
	Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" <devicetree@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] thermal/core: Introduce user trip points

On Wed, Jul 3, 2024 at 12:49 AM Daniel Lezcano
<daniel.lezcano@...aro.org> wrote:
>
> On 02/07/2024 19:15, Rafael J. Wysocki wrote:
> > On Tue, Jul 2, 2024 at 6:31 PM Daniel Lezcano <daniel.lezcano@...aro.org> wrote:
> >>
> >> On 02/07/2024 13:03, Rafael J. Wysocki wrote:
> >>
> >> [ ... ]
> >>
> >>>>> Trips cannot be created on the fly ATM.
> >>>>>
> >>>>> What can be done is to create trips that are invalid to start with and
> >>>>> then set their temperature via sysfs.  This has been done already for
> >>>>> quite a while AFAICS.
> >>>>
> >>>> Yes, I remember that.
> >>>>
> >>>> I would like to avoid introducing more weirdness in the thermal
> >>>> framework which deserve a clear ABI.
> >>>>
> >>>> What is missing to create new trip points on the fly ?
> >>>
> >>> A different data structure to store them (essentially, a list instead
> >>> of an array).
> >>>
> >>> I doubt it's worth the hassle.
> >>>
> >>> What's wrong with the current approach mentioned above?  It will need
> >>> to be supported going forward anyway.
> >>
> >> So when the "user trip point" option will be set, a thermal zone will
> >> have ~ten(?) user trip points initialized to an invalid temperature ?
> >
> > If a thermal zone is registered with 10 invalid trip points, htat can
> > happen already today.
>
> IINW, this is the case for a particular driver (int340x_thermal_zone?),
> may be for a thermal zone. But in the general case where we can have
> more the 50 thermal zones it is not adequate as we will end up with more
> than 500 trip points overall.
>
> Assuming it is the int340x_thermal_zone driver, it is active trip
> points, so that assumes the associated cooling device will be active.
> TBH, it is fuzzy regarding a notification mechanism

The trip points that are invalid to start with are passive IIRC, but
the point I wanted to make was that the number of trip points, their
type and whether or not they were invalid to start with depended on
the driver registering a thermal zone.  Drivers put whatever they like
into the trips table today.

> > Let's talk about the usage model, though.
>
> Sure
>
> > IIUC, this would be something like "triggers" I mentioned before: If a
> > certain temperature level is reached, a notification is sent to user
> > space, and there are multiple (possibly many) levels like this.  They
> > can be added and deleted at any time.
>
> Yes, except I don't think the usage will be to often creating trip
> points. More likely, depending on the kind of sensors and the associated
> logic, a number of trip points will created for a specific profile and
> then modified on the fly.

So I gather that you'd like the initial set to come from DT.

> > There can be an interface for this, as simple as a pair of sysfs
> > attributes under a thermal zone: add_trigger and remove_trigger.  If
> > root (or equivalent) writes a (valid) temperature value to
> > add_trigger, a new trigger is added (up to a limit and provided that
> > enough memory can be allocated).  Conversely, if a temperature value
> > is written to remove_trigger and there is a trigger with that
> > temperature, it will be deleted.
>
> A hysteresis would be needed too. IMO, netlinks are more adequate for
> this purpose.

That depends.

One way to implement hysteresis is to add a new trigger when an
existing one is crossed, either below (on the way up) or above (on the
way down) it, and remove it.  Then you don't need an additional
hysteresis value.

> > Internally, the triggers can be stored in a sorted list (with some
> > optimizations, so it need not be walked every time the zone
> > temperature changes) or a tree, independent of the trips table (if
> > any).  Every time the zone temperature changes, the triggers list is
> > consulted (in addition to the trips table) and if any of them have
> > been crossed, notifications are sent to user space.
>
> So basically, thermal_zone_device_update() will browse two lists,
> triggers + trip points, right ?

Right.

> > If polling is used, this would just work, but without polling the
> > driver needs to support setting a pair (at least) of temperature
> > levels causing an interrupt to occur.
>
> I'm missing this point, can you elaborate ?

Polling guarantees that __thermal_zone_device_update() will be
executed periodically and so it guarantees detection of crossing trip
points (or trigger temperature levels).

If there is no polling, interrupts (or equivalent) need to be used to
invoke __thermal_zone_device_update() when trips are crossed.
Basically, if any of them is crossed, you need an interrupt.

Usually, however, hardware supports a limited number of temperature
levels that can trigger interrupts and I wanted to make the point that
it was sufficient for it to support two of them for the usage model in
question.

> > If a specific callback, say
> > .set_triggers(), is provided by the driver, it can be used for setting
> > those temperature levels to the triggers right above and right below
> > the current zone temperature, in analogy with .set_trips().
> >
> > Does this reflect what you are after?
>
> At the first glance I would say yes, but I don't get why it is more
> complicate to just add 'triggers' with the trip points (formerly 'user'
> trip points)

The most problematic part is the requirement to be able to add and
remove "triggers" on the fly from user space.  This requires two
things: (a) a user space interface for that and (b) a data structure
suitable for adding and removing entries (ideally, a sorted one).
None of these things exist for trip points today and the trip points
in use today don't require any of them either.  Adding more complexity
to the already complex trip point implementation doesn't look
particularly attractive to me.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ