Skip to contentSkip to conversation

thermal: add new test group

PATCH Superseded Piotr Kubaj 5 participants 7 messages May 6 – May 13

v19 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

PATCH v19 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.

---
Correct year in the Makefile.

 runtest/thermal                               |   3 +
 testcases/kernel/Makefile                     |   1 +
 testcases/kernel/thermal/.gitignore           |   1 +
 testcases/kernel/thermal/Makefile             |   9 +
 .../kernel/thermal/thermal_interrupt_events.c | 242 ++++++++++++++++++
 5 files changed, 256 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 +242 -0

242 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 9

Quoted 6 lines · Piotr Kubaj

[PATCH] thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +4 -0
+/*\
+ * Tests the CPU package thermal sensor interface for Intel platforms.
+
+ * Works by checking the initial count of thermal interrupts. Then it

The blank line separating the two paragraphs must carry the " *" prefix, i.e. " *" on its own, not an empty line.

testcases/kernel/thermal/thermal_interrupt_events.c line 174

Quoted 4 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +4 -0
+		if (temp > temp_high)
+			break;
+		sleep(sleep_time--);
+		run_time -= 3;

sleep() for synchronisation is not allowed (LTP ground rule G2). Replace with a polling loop using tst_timer_start()/tst_timer_expired_ms(), or remove the sleep and let the workload loop duration do the pacing.

---
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
Acked-by Andrea Cervesato
#2 lore raw

Hi Piotr,

you can ignore the AI agent review in this case. We already talked about these issues and the patch looks ok to me and others. Hopefully we can merge this soon.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v19 1/1
#3 lore raw
In reply to Piotr Kubaj

Hi Piotr,

Quoted 7 lines

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.

While I consider this ready and Andrea already acked this (I really want to get this merged before LTP new release in the end of May), let's wait for Cyril's ack (you're on his TODO list).

Thanks for your work and patience.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v19 1/1
#4 lore raw
In reply to Piotr Kubaj

Hi!

testcases/kernel/thermal/thermal_interrupt_events.c line 78

Quoted 6 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +6 -0
+static void setup(void)
+{
+	char line[8192];
+
+	nproc = tst_ncpus();
+	tst_set_runtime(nproc * TEST_RUNTIME);

The last thing that I do not think is correct is this part. We are setting the runtime here based on the number of CPUs and not based on the number of actuall test iterations.

I guess that we need to:

Turn the x86_pkg_temp_tz_found into a counter and collect the number of thermal zones found and set the runtime at the end of the setup with the counter instead.

And at the same time the TEST_RUNTIME appears to be significantly smaller than the actual runtime.

The upper bound for the runtime is a sum of all possible iterations, if we simplify it a bit it would be roughly ((RUNTIME+SLEEPTIME) * (SLEEPTIME/2))

As we are doing SLEEPTIME iterations with SLEEPTIME and RUNTIME getting smaller in each of them so it will average out to SLEEPTIME/2 iterations with full (RUNTIME+SLEEPTIME)

So I guess that we need:

  #define TEST_RUNTIME ((RUNTIME+SLEEPTIME) * (SLEEPTIME/2))

The rest looks good to me.

With the runtime calculation fixed:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
Quoted 25 lines

Hi!

testcases/kernel/thermal/thermal_interrupt_events.c line 78

Quoted 6 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +6 -0
+static void setup(void)
+{
+	char line[8192];
+
+	nproc = tst_ncpus();
+	tst_set_runtime(nproc * TEST_RUNTIME);

The last thing that I do not think is correct is this part. We are setting the runtime here based on the number of CPUs and not based on the number of actuall test iterations.

I guess that we need to:

Turn the x86_pkg_temp_tz_found into a counter and collect the number of thermal zones found and set the runtime at the end of the setup with the counter instead.

And at the same time the TEST_RUNTIME appears to be significantly smaller than the actual runtime.

The upper bound for the runtime is a sum of all possible iterations, if we simplify it a bit it would be roughly ((RUNTIME+SLEEPTIME) * (SLEEPTIME/2))

Quoted 7 lines

As we are doing SLEEPTIME iterations with SLEEPTIME and RUNTIME getting smaller in each of them so it will average out to SLEEPTIME/2 iterations with full (RUNTIME+SLEEPTIME)

So I guess that we need:

  #define TEST_RUNTIME ((RUNTIME+SLEEPTIME) * (SLEEPTIME/2))

And other thing which is on my machine broken is to run with more iterations, it randomly fails or get stuck after first iteration:

./thermal_interrupt_events -i3
thermal_interrupt_events.c:207: TINFO: CPU 23 interrupt counter: 23 (previous: 21) thermal_interrupt_events.c:217: TPASS: x86 package thermal interrupt triggered thermal_interrupt_events.c:142: TINFO: Testing /sys/class/thermal/thermal_zone9/temp thermal_interrupt_events.c:213: TFAIL: No thermal interrupt increase detected

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Hi!

Quoted 8 lines

And other thing which is on my machine broken is to run with more iterations, it randomly fails or get stuck after first iteration:

./thermal_interrupt_events -i3
thermal_interrupt_events.c:207: TINFO: CPU 23 interrupt counter: 23 (previous: 21) thermal_interrupt_events.c:217: TPASS: x86 package thermal interrupt triggered thermal_interrupt_events.c:142: TINFO: Testing /sys/class/thermal/thermal_zone9/temp thermal_interrupt_events.c:213: TFAIL: No thermal interrupt increase detected

That may as well be because the CPU heatsink accumulated too much heat and cannot increase it further. Interacting with the physical world outside is a bit tricky. The test may need a cooldown period (e.g. sleep(300)) at the end of the test iteration.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp