Skip to contentSkip to conversation

thermal: add new test group

PATCH Superseded Piotr Kubaj 3 participants 3 messages May 14 – May 15

v20 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

PATCH v20 1/1 thermal: add new test group

Currently consists of only one test for the CPU package thermal sensor interface for Intel platforms.
It works by checking the initial count of thermal interrupts. Then it decreases the threshold for sending a thermal interrupt to just above the current temperature and runs a workload on the CPU. Finally, it restores the original thermal threshold and checks whether the number of thermal interrupts increased.

---
Add 300s cooldown between runs to ensure -i $NUM runs pass.

 runtest/thermal                               |   3 +
 testcases/kernel/Makefile                     |   1 +
 testcases/kernel/thermal/.gitignore           |   1 +
 testcases/kernel/thermal/Makefile             |   9 +
 .../kernel/thermal/thermal_interrupt_events.c | 253 ++++++++++++++++++
 5 files changed, 267 insertions(+)
 create mode 100644 runtest/thermal
 create mode 100644 testcases/kernel/thermal/.gitignore
 create mode 100644 testcases/kernel/thermal/Makefile
 create mode 100644 testcases/kernel/thermal/thermal_interrupt_events.c
runtest/thermal new file +3 -0
new file mode 100644
index 000000000..57e3d29f8
@@ -0,0 +1,3 @@
+# Thermal driver API
+# https://docs.kernel.org/driver-api/thermal/
+thermal_interrupt_events thermal_interrupt_events
testcases/kernel/Makefile +1 -0
index 98fd45a9d..ac816e4e8 100644
@@ -36,6 +36,7 @@ SUBDIRS			+= connectors \
 			   sched \
 			   security \
 			   sound \
+			   thermal \
 			   tracing \
 			   uevents \
 			   watchqueue \
testcases/kernel/thermal/.gitignore new file +1 -0
new file mode 100644
index 000000000..1090bdad8
@@ -0,0 +1 @@
+thermal_interrupt_events
testcases/kernel/thermal/Makefile new file +9 -0
new file mode 100644
index 000000000..eda3a64f1
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2026, Intel Corporation. All rights reserved.
+# Author:Piotr Kubaj <[email protected]>
+
+top_srcdir             ?= ../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/thermal/thermal_interrupt_events.c new file +253 -0

253 lines not on this page · raw message

Signature · 13 lines
2.47.3

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Piotr,

testcases/kernel/thermal/thermal_interrupt_events.c line 207

Quoted 11 lines · Piotr Kubaj

thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +9 -0
+static void run(void)
+{
+	static bool first_zone = true;
+	...
+		if (!first_zone) {
+			tst_res(TINFO, "Cooling down for %d seconds", COOLDOWN);
+			sleep(COOLDOWN);
+		}
+		first_zone = false;

The static qualifier means first_zone is initialized only once, at program start. On the second iteration (-i 2), it will already be false, causing the first zone to incur an unnecessary 300-second cooldown. Drop static so it resets to true on every call.

[...]

---
Note:

Our agent completed the review of the patch. The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#2 lore raw

Hi Piotr,

Quoted 5 lines

Hi Piotr,

Quoted 1 line · Piotr Kubaj

thermal: add new test group

Quoted 14 lines

Review

Quoted 9 lines
(quoted diff) +9 -0
+static void run(void)
+{
+	static bool first_zone = true;
+	...
+		if (!first_zone) {
+			tst_res(TINFO, "Cooling down for %d seconds", COOLDOWN);
+			sleep(COOLDOWN);
+		}
+		first_zone = false;

The static qualifier means first_zone is initialized only once, at program start. On the second iteration (-i 2), it will already be false, causing the first zone to incur an unnecessary 300-second cooldown. Drop static so it resets to true on every call.

AI is wrong, that was actually the point. IMHO this v20 is better than following v21. I just wonder if 300 sec isn't too much.

Also, it can still fail if one runs test more times without iterations. But I'm ok with this known issue.

If I get Cyril's ack, I'll merge this version with minor formatting diff.

Kind regards,
Petr

kernel/thermal/thermal_interrupt_events.c +3 -3
index b282180314..9d9d9d7e4c 100644
@@ -201,7 +201,7 @@ static void run(void)
 	for (int i = 0; i < tz_counter; i++) {
 		if (x86_pkg_temp_tz[i]) {
 			if (!first_zone) {
-				tst_res(TINFO, "Cooling down for %d seconds", COOLDOWN);
+				tst_res(TINFO, "Cooling down for %d sec", COOLDOWN);
 				sleep(COOLDOWN);
 			}
 			first_zone = false;
@@ -215,8 +215,8 @@ static void run(void)
 			for (int j = 0; j < nproc; j++) {
 				if (interrupt_later[j] > interrupt_init[j]) {
 					interrupt_increased = true;
-					tst_res(TINFO, "CPU %d interrupt counter: %" PRIu64 " (previous: %" PRIu64 ")",
-						j, interrupt_later[j], interrupt_init[j]);
+					tst_res(TINFO, "CPU %d interrupt counter: %" PRIu64 " => %" PRIu64,
+						j, interrupt_init[j], interrupt_later[j]);
 				}
 			}
 
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp