Skip to contentSkip to conversation

thermal/core: Make the userspace governor deprecated

PATCH Superseded Daniel Lezcano 2 participants 7 messages Oct 19, 2021 Thermal

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 thermal/core: Make the userspace governor deprecated

The userspace governor is sending temperature when polling is active and trip point crossed events. Nothing else.

AFAICT, this governor is used with custom kernels making the userspace governor co-existing with another governor on the same thermal zone because there was no notification mechanism, implying a hack in the framework to support this configuration.

The new netlink thermal notification is able to provide more information than the userspace governor and give the opportunity to the users of this governor to replace it by a dedicated notification framework.

The userspace governor will be removed as its usage is no longer needed.

Add a warning message to tell the userspace governor is deprecated.

---
 drivers/thermal/gov_user_space.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/thermal/gov_user_space.c +9 -0
index 82a7198bbe71..f4fe050e1cbc 100644
@@ -15,6 +15,14 @@
 
 #include "thermal_core.h"
 
+static int user_space_bind(struct thermal_zone_device *tz)
+{
+	pr_warn("Userspace governor deprecated: use thermal netlink "	\
+		"notification instead\n");
+
+	return 0;
+}
+
 /**
  * notify_user_space - Notifies user space about thermal events
  * @tz: thermal_zone_device
@@ -43,5 +51,6 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
 static struct thermal_governor thermal_gov_user_space = {
 	.name		= "user_space",
 	.throttle	= notify_user_space,
+	.bind_to_tz	= user_space_bind,
 };
 THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/2 thermal/core: Make deprecated cooling device state change from userspace

The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it.

The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision.

We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power.

The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous.

The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos.

As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future.

Emit a warning and deprecate the interface.

---
 drivers/thermal/thermal_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/thermal/thermal_sysfs.c +2 -0
index 1c4aac8464a7..730f1361dbef 100644
@@ -610,6 +610,8 @@ cur_state_store(struct device *dev, struct device_attribute *attr,
 	unsigned long state;
 	int result;
 
+	pr_warn_once("Setting cooling device state is deprecated\n");
+	
 	if (sscanf(buf, "%ld\n", &state) != 1)
 		return -EINVAL;
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v2 2/2] thermal/core: Make deprecated cooling device state change from userspace

Quoted 36 lines · Daniel Lezcano

The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it.

The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision.

We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power.

The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous.

The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos.

As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future.

Emit a warning and deprecate the interface.

---
 drivers/thermal/thermal_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/thermal/thermal_sysfs.c +0 -0
index 1c4aac8464a7..730f1361dbef 100644

drivers/thermal/thermal_sysfs.c cur_state_store(struct device *dev, struct device_attribute *attr, · line 613

Quoted 4 lines
drivers/thermal/thermal_sysfs.c +1 -0
@@ -610,6 +610,8 @@ cur_state_store(struct device *dev, struct device_attribute *attr,
        unsigned long state;
        int result;
 
+       pr_warn_once("Setting cooling device state is deprecated\n");

Maybe dev_warn_once() even? I guess it won\t hurt to print it once per the affected device?

Quoted 5 lines
drivers/thermal/thermal_sysfs.c +1 -1
+
        if (sscanf(buf, "%ld\n", &state) != 1)
                return -EINVAL;
 
--
#3 lore raw

Re: [PATCH v2 2/2] thermal/core: Make deprecated cooling device state change from userspace

Quoted 42 lines · Rafael J. Wysocki
Quoted 39 lines · Daniel Lezcano

The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it.

The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision.

We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power.

The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous.

The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos.

As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future.

Emit a warning and deprecate the interface.

---
 drivers/thermal/thermal_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/thermal/thermal_sysfs.c +0 -0
index 1c4aac8464a7..730f1361dbef 100644
@@ -610,6 +610,8 @@ cur_state_store(struct device *dev, struct device_attribute *attr,
        unsigned long state;
        int result;
 
Quoted 10 lines

drivers/thermal/thermal_sysfs.c cur_state_store(struct device *dev, struct device_attribute *attr, · line 613

Quoted 1 line
drivers/thermal/thermal_sysfs.c +1 -0
+       pr_warn_once("Setting cooling device state is deprecated\n");

Maybe dev_warn_once() even? I guess it won\t hurt to print it once per the affected device?

Quoted 5 lines
drivers/thermal/thermal_sysfs.c +1 -1
+
        if (sscanf(buf, "%ld\n", &state) != 1)
                return -EINVAL;
 
--

Also I think that changing the subject to something like "Deprecate changing cooling device state from userspace" would help.

#4 lore raw

Re: [PATCH v2 2/2] thermal/core: Make deprecated cooling device state change from userspace

Quoted 43 lines · Rafael J. Wysocki
Quoted 41 lines · Rafael J. Wysocki
Quoted 38 lines · Daniel Lezcano

The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it.

The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision.

We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power.

The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous.

The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos.

As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future.

Emit a warning and deprecate the interface.

drivers/thermal/thermal_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)

(quoted diff) +0 -0

b/drivers/thermal/thermal_sysfs.c index 1c4aac8464a7..730f1361dbef 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -610,6 +610,8 @@ cur_state_store(struct device *dev, struct device_attribute *attr, unsigned long state; int result;

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

+ pr_warn_once("Setting cooling device state is
deprecated\n");

Maybe dev_warn_once() even? I guess it won\t hurt to print it once per the affected device?

Actually, there is no difference except it will be prefixed by the device name.

As the static variable to write once the message is local to the function, not the dev, the warning will appear only once even if we use dev, or cdev->device.

The other calls in the file are pr_warn. I suggest to stay consistent in this case. Is that fine ?

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

+ if (sscanf(buf, "%ld\n", &state) != 1) return -EINVAL;

--

Also I think that changing the subject to something like "Deprecate changing cooling device state from userspace" would help.

Ok

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#5 lore raw

Re: [PATCH v2 2/2] thermal/core: Make deprecated cooling device state change from userspace

Quoted 54 lines · Daniel Lezcano
Quoted 43 lines · Rafael J. Wysocki
Quoted 41 lines · Rafael J. Wysocki
Quoted 38 lines · Daniel Lezcano

The cooling devices have their cooling device set_cur_state read-writable all the time in the sysfs directory, thus allowing the userspace to act on it.

The thermal framework is wrongly used by userspace as a power capping framework by acting on the cooling device opaque state. This one then competes with the in-kernel governor decision.

We have seen in out-of-tree kernels, a big number of devices which are abusely declaring themselves as cooling device just to act on their power.

The role of the thermal framework is to protect the junction temperature of the silicon. Letting the userspace to play with a cooling device is invalid and potentially dangerous.

The powercap framework is the right framework to do power capping and moreover it deals with the aggregation via the dev pm qos.

As the userspace governor is marked deprecated and about to be removed, there is no point to keep this file writable also in the future.

Emit a warning and deprecate the interface.

drivers/thermal/thermal_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)

(quoted diff) +0 -0

b/drivers/thermal/thermal_sysfs.c index 1c4aac8464a7..730f1361dbef 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -610,6 +610,8 @@ cur_state_store(struct device *dev, struct device_attribute *attr, unsigned long state; int result;

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

+ pr_warn_once("Setting cooling device state is
deprecated\n");

Maybe dev_warn_once() even? I guess it won\t hurt to print it once per the affected device?

Actually, there is no difference except it will be prefixed by the device name.

Quoted 6 lines

As the static variable to write once the message is local to the function, not the dev, the warning will appear only once even if we use dev, or cdev->device.

The other calls in the file are pr_warn. I suggest to stay consistent in this case. Is that fine ?

It is, except that it may not be straightforward to connect the message to the specific device in question.

maintainer Acked-by on v2 1/2
#6 lore raw
In reply to Daniel Lezcano
Quoted 14 lines · Daniel Lezcano

The userspace governor is sending temperature when polling is active and trip point crossed events. Nothing else.

AFAICT, this governor is used with custom kernels making the userspace governor co-existing with another governor on the same thermal zone because there was no notification mechanism, implying a hack in the framework to support this configuration.

The new netlink thermal notification is able to provide more information than the userspace governor and give the opportunity to the users of this governor to replace it by a dedicated notification framework.

Quoted 6 lines

The userspace governor will be removed as its usage is no longer needed.

Add a warning message to tell the userspace governor is deprecated.

Quoted 33 lines
---
 drivers/thermal/gov_user_space.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/thermal/gov_user_space.c +9 -1
index 82a7198bbe71..f4fe050e1cbc 100644
@@ -15,6 +15,14 @@
 
 #include "thermal_core.h"
 
+static int user_space_bind(struct thermal_zone_device *tz)
+{
+       pr_warn("Userspace governor deprecated: use thermal netlink "   \
+               "notification instead\n");
+
+       return 0;
+}
+
 /**
  * notify_user_space - Notifies user space about thermal events
  * @tz: thermal_zone_device
@@ -43,5 +51,6 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
 static struct thermal_governor thermal_gov_user_space = {
        .name           = "user_space",
        .throttle       = notify_user_space,
+       .bind_to_tz     = user_space_bind,
 };
 THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);
--

2.25.1