Skip to content

Commit 598d507

Browse files
committed
x86/mce/therm_throt: Optimize notifications of thermal throttle
jira LE-3201 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> commit f665620 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-4.18.0-553.22.1.rt7.363.el8_10/f6656208.failed Some modern systems have very tight thermal tolerances. Because of this they may cross thermal thresholds when running normal workloads (even during boot). The CPU hardware will react by limiting power/frequency and using duty cycles to bring the temperature back into normal range. Thus users may see a "critical" message about the "temperature above threshold" which is soon followed by "temperature/speed normal". These messages are rate-limited, but still may repeat every few minutes. This issue became worse starting with the Ivy Bridge generation of CPUs because they include a TCC activation offset in the MSR IA32_TEMPERATURE_TARGET. OEMs use this to provide alerts long before critical temperatures are reached. A test run on a laptop with Intel 8th Gen i5 core for two hours with a workload resulted in 20K+ thermal interrupts per CPU for core level and another 20K+ interrupts at package level. The kernel logs were full of throttling messages. The real value of these threshold interrupts, is to debug problems with the external cooling solutions and performance issues due to excessive throttling. So the solution here is the following: - In the current thermal_throttle folder, show: - the maximum time for one throttling event and, - the total amount of time the system was in throttling state. - Do not log short excursions. - Log only when, in spite of thermal throttling, the temperature is rising. On the high threshold interrupt trigger a delayed workqueue that monitors the threshold violation log bit (THERM_STATUS_PROCHOT_LOG). When the log bit is set, this workqueue callback calculates three point moving average and logs a warning message when the temperature trend is rising. When this log bit is clear and temperature is below threshold temperature, then the workqueue callback logs a "Normal" message. Once a high threshold event is logged, the logging is rate-limited. With this patch on the same test laptop, no warnings are printed in the logs as the max time the processor could bring the temperature under control is only 280 ms. This implementation is done with the inputs from Alan Cox and Tony Luck. [ bp: Touchups. ] Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: bberg@redhat.com Cc: ckellner@redhat.com Cc: hdegoede@redhat.com Cc: Ingo Molnar <mingo@redhat.com> Cc: linux-edac <linux-edac@vger.kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: x86-ml <x86@kernel.org> Link: https://lkml.kernel.org/r/20191111214312.81365-1-srinivas.pandruvada@linux.intel.com (cherry picked from commit f665620) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # drivers/thermal/intel/therm_throt.c
1 parent dfe3ac0 commit 598d507

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
x86/mce/therm_throt: Optimize notifications of thermal throttle
2+
3+
jira LE-3201
4+
Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10
5+
commit-author Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
6+
commit f6656208f04e5b3804054008eba4bf7170f4c841
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-rt-4.18.0-553.22.1.rt7.363.el8_10/f6656208.failed
10+
11+
Some modern systems have very tight thermal tolerances. Because of this
12+
they may cross thermal thresholds when running normal workloads (even
13+
during boot). The CPU hardware will react by limiting power/frequency
14+
and using duty cycles to bring the temperature back into normal range.
15+
16+
Thus users may see a "critical" message about the "temperature above
17+
threshold" which is soon followed by "temperature/speed normal". These
18+
messages are rate-limited, but still may repeat every few minutes.
19+
20+
This issue became worse starting with the Ivy Bridge generation of
21+
CPUs because they include a TCC activation offset in the MSR
22+
IA32_TEMPERATURE_TARGET. OEMs use this to provide alerts long before
23+
critical temperatures are reached.
24+
25+
A test run on a laptop with Intel 8th Gen i5 core for two hours with a
26+
workload resulted in 20K+ thermal interrupts per CPU for core level and
27+
another 20K+ interrupts at package level. The kernel logs were full of
28+
throttling messages.
29+
30+
The real value of these threshold interrupts, is to debug problems with
31+
the external cooling solutions and performance issues due to excessive
32+
throttling.
33+
34+
So the solution here is the following:
35+
36+
- In the current thermal_throttle folder, show:
37+
- the maximum time for one throttling event and,
38+
- the total amount of time the system was in throttling state.
39+
40+
- Do not log short excursions.
41+
42+
- Log only when, in spite of thermal throttling, the temperature is rising.
43+
On the high threshold interrupt trigger a delayed workqueue that
44+
monitors the threshold violation log bit (THERM_STATUS_PROCHOT_LOG). When
45+
the log bit is set, this workqueue callback calculates three point moving
46+
average and logs a warning message when the temperature trend is rising.
47+
48+
When this log bit is clear and temperature is below threshold
49+
temperature, then the workqueue callback logs a "Normal" message. Once a
50+
high threshold event is logged, the logging is rate-limited.
51+
52+
With this patch on the same test laptop, no warnings are printed in the logs
53+
as the max time the processor could bring the temperature under control is
54+
only 280 ms.
55+
56+
This implementation is done with the inputs from Alan Cox and Tony Luck.
57+
58+
[ bp: Touchups. ]
59+
60+
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
61+
Signed-off-by: Borislav Petkov <bp@suse.de>
62+
Cc: "H. Peter Anvin" <hpa@zytor.com>
63+
Cc: bberg@redhat.com
64+
Cc: ckellner@redhat.com
65+
Cc: hdegoede@redhat.com
66+
Cc: Ingo Molnar <mingo@redhat.com>
67+
Cc: linux-edac <linux-edac@vger.kernel.org>
68+
Cc: Thomas Gleixner <tglx@linutronix.de>
69+
Cc: Tony Luck <tony.luck@intel.com>
70+
Cc: x86-ml <x86@kernel.org>
71+
Link: https://lkml.kernel.org/r/20191111214312.81365-1-srinivas.pandruvada@linux.intel.com
72+
(cherry picked from commit f6656208f04e5b3804054008eba4bf7170f4c841)
73+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
74+
75+
# Conflicts:
76+
# drivers/thermal/intel/therm_throt.c
77+
diff --cc drivers/thermal/intel/therm_throt.c
78+
index dd55d96efeff,d01e0da0163a..000000000000
79+
--- a/drivers/thermal/intel/therm_throt.c
80+
+++ b/drivers/thermal/intel/therm_throt.c
81+
@@@ -268,23 -458,28 +457,41 @@@ static void thermal_throttle_remove_dev
82+
/* Get notified when a cpu comes on/off. Be hotplug friendly. */
83+
static int thermal_throttle_online(unsigned int cpu)
84+
{
85+
+ struct thermal_state *state = &per_cpu(thermal_state, cpu);
86+
struct device *dev = get_cpu_device(cpu);
87+
88+
++<<<<<<< HEAD:drivers/thermal/intel/therm_throt.c
89+
+ /*
90+
+ * The first CPU coming online will enable the HFI. Usually this causes
91+
+ * hardware to issue an HFI thermal interrupt. Such interrupt will reach
92+
+ * the CPU once we enable the thermal vector in the local APIC.
93+
+ */
94+
+ intel_hfi_online(cpu);
95+
++=======
96+
+ state->package_throttle.level = PACKAGE_LEVEL;
97+
+ state->core_throttle.level = CORE_LEVEL;
98+
+
99+
+ INIT_DELAYED_WORK(&state->package_throttle.therm_work, throttle_active_work);
100+
+ INIT_DELAYED_WORK(&state->core_throttle.therm_work, throttle_active_work);
101+
++>>>>>>> f6656208f04e (x86/mce/therm_throt: Optimize notifications of thermal throttle):arch/x86/kernel/cpu/mce/therm_throt.c
102+
103+
return thermal_throttle_add_dev(dev, cpu);
104+
}
105+
106+
static int thermal_throttle_offline(unsigned int cpu)
107+
{
108+
+ struct thermal_state *state = &per_cpu(thermal_state, cpu);
109+
struct device *dev = get_cpu_device(cpu);
110+
111+
++<<<<<<< HEAD:drivers/thermal/intel/therm_throt.c
112+
+ intel_hfi_offline(cpu);
113+
++=======
114+
+ cancel_delayed_work(&state->package_throttle.therm_work);
115+
+ cancel_delayed_work(&state->core_throttle.therm_work);
116+
+
117+
+ state->package_throttle.rate_control_active = false;
118+
+ state->core_throttle.rate_control_active = false;
119+
++>>>>>>> f6656208f04e (x86/mce/therm_throt: Optimize notifications of thermal throttle):arch/x86/kernel/cpu/mce/therm_throt.c
120+
121+
thermal_throttle_remove_dev(dev);
122+
return 0;
123+
* Unmerged path drivers/thermal/intel/therm_throt.c

0 commit comments

Comments
 (0)