thermal: add new test group
PATCH v13 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.
---
One more calloc() replacement.
--- runtest/thermal | 3 + testcases/kernel/Makefile | 1 + testcases/kernel/thermal/.gitignore | 1 + testcases/kernel/thermal/Makefile | 9 + .../kernel/thermal/thermal_interrupt_events.c | 217 ++++++++++++++++++ 5 files changed, 231 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
@@ -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
@@ -36,6 +36,7 @@ SUBDIRS += connectors \ sched \ security \ sound \ + thermal \ tracing \ uevents \ watchqueue \
testcases/kernel/thermal/.gitignore new file +1 -0
@@ -0,0 +1 @@ +thermal_interrupt_events
testcases/kernel/thermal/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2025, 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 +217 -0
217 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
Hi Piotr,
testcases/kernel/thermal/thermal_interrupt_events.c line 58
Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +2
-0+ ptr = endptr; +tst_res (TDEBUG ,"interrupts[%d]: %ld" , i, interrupts[i]);
interrupts is uint64_t*, so we should use %ul instead.
testcases/kernel/thermal/thermal_interrupt_events.c line 193
Quoted 12 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +12
-0+static void run (void ) +{ +for (int i =0 ; i < tz_counter; i++) { +if (x86_pkg_temp_tz[i]) +test_zone (i); + } +read_interrupts (interrupt_later, nproc); + +for (int i =0 ; i < nproc; i++) { +if (interrupt_later[i] < interrupt_init[i]) +tst_res (TFAIL ,"CPU %d interrupt counter: %ld (previous: %ld)" , + i, interrupt_later[i], interrupt_init[i]);
We always consider TFAIL when counter decreases, but we never consider when it increases. Is there a reason for that?
testcases/kernel/thermal/thermal_interrupt_events.c line 200
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +7
-0+ } + +if (temp <= temp_high) +tst_res (TFAIL ,"Zone temperature is not rising as expected" ); +else +tst_res (TPASS ,"x86 package thermal interrupt triggered" ); +}
I also have other questions in here. Why are we considering only the last zone temperature? Is there a reason for it, or we should save all temperature for all zones and eventually verify temperature increased specifically for each one of them?
Because in a single socket system (I guess) we have one single temperature for all the zones, but on i.e. dual socket server, this test would verify that only the last zone has increased temperature above the higher level. And this is wrong, according to the goal of this test. We want to verify that kernel is correctly working for all systems, correctly increasing the thermal counter for each thermal zone. If this is correct, temp and temp_high should be an array, where each item is associated to a zone, and it should be processed only at the end for TPASS/TFAIL.
Kind Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
2026-03-24 (火) の 13:05 +0000 に Andrea Cervesato さんは書きました:
Quoted 7 lines
Hi Piotr,
Quoted 3 lines
(quoted diff) +2
-0+ ptr = endptr; + tst_res(TDEBUG, "interrupts[%d]:%ld", i, interrupts[i]);
interruptsis uint64_t*, so we should use %ul instead.
That causes:
In file included from thermal_interrupt_events.c:19:thermal_interrupt_events.c: In function ‘read_interrupts’:../../../include/tst_test.h:74:55: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 6 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
74 | tst_res_(__FILE__, __LINE__, (ttype),
(arg_fmt), ##__VA_ARGS__);\
| ^~~~~~~~~
thermal_interrupt_events.c:58:33: note: in expansion of macro ‘tst_res’
58 | tst_res(TDEBUG,
"interrupts[%d]: %ul", i, interrupts[i]);
| ^~~~~~~
Quoted 11 lines
Quoted 11 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +10
-0+static void run (void ) +{ +for (int i =0 ; i < tz_counter; i++) { +if (x86_pkg_temp_tz[i]) +test_zone (i); + } +read_interrupts (interrupt_later, nproc); + +for (int i =0 ; i < nproc; i++) { +if (interrupt_later[i] < interrupt_init[i])
Quoted 8 lines
Quoted 4 lines
(quoted diff) +1
-0+ tst_res(TFAIL, "CPU %d interrupt counter:%ld (previous: %ld)",
(quoted diff) +1
-0+ i, interrupt_later[i],interrupt_init[i]);
We always consider TFAIL when counter decreases, but we never consider when
it increases. Is there a reason for that?
Yes, increasing is expected.
Quoted 17 lines
Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +4
-0+ } + +if (temp <= temp_high) + tst_res(TFAIL, "Zone temperature is not rising asexpected");
(quoted diff) +2
-0+ else + tst_res(TPASS, "x86 package thermal interrupttriggered");
+}I also have other questions in here. Why are we considering only the last zone temperature? Is there a reason for it, or we should save all
temperature for all zones and eventually verify temperature increased specifically for each one of them?
Quoted 9 lines
Because in a single socket system (I guess) we have one single temperature for all the zones, but on i.e. dual socket server, this test would verify that only the last zone has increased temperature above the higher level. And this is wrong, according to the goal of this test. We want to verify that kernel is correctly working for all systems, correctly increasing the thermal counter for each thermal zone. If this is correct,
tempandtemp_highshould be an array, where each item is associated to a zone, and it should be processed only at the end for TPASS/TFAIL.
You're right, all the zones should be checked. I opted for a simpler solution, checking after testing each zone whether temperature rose since it's possible that only one of the zones has an issue. Because interrupts also need to be checked after each zone test, I moved reading initial interrupts array to the run() function as well. cleanup() also needed a fix to restore previous values for all the tested zones.
Quoted 7 lines
Kind Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
---------------------------------------------------------------------
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.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp