Skip to contentSkip to conversation

CPU Package temperarure thermal driver (v02)

PATCH In review Srinivas Pandruvada 3 participants 9 messages May 17, 2013 – Jun 13, 2013

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/3 x86, mcheck, therm_throt: Process package thresholds

In reply to Srinivas Pandruvada

Added callback registration for package threshold reports. Also added a callback to check the rate control implemented in callback or not. If there is no rate control implemented, then there is a default rate control similar to core threshold notification by delaying for CHECK_INTERVAL (5 minutes) between reports.

---
 arch/x86/include/asm/mce.h               |  7 ++++
 arch/x86/kernel/cpu/mcheck/therm_throt.c | 63 ++++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 4 deletions(-)
arch/x86/include/asm/mce.h +7 -0
index f4076af..4c619bf 100644
@@ -214,6 +214,13 @@ void mce_log_therm_throt_event(__u64 status);
 /* Interrupt Handler for core thermal thresholds */
 extern int (*platform_thermal_notify)(__u64 msr_val);
 
+/* Interrupt Handler for package thermal thresholds */
+extern int (*platform_thermal_package_notify)(__u64 msr_val);
+
+/* Callback support of rate control, return true, if
+ * callback has rate control */
+extern bool (*platform_thermal_package_rate_control)(void);
+
 #ifdef CONFIG_X86_THERMAL_VECTOR
 extern void mcheck_intel_therm_init(void);
 #else
arch/x86/kernel/cpu/mcheck/therm_throt.c +59 -4

112 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#0 lore raw

cover CPU Package temperarure thermal driver (v02)

This driver register CPU digital temperature package level sensor as a thermal zone with two user mode configurable trip points. Once the trip point is violated, user mode can receive notification via thermal notification mechanism and can take any action to control temperature.

Changes:
v02:
Did majority of changes suggested by Eduardo Valentin. Main changes are:
- Module parameters for rate control delay
- Removed user space gov parameter in thermal_zone_register
- Changes related to returning of errors values
- Error code return values

v01:
First version for review

Background:
This set of changes were done to coretemp driver and posted to lm_sensors mailing list on 04/04/2013. This was reviewed by Guenter Roeck from lm-sensors and Zhang Rui (thermal maintainer). They were in agreement not to add notification mechanism to coretemp driver but use thermal sysfs.
Guenter Roeck suggested to use approach like "db8500_thermal driver in drivers/thermal". So resubmitting the driver as a thermal zone driver.
Previous discussion link:
http://comments.gmane.org/gmane.linux.drivers.sensors/32182
"
This is clear that there is reluctance in adding thresholds in coretemp sysfs, during previous attempts. Probably because of lake of use cases.
But this time use case may be more compelling.

We have many small form factor devices like ultrabooks, slate PCs in the market. Unfortunately these devices reach maximum temperature with relatively less workloads, causing BIOS to do thermal throttling. There are real performance issues due to aggressive BIOS action to control thermals and also thermal breakdown in some cases.

Even the most expensive laptops, don't have correct ACPI thermal configuration, so that kernel thermal driver can act. In some case even the trip point is higher than critical temperature setting.

Intel has developed several drivers, which can be used to cool the system very efficiently. They include RAPL based cooling driver, Powerclamp driver and P state driver. To utilize these cooling device a closed loop user mode program is required, which will utilize these method and dynamically compensate for high CPU temperatures, without relying on any configuration data.
One such solution is developed is "Linux thermal daemon". More details can be obtained from "https://github.com/01org/thermal_daemon/blob/master/ThermalDaemon_Introduction.pdf". This daemon polls for cpu temperature and apply compensation once the CPU reach target temperature.

This polling can be mostly avoided, by getting notification for the temperature, where it needs to wake up and get ready for apply compensation. In most of the normal use cases, there may not be any threshold events. So very minimal number of user space notification for thermal thresholds.

Srinivas Pandruvada (3):
x86, mcheck, therm_throt: Process package thresholds
Thermal: CPU Package temperature thermal
Thermal: Documentation for x86 package temperature thermal driver

 Documentation/thermal/x86_pkg_temperature_thermal |  47 ++
 arch/x86/include/asm/mce.h                        |   7 +
 arch/x86/kernel/cpu/mcheck/therm_throt.c          |  63 ++-
 drivers/thermal/Kconfig                           |  12 +
 drivers/thermal/Makefile                          |   2 +-
 drivers/thermal/x86_pkg_temp_thermal.c            | 642 ++++++++++++++++++++++
 6 files changed, 768 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/thermal/x86_pkg_temperature_thermal
 create mode 100644 drivers/thermal/x86_pkg_temp_thermal.c
Signature · 1 line
1.7.11.7
#3 lore raw

PATCH 3/3 Thermal: Documentation for x86 package temperature thermal driver

Added documentation describing details of the x86 package temperature thermal driver.

---
 Documentation/thermal/x86_pkg_temperature_thermal | 47 +++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/thermal/x86_pkg_temperature_thermal
Documentation/thermal/x86_pkg_temperature_thermal new file +47 -0
new file mode 100644
index 0000000..17a3a4c
@@ -0,0 +1,47 @@
+Kernel driver: x86_pkg_temp_thermal
+===================
+
+Supported chips:
+* x86: with package level thermal management
+(Verify using: CPUID.06H:EAX[bit 6] =1)
+
+Authors: Srinivas Pandruvada <[email protected]>
+
+Reference
+---
+Intel® 64 and IA-32 Architectures Software Developer’s Manual (Jan, 2013):
+Chapter 14.6: PACKAGE LEVEL THERMAL MANAGEMENT
+
+Description
+---------
+
+This driver register CPU digital temperature package level sensor as a thermal
+zone with maximum two user mode configurable trip points. Number of trip points
+depends on the capability of the package. Once the trip point is violated,
+user mode can receive notification via thermal notification mechanism and can
+take any action to control temperature.
+
+
+Threshold management
+--------------------
+Each package will register as a thermal zone under /sys/class/thermal.
+Example:
+/sys/class/thermal/thermal_zone1
+
+This contains two trip points:
+- trip_point_0_temp
+- trip_point_1_temp
+
+User can set any temperature between 0 to TJ-Max temperature. Temperature units
+are in milli-degree Celsius. Refer to "Documentation/thermal/sysfs-api.txt" for
+thermal sys-fs details.
+
+Any value other than 0 in these trip points, can trigger thermal notifications.
+Setting 0, stops sending thermal notifications.
+
+Thermal notifications: To get kobject-uevent notifications, set the thermal zone
+policy to "user_space". For example: echo -n "user_space" > policy
+
+
+
+
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH 2/3 Thermal: CPU Package temperature thermal

In reply to Srinivas Pandruvada

This driver register CPU digital temperature sensor as a thermal zone at package level.
Each package will show up as one zone with at max two trip points. These trip points can be both read and updated. Once a non zero value is set in the trip point, if the package package temperature goes above or below this setting, a thermal notification is generated.

---
 drivers/thermal/Kconfig                |  12 +
 drivers/thermal/Makefile               |   2 +-
 drivers/thermal/x86_pkg_temp_thermal.c | 642 +++++++++++++++++++++++++++++++++
 3 files changed, 655 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/x86_pkg_temp_thermal.c
drivers/thermal/Kconfig +12 -0
index a764f16..ed9b983 100644
@@ -165,4 +165,16 @@ config INTEL_POWERCLAMP
 	  enforce idle time which results in more package C-state residency. The
 	  user interface is exposed via generic thermal framework.
 
+config X86_PKG_TEMP_THERMAL
+	tristate "X86 package temperature thermal driver"
+	depends on THERMAL
+	depends on X86
+	select THERMAL_GOV_USER_SPACE
+	default m
+	help
+	  Enable this to register CPU digital sensor for package temperature as
+	  thermal zone. Each package will have its own thermal zone. There are
+	  two trip points which can be set by user to get notifications via thermal
+	  notification methods.
+
 endif
drivers/thermal/Makefile +1 -1
index d3a2b38..fd137ce 100644
@@ -21,4 +21,4 @@ obj-$(CONFIG_DOVE_THERMAL)  	+= dove_thermal.o
 obj-$(CONFIG_DB8500_THERMAL)	+= db8500_thermal.o
 obj-$(CONFIG_DB8500_CPUFREQ_COOLING)	+= db8500_cpufreq_cooling.o
 obj-$(CONFIG_INTEL_POWERCLAMP)	+= intel_powerclamp.o
-
+obj-$(CONFIG_X86_PKG_TEMP_THERMAL)	+= x86_pkg_temp_thermal.o
drivers/thermal/x86_pkg_temp_thermal.c new file +642 -0

642 lines not on this page · raw message

Signature · 1 line
1.7.11.7
reviewer
#4 lore raw
In reply to Srinivas Pandruvada
Quoted 5 lines · Srinivas Pandruvada

This driver register CPU digital temperature package level sensor as a thermal zone with two user mode configurable trip points. Once the trip point is violated, user mode can receive notification via thermal notification mechanism and can take any action to control temperature.

I'm okay with this patch set.
But I'm wondering who should take patch 1/3?

thanks,
rui

Quoted 66 lines

Changes:
v02:
Did majority of changes suggested by Eduardo Valentin. Main changes are:
- Module parameters for rate control delay
- Removed user space gov parameter in thermal_zone_register
- Changes related to returning of errors values
- Error code return values

v01:
First version for review

Background:
This set of changes were done to coretemp driver and posted to lm_sensors mailing list on 04/04/2013. This was reviewed by Guenter Roeck from lm-sensors and Zhang Rui (thermal maintainer). They were in agreement not to add notification mechanism to coretemp driver but use thermal sysfs.
Guenter Roeck suggested to use approach like "db8500_thermal driver in drivers/thermal". So resubmitting the driver as a thermal zone driver.
Previous discussion link:
http://comments.gmane.org/gmane.linux.drivers.sensors/32182
"
This is clear that there is reluctance in adding thresholds in coretemp sysfs, during previous attempts. Probably because of lake of use cases.
But this time use case may be more compelling.

We have many small form factor devices like ultrabooks, slate PCs in the market. Unfortunately these devices reach maximum temperature with relatively less workloads, causing BIOS to do thermal throttling. There are real performance issues due to aggressive BIOS action to control thermals and also thermal breakdown in some cases.

Even the most expensive laptops, don't have correct ACPI thermal configuration, so that kernel thermal driver can act. In some case even the trip point is higher than critical temperature setting.

Intel has developed several drivers, which can be used to cool the system very efficiently. They include RAPL based cooling driver, Powerclamp driver and P state driver. To utilize these cooling device a closed loop user mode program is required, which will utilize these method and dynamically compensate for high CPU temperatures, without relying on any configuration data.
One such solution is developed is "Linux thermal daemon". More details can be obtained from "https://github.com/01org/thermal_daemon/blob/master/ThermalDaemon_Introduction.pdf". This daemon polls for cpu temperature and apply compensation once the CPU reach target temperature.

This polling can be mostly avoided, by getting notification for the temperature, where it needs to wake up and get ready for apply compensation. In most of the normal use cases, there may not be any threshold events. So very minimal number of user space notification for thermal thresholds.

Srinivas Pandruvada (3):
x86, mcheck, therm_throt: Process package thresholds
Thermal: CPU Package temperature thermal
Thermal: Documentation for x86 package temperature thermal driver

 Documentation/thermal/x86_pkg_temperature_thermal |  47 ++
 arch/x86/include/asm/mce.h                        |   7 +
 arch/x86/kernel/cpu/mcheck/therm_throt.c          |  63 ++-
 drivers/thermal/Kconfig                           |  12 +
 drivers/thermal/Makefile                          |   2 +-
 drivers/thermal/x86_pkg_temp_thermal.c            | 642 ++++++++++++++++++++++
 6 files changed, 768 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/thermal/x86_pkg_temperature_thermal
 create mode 100644 drivers/thermal/x86_pkg_temp_thermal.c
#5 lore raw

Tony Luck is the maintainer and he did review once and gave comments.

Hi Tony,

Do you have further comments?

Thanks,
Srinivas

Quoted 83 lines · Zhang Rui
Quoted 5 lines · Srinivas Pandruvada

This driver register CPU digital temperature package level sensor as a thermal zone with two user mode configurable trip points. Once the trip point is violated, user mode can receive notification via thermal notification mechanism and can take any action to control temperature.

I'm okay with this patch set.
But I'm wondering who should take patch 1/3?

thanks,
rui

Quoted 63 lines

Changes:
v02:
Did majority of changes suggested by Eduardo Valentin. Main changes are:
- Module parameters for rate control delay
- Removed user space gov parameter in thermal_zone_register
- Changes related to returning of errors values
- Error code return values

v01:
First version for review

Background:
This set of changes were done to coretemp driver and posted to lm_sensors mailing list on 04/04/2013. This was reviewed by Guenter Roeck from lm-sensors and Zhang Rui (thermal maintainer). They were in agreement not to add notification mechanism to coretemp driver but use thermal sysfs.
Guenter Roeck suggested to use approach like "db8500_thermal driver in drivers/thermal". So resubmitting the driver as a thermal zone driver.
Previous discussion link:
http://comments.gmane.org/gmane.linux.drivers.sensors/32182
"
This is clear that there is reluctance in adding thresholds in coretemp sysfs, during previous attempts. Probably because of lake of use cases.
But this time use case may be more compelling.

We have many small form factor devices like ultrabooks, slate PCs in the market. Unfortunately these devices reach maximum temperature with relatively less workloads, causing BIOS to do thermal throttling. There are real performance issues due to aggressive BIOS action to control thermals and also thermal breakdown in some cases.

Even the most expensive laptops, don't have correct ACPI thermal configuration, so that kernel thermal driver can act. In some case even the trip point is higher than critical temperature setting.

Intel has developed several drivers, which can be used to cool the system very efficiently. They include RAPL based cooling driver, Powerclamp driver and P state driver. To utilize these cooling device a closed loop user mode program is required, which will utilize these method and dynamically compensate for high CPU temperatures, without relying on any configuration data.
One such solution is developed is "Linux thermal daemon". More details can be obtained from "https://github.com/01org/thermal_daemon/blob/master/ThermalDaemon_Introduction.pdf". This daemon polls for cpu temperature and apply compensation once the CPU reach target temperature.

This polling can be mostly avoided, by getting notification for the temperature, where it needs to wake up and get ready for apply compensation. In most of the normal use cases, there may not be any threshold events. So very minimal number of user space notification for thermal thresholds.

Srinivas Pandruvada (3):
x86, mcheck, therm_throt: Process package thresholds
Thermal: CPU Package temperature thermal
Thermal: Documentation for x86 package temperature thermal driver

  Documentation/thermal/x86_pkg_temperature_thermal |  47 ++
  arch/x86/include/asm/mce.h                        |   7 +
  arch/x86/kernel/cpu/mcheck/therm_throt.c          |  63 ++-
  drivers/thermal/Kconfig                           |  12 +
  drivers/thermal/Makefile                          |   2 +-
  drivers/thermal/x86_pkg_temp_thermal.c            | 642 ++++++++++++++++++++++
  6 files changed, 768 insertions(+), 5 deletions(-)
Quoted 3 lines

create mode 100644 Documentation/thermal/x86_pkg_temperature_thermal create mode 100644 drivers/thermal/x86_pkg_temp_thermal.c

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 5 lines · Srinivas Pandruvada

Tony Luck is the maintainer and he did review once and gave comments.

Hi Tony,

Do you have further comments?

I think this looks OK. Have you done any testing on the server end of the spectrum - 2 or 4 socket Sandy Bridge or Ivy Bridge.

-Tony

#7 lore raw
Quoted 7 lines · Tony Luck
Quoted 5 lines · Srinivas Pandruvada

Tony Luck is the maintainer and he did review once and gave comments.

Hi Tony,

Do you have further comments?

Quoted 9 lines

I think this looks OK. Have you done any testing on the server end of the spectrum - 2 or 4 socket Sandy Bridge or Ivy Bridge.

-Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

I tested on Romley (Sandy Bridge) with 2 sockets.

Thanks,
Srinivas

reviewer
#8 lore raw
In reply to Srinivas Pandruvada
Quoted 5 lines · Srinivas Pandruvada

This driver register CPU digital temperature package level sensor as a thermal zone with two user mode configurable trip points. Once the trip point is violated, user mode can receive notification via thermal notification mechanism and can take any action to control temperature.

the whole patch series has been applied.

thanks,
rui

Quoted 66 lines

Changes:
v02:
Did majority of changes suggested by Eduardo Valentin. Main changes are:
- Module parameters for rate control delay
- Removed user space gov parameter in thermal_zone_register
- Changes related to returning of errors values
- Error code return values

v01:
First version for review

Background:
This set of changes were done to coretemp driver and posted to lm_sensors mailing list on 04/04/2013. This was reviewed by Guenter Roeck from lm-sensors and Zhang Rui (thermal maintainer). They were in agreement not to add notification mechanism to coretemp driver but use thermal sysfs.
Guenter Roeck suggested to use approach like "db8500_thermal driver in drivers/thermal". So resubmitting the driver as a thermal zone driver.
Previous discussion link:
http://comments.gmane.org/gmane.linux.drivers.sensors/32182
"
This is clear that there is reluctance in adding thresholds in coretemp sysfs, during previous attempts. Probably because of lake of use cases.
But this time use case may be more compelling.

We have many small form factor devices like ultrabooks, slate PCs in the market. Unfortunately these devices reach maximum temperature with relatively less workloads, causing BIOS to do thermal throttling. There are real performance issues due to aggressive BIOS action to control thermals and also thermal breakdown in some cases.

Even the most expensive laptops, don't have correct ACPI thermal configuration, so that kernel thermal driver can act. In some case even the trip point is higher than critical temperature setting.

Intel has developed several drivers, which can be used to cool the system very efficiently. They include RAPL based cooling driver, Powerclamp driver and P state driver. To utilize these cooling device a closed loop user mode program is required, which will utilize these method and dynamically compensate for high CPU temperatures, without relying on any configuration data.
One such solution is developed is "Linux thermal daemon". More details can be obtained from "https://github.com/01org/thermal_daemon/blob/master/ThermalDaemon_Introduction.pdf". This daemon polls for cpu temperature and apply compensation once the CPU reach target temperature.

This polling can be mostly avoided, by getting notification for the temperature, where it needs to wake up and get ready for apply compensation. In most of the normal use cases, there may not be any threshold events. So very minimal number of user space notification for thermal thresholds.

Srinivas Pandruvada (3):
x86, mcheck, therm_throt: Process package thresholds
Thermal: CPU Package temperature thermal
Thermal: Documentation for x86 package temperature thermal driver

 Documentation/thermal/x86_pkg_temperature_thermal |  47 ++
 arch/x86/include/asm/mce.h                        |   7 +
 arch/x86/kernel/cpu/mcheck/therm_throt.c          |  63 ++-
 drivers/thermal/Kconfig                           |  12 +
 drivers/thermal/Makefile                          |   2 +-
 drivers/thermal/x86_pkg_temp_thermal.c            | 642 ++++++++++++++++++++++
 6 files changed, 768 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/thermal/x86_pkg_temperature_thermal
 create mode 100644 drivers/thermal/x86_pkg_temp_thermal.c