Skip to content

Commit bf67d69

Browse files
committed
x86/mce/therm_throt: Mark throttle_active_work() as __maybe_unused
jira LE-3201 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 commit-author Arnd Bergmann <arnd@arndb.de> commit db1ae03 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/db1ae031.failed throttle_active_work() is only called if CONFIG_SYSFS is set, otherwise we get a harmless warning: arch/x86/kernel/cpu/mce/therm_throt.c:238:13: error: 'throttle_active_work' \ defined but not used [-Werror=unused-function] Mark the function as __maybe_unused to avoid the warning. Fixes: f665620 ("x86/mce/therm_throt: Optimize notifications of thermal throttle") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: bberg@redhat.com Cc: ckellner@redhat.com Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: hdegoede@redhat.com Cc: "H. Peter Anvin" <hpa@zytor.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/20191210203925.3119091-1-arnd@arndb.de (cherry picked from commit db1ae03) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # drivers/thermal/intel/therm_throt.c
1 parent 348153a commit bf67d69

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
x86/mce/therm_throt: Mark throttle_active_work() as __maybe_unused
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 Arnd Bergmann <arnd@arndb.de>
6+
commit db1ae0314f47e88ae06679270adf17ffa245afd4
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/db1ae031.failed
10+
11+
throttle_active_work() is only called if CONFIG_SYSFS is set, otherwise
12+
we get a harmless warning:
13+
14+
arch/x86/kernel/cpu/mce/therm_throt.c:238:13: error: 'throttle_active_work' \
15+
defined but not used [-Werror=unused-function]
16+
17+
Mark the function as __maybe_unused to avoid the warning.
18+
19+
Fixes: f6656208f04e ("x86/mce/therm_throt: Optimize notifications of thermal throttle")
20+
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
21+
Signed-off-by: Borislav Petkov <bp@suse.de>
22+
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
23+
Cc: bberg@redhat.com
24+
Cc: ckellner@redhat.com
25+
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26+
Cc: hdegoede@redhat.com
27+
Cc: "H. Peter Anvin" <hpa@zytor.com>
28+
Cc: Ingo Molnar <mingo@redhat.com>
29+
Cc: linux-edac <linux-edac@vger.kernel.org>
30+
Cc: Thomas Gleixner <tglx@linutronix.de>
31+
Cc: Tony Luck <tony.luck@intel.com>
32+
Cc: x86-ml <x86@kernel.org>
33+
Link: https://lkml.kernel.org/r/20191210203925.3119091-1-arnd@arndb.de
34+
(cherry picked from commit db1ae0314f47e88ae06679270adf17ffa245afd4)
35+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
36+
37+
# Conflicts:
38+
# drivers/thermal/intel/therm_throt.c
39+
diff --cc drivers/thermal/intel/therm_throt.c
40+
index dd55d96efeff,8963493a1e9e..000000000000
41+
--- a/drivers/thermal/intel/therm_throt.c
42+
+++ b/drivers/thermal/intel/therm_throt.c
43+
@@@ -134,6 -192,112 +134,115 @@@ static const struct attribute_group the
44+
#define CORE_LEVEL 0
45+
#define PACKAGE_LEVEL 1
46+
47+
++<<<<<<< HEAD:drivers/thermal/intel/therm_throt.c
48+
++=======
49+
+ #define THERM_THROT_POLL_INTERVAL HZ
50+
+ #define THERM_STATUS_PROCHOT_LOG BIT(1)
51+
+
52+
+ #define THERM_STATUS_CLEAR_CORE_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(13) | BIT(15))
53+
+ #define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11))
54+
+
55+
+ static void clear_therm_status_log(int level)
56+
+ {
57+
+ int msr;
58+
+ u64 mask, msr_val;
59+
+
60+
+ if (level == CORE_LEVEL) {
61+
+ msr = MSR_IA32_THERM_STATUS;
62+
+ mask = THERM_STATUS_CLEAR_CORE_MASK;
63+
+ } else {
64+
+ msr = MSR_IA32_PACKAGE_THERM_STATUS;
65+
+ mask = THERM_STATUS_CLEAR_PKG_MASK;
66+
+ }
67+
+
68+
+ rdmsrl(msr, msr_val);
69+
+ msr_val &= mask;
70+
+ wrmsrl(msr, msr_val & ~THERM_STATUS_PROCHOT_LOG);
71+
+ }
72+
+
73+
+ static void get_therm_status(int level, bool *proc_hot, u8 *temp)
74+
+ {
75+
+ int msr;
76+
+ u64 msr_val;
77+
+
78+
+ if (level == CORE_LEVEL)
79+
+ msr = MSR_IA32_THERM_STATUS;
80+
+ else
81+
+ msr = MSR_IA32_PACKAGE_THERM_STATUS;
82+
+
83+
+ rdmsrl(msr, msr_val);
84+
+ if (msr_val & THERM_STATUS_PROCHOT_LOG)
85+
+ *proc_hot = true;
86+
+ else
87+
+ *proc_hot = false;
88+
+
89+
+ *temp = (msr_val >> 16) & 0x7F;
90+
+ }
91+
+
92+
+ static void __maybe_unused throttle_active_work(struct work_struct *work)
93+
+ {
94+
+ struct _thermal_state *state = container_of(to_delayed_work(work),
95+
+ struct _thermal_state, therm_work);
96+
+ unsigned int i, avg, this_cpu = smp_processor_id();
97+
+ u64 now = get_jiffies_64();
98+
+ bool hot;
99+
+ u8 temp;
100+
+
101+
+ get_therm_status(state->level, &hot, &temp);
102+
+ /* temperature value is offset from the max so lesser means hotter */
103+
+ if (!hot && temp > state->baseline_temp) {
104+
+ if (state->rate_control_active)
105+
+ pr_info("CPU%d: %s temperature/speed normal (total events = %lu)\n",
106+
+ this_cpu,
107+
+ state->level == CORE_LEVEL ? "Core" : "Package",
108+
+ state->count);
109+
+
110+
+ state->rate_control_active = false;
111+
+ return;
112+
+ }
113+
+
114+
+ if (time_before64(now, state->next_check) &&
115+
+ state->rate_control_active)
116+
+ goto re_arm;
117+
+
118+
+ state->next_check = now + CHECK_INTERVAL;
119+
+
120+
+ if (state->count != state->last_count) {
121+
+ /* There was one new thermal interrupt */
122+
+ state->last_count = state->count;
123+
+ state->average = 0;
124+
+ state->sample_count = 0;
125+
+ state->sample_index = 0;
126+
+ }
127+
+
128+
+ state->temp_samples[state->sample_index] = temp;
129+
+ state->sample_count++;
130+
+ state->sample_index = (state->sample_index + 1) % ARRAY_SIZE(state->temp_samples);
131+
+ if (state->sample_count < ARRAY_SIZE(state->temp_samples))
132+
+ goto re_arm;
133+
+
134+
+ avg = 0;
135+
+ for (i = 0; i < ARRAY_SIZE(state->temp_samples); ++i)
136+
+ avg += state->temp_samples[i];
137+
+
138+
+ avg /= ARRAY_SIZE(state->temp_samples);
139+
+
140+
+ if (state->average > avg) {
141+
+ pr_warn("CPU%d: %s temperature is above threshold, cpu clock is throttled (total events = %lu)\n",
142+
+ this_cpu,
143+
+ state->level == CORE_LEVEL ? "Core" : "Package",
144+
+ state->count);
145+
+ state->rate_control_active = true;
146+
+ }
147+
+
148+
+ state->average = avg;
149+
+
150+
+ re_arm:
151+
+ clear_therm_status_log(state->level);
152+
+ schedule_delayed_work_on(this_cpu, &state->therm_work, THERM_THROT_POLL_INTERVAL);
153+
+ }
154+
+
155+
++>>>>>>> db1ae0314f47 (x86/mce/therm_throt: Mark throttle_active_work() as __maybe_unused):arch/x86/kernel/cpu/mce/therm_throt.c
156+
/***
157+
* therm_throt_process - Process thermal throttling event from interrupt
158+
* @curr: Whether the condition is current or not (boolean), since the
159+
* Unmerged path drivers/thermal/intel/therm_throt.c

0 commit comments

Comments
 (0)