linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Thermal notifications without setting thermal governor to userspace?
@ 2022-03-30 15:45 Chris Down
  2022-03-30 18:08 ` Daniel Lezcano
  2022-03-30 22:24 ` Daniel Lezcano
  0 siblings, 2 replies; 9+ messages in thread
From: Chris Down @ 2022-03-30 15:45 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	Guenter Roeck

Hey thermal folks,

I'm hoping that you'll be able to provide some guidance on what options are 
available for getting thermal notifications without changing the policy to 
userspace control.

To be clear, my intent is to have a userspace daemon which can set multiple 
temperature trips at runtime on which it can receive a notification (preferably 
by a simple mechanism like uevents), and to be able to distinguish which 
threshold was tripped. For example, to be able to set trips at 50C, 70C, and 
90C, getting events both when the temperature exceeds that and when it dips 
back under the specified threshold.

Right now I am polling /sys/class/thermal/thermal_zone*/temp but this can be 
expensive, especially for the ACPI thermal zone.

As it is, I see four options:

1. Set thermal_zone to use user_space governor and use uevents

As I understand it, this means that the default critical temperature will no 
longer be respected and user space is now responsible for taking action to 
control thermal events.

If that's correct, then it seems dangerous to set it to user_space for 
userspace applications which only want to monitor their own trip temperatures, 
but not take direct action.

2. Use hwmon thermal events

I see that commit 1597b374af22 ("hwmon: Add notification support") adds 
notification support to hwmon, but as far as I can tell this is based on 
statically defined trip temperatures from ACPI or similar inputs. I see you can 
change it with the thermal.crt boot option, but that's too early for a normal 
userspace daemon to do anything (and it doesn't allow any dynamic 
reconfiguration).

3. Use thermal over netlink

I see that commit 1ce50e7d408e ("thermal: core: genetlink support for 
events/cmd/sampling") which was merged a couple of years ago adds support for 
thermal netlink events.

I also see articles suggesting that support for this new netlink interface will 
be or was added to libnl, but I can't seem to find anything about it in the 
libnl sources.

Is this mature enough to use? If so, does one have to hack up their own 
userspace netlink library for now, or what's the plan there?

In general I would prefer something simpler that fits into the existing strong 
tooling around uevents/etc though, this looks useful, but it does a lot more 
than I need and requires adding another userspace dependency on libnl.

4. Poll /sys/class/thermal/thermal_zone*/temp or hwmon

This is what I'm currently doing. It's slow, and often unnecessarily costly on 
weaker systems.

Are there other options I'm not considering here that might help me out here?

Thanks,

Chris

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-04-04 21:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-30 15:45 Thermal notifications without setting thermal governor to userspace? Chris Down
2022-03-30 18:08 ` Daniel Lezcano
2022-03-30 18:11   ` Chris Down
2022-03-30 22:24 ` Daniel Lezcano
2022-04-04 15:17   ` Chris Down
2022-04-04 16:17     ` Daniel Lezcano
2022-04-04 17:17       ` Chris Down
2022-04-04 20:27         ` Daniel Lezcano
2022-04-04 20:50           ` Chris Down

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).