Skip to contentSkip to conversation

thermal: add new test group

PATCH In review Piotr Kubaj 4 participants 9 messages May 14 – Jun 12

lore
Share & tools
lore
#0 lore raw

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

---
Drop static from first_zone.

 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 175

Quoted 7 lines · Piotr Kubaj

thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +5 -0
+	while (sleep_time > 0) {
+		...
+		if (temp > temp_high)
+			break;
+		sleep(sleep_time--);

G2: sleep() used for synchronization. This is not a timer API test so the G2 exemption does not apply. Consider polling with tst_timer_expired_ms() or discuss with maintainers if a thermal-specific exception is appropriate.

testcases/kernel/thermal/thermal_interrupt_events.c line 205

Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +2 -0
+			tst_res(TINFO, "Cooling down for %d seconds", COOLDOWN);
+			sleep(COOLDOWN);

G2: Same issue — sleep() used as a synchronization barrier for CPU cooldown between zone tests. If a non-sleep alternative is genuinely infeasible for thermal testing, this needs explicit justification in the commit message.

---
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
#2 lore raw

Hi all,

actually v20 is better than this v21 => setting it changes requested. I'd prefer to merge v20.

Quoted 16 lines

Hi Piotr,

testcases/kernel/thermal/thermal_interrupt_events.c line 175

Quoted 7 lines · Piotr Kubaj

thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +5 -0
+	while (sleep_time > 0) {
+		...
+		if (temp > temp_high)
+			break;
+		sleep(sleep_time--);

G2: sleep() used for synchronization. This is not a timer API test so the G2 exemption does not apply. Consider polling with tst_timer_expired_ms() or discuss with maintainers if a thermal-specific exception is appropriate.

Quoted 7 lines

testcases/kernel/thermal/thermal_interrupt_events.c line 205

Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +2 -0
+			tst_res(TINFO, "Cooling down for %d seconds", COOLDOWN);
+			sleep(COOLDOWN);

G2: Same issue — sleep() used as a synchronization barrier for CPU cooldown between zone tests. If a non-sleep alternative is genuinely infeasible for thermal testing, this needs explicit justification in the commit message.

Yes, cooldown could have been mentioned in the commit message, I'll add it for v20.

Kind regards,
Petr

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

I set it to 300s, as requested, because attempts to set it to 60s and 120s gave some failures when running with -i 10.

2026-05-15 (金) の 16:42 +0200 に Petr Vorel さんは書きました:

Quoted 34 lines

Hi all,

actually v20 is better than this v21 => setting it changes requested. I'd prefer to merge v20.

Quoted 18 lines

Hi Piotr,

testcases/kernel/thermal/thermal_interrupt_events.c line 175

Quoted 7 lines · Piotr Kubaj

thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +5 -0
+	while (sleep_time > 0) {
+		...
+		if (temp > temp_high)
+			break;
+		sleep(sleep_time--);

G2: sleep() used for synchronization. This is not a timer API test so
the G2 exemption does not apply. Consider polling with tst_timer_expired_ms() or discuss with maintainers if a thermal- specific
exception is appropriate.

Quoted 10 lines

testcases/kernel/thermal/thermal_interrupt_events.c line 205

Quoted 3 lines
(quoted diff) +1 -0
+			tst_res(TINFO, "Cooling down for %d

seconds", COOLDOWN);

testcases/kernel/thermal/thermal_interrupt_events.c new file +1 -0
+			sleep(COOLDOWN);

G2: Same issue — sleep() used as a synchronization barrier for CPU cooldown between zone tests. If a non-sleep alternative is genuinely
infeasible for thermal testing, this needs explicit justification in the
commit message.

Quoted 6 lines

Yes, cooldown could have been mentioned in the commit message, I'll add it for
v20.

Kind regards,
Petr

---------------------------------------------------------------------
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
#4 lore raw

Since there's no other review, is v20 ready to merge?

2026-05-18 (月) の 08:11 +0000 に Kubaj, Piotr さんは書きました:

Quoted 56 lines

I set it to 300s, as requested, because attempts to set it to 60s and 120s gave some failures when running with -i 10.

2026-05-15 (金) の 16:42 +0200 に Petr Vorel さんは書きました:

Quoted 37 lines

Hi all,

actually v20 is better than this v21 => setting it changes requested.
I'd prefer to merge v20.

Quoted 19 lines

Hi Piotr,

testcases/kernel/thermal/thermal_interrupt_events.c line 175

Quoted 7 lines · Piotr Kubaj

thermal: add new test group

testcases/kernel/thermal/thermal_interrupt_events.c new file +5 -0
+	while (sleep_time > 0) {
+		...
+		if (temp > temp_high)
+			break;
+		sleep(sleep_time--);

G2: sleep() used for synchronization. This is not a timer API test
so
the G2 exemption does not apply. Consider polling with tst_timer_expired_ms() or discuss with maintainers if a thermal- specific
exception is appropriate.

Quoted 11 lines

testcases/kernel/thermal/thermal_interrupt_events.c line 205

Quoted 3 lines
(quoted diff) +1 -0
+			tst_res(TINFO, "Cooling down for %d

seconds", COOLDOWN);

testcases/kernel/thermal/thermal_interrupt_events.c new file +1 -0
+			sleep(COOLDOWN);

G2: Same issue — sleep() used as a synchronization barrier for CPU
cooldown between zone tests. If a non-sleep alternative is genuinely
infeasible for thermal testing, this needs explicit justification in the
commit message.

Quoted 6 lines

Yes, cooldown could have been mentioned in the commit message, I'll add it for
v20.

Kind regards,
Petr

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

Quoted 9 lines

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.

---------------------------------------------------------------------
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
#5 lore raw

Hi Piotr,

Quoted 1 line

Since there's no other review, is v20 ready to merge?

I'm sorry it will have to wait after upcoming LTP release (which is going to be this Friday). It's still waits for Cyril's final look. We've been busy with fixing existing tests, that's why he haven't done it yet. Thanks for understanding.

Kind regards,
Petr

Quoted 10 lines

2026-05-18 (月) の 08:11 +0000 に Kubaj, Piotr さんは書きました:

Quoted 9 lines

I set it to 300s, as requested, because attempts to set it to 60s and 120s gave some failures when running with -i 10.

2026-05-15 (金) の 16:42 +0200 に Petr Vorel さんは書きました:

Quoted 5 lines

Hi all,

actually v20 is better than this v21 => setting it changes requested.
I'd prefer to merge v20.

...

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Kubaj, Piotr

Hi!
I've been debugging the test random failures and it all boils down to two things:

- the sysfs temperature values are in mC the increment we have is way too small

- we need to set the trigger value in the while(sleep_time > 0) loop otherwise we can end up running all the iterations with a value that is too high (if we enter the function when the CPU temperature was high)

The test runs reliably for me with -i 100 with these changes, I can push the test with these changes added if you agree:

testcases/kernel/thermal/thermal_interrupt_events.c +19 -11
index 42e1532f6..ed55632dc 100644
@@ -20,10 +20,10 @@
 #include "tst_timer_test.h"
 
 #define        TEST_RUNTIME    ((RUNTIME + SLEEPTIME) * (SLEEPTIME / 2) + COOLDOWN)
-#define        RUNTIME         30
+#define        RUNTIME         10
 #define        SLEEPTIME       10
 #define        COOLDOWN        300
-#define        TEMP_INCREMENT  10
+#define        TEMP_INCREMENT  5000
 
 static bool *x86_pkg_temp_tz;
 static char temp_path[PATH_MAX], trip_path[PATH_MAX];
@@ -135,13 +135,8 @@ static void cpu_workload(double run_time)
        }
 }
 
-static void test_zone(int i)
+static void set_trippoint(void)
 {
-       int sleep_time = SLEEPTIME;
-       double run_time = RUNTIME;
-
-       snprintf(temp_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/temp", i);
-       tst_res(TINFO, "Testing %s", temp_path);
        SAFE_FILE_SCANF(temp_path, "%d", &temp);
        if (temp < 0)
                tst_brk(TBROK, "Unexpected zone temperature value %d", temp);
@@ -150,10 +145,21 @@ static void test_zone(int i)
 
        temp_high = temp + TEMP_INCREMENT;
 
-       snprintf(trip_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);
-
        tst_res(TDEBUG, "Setting new trip_point_1_temp value: %d", temp_high);
        SAFE_FILE_PRINTF(trip_path, "%d", temp_high);
+}
+
+static void test_zone(int i)
+{
+       int sleep_time = SLEEPTIME;
+       double run_time = RUNTIME;
+
+       snprintf(temp_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/temp", i);
+       snprintf(trip_path, PATH_MAX, "/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);
+
+       tst_res(TINFO, "Testing %s", temp_path);
+
+       set_trippoint();
 
        while (sleep_time > 0) {
                tst_res(TDEBUG, "Running for %f seconds, then sleeping for %d seconds", run_time, sleep_time);
@@ -173,7 +179,9 @@ static void test_zone(int i)
                if (temp > temp_high)
                        break;
                sleep(sleep_time--);
-               run_time -= 3;
+               run_time--;
+
+               set_trippoint();
        }
 }
 
Signature · 5 lines
Cyril Hrubis
[email protected]

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

I think your changes look good, please push!

2026-06-09 (火) の 14:24 +0200 に Cyril Hrubis さんは書きました:

Quoted 83 lines

Hi!
I've been debugging the test random failures and it all boils down to two things:

- the sysfs temperature values are in mC the increment we have is way too small

- we need to set the trigger value in the while(sleep_time > 0) loop otherwise we can end up running all the iterations with a value that
  is too high (if we enter the function when the CPU temperature was high)

The test runs reliably for me with -i 100 with these changes, I can push
the test with these changes added if you agree:

testcases/kernel/thermal/thermal_interrupt_events.c +2 -2
index 42e1532f6..ed55632dc 100644
@@ -20,10 +20,10 @@
  #include "tst_timer_test.h"
 
  #define        TEST_RUNTIME    ((RUNTIME + SLEEPTIME) * (SLEEPTIME /
 2) + COOLDOWN)
-#define        RUNTIME         30
+#define        RUNTIME         10
  #define        SLEEPTIME       10
  #define        COOLDOWN        300
-#define        TEMP_INCREMENT  10
+#define        TEMP_INCREMENT  5000
 
  static bool *x86_pkg_temp_tz;

 static char temp_path[PATH_MAX], trip_path[PATH_MAX];

testcases/kernel/thermal/thermal_interrupt_events.c +1 -6
@@ -135,13 +135,8 @@ static void cpu_workload(double run_time)
         }
  }
 
-static void test_zone(int i)
+static void set_trippoint(void)
  {
-       int sleep_time = SLEEPTIME;
-       double run_time = RUNTIME;
-
-       snprintf(temp_path, PATH_MAX,
 "/sys/class/thermal/thermal_zone%d/temp", i);
-       tst_res(TINFO, "Testing %s", temp_path);
         SAFE_FILE_SCANF(temp_path, "%d", &temp);
         if (temp < 0)

                tst_brk(TBROK, "Unexpected zone temperature value %d", temp);

testcases/kernel/thermal/thermal_interrupt_events.c +9 -2
@@ -150,10 +145,21 @@ static void test_zone(int i)
 
         temp_high = temp + TEMP_INCREMENT;
 
-       snprintf(trip_path, PATH_MAX,
 "/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);
-
         tst_res(TDEBUG, "Setting new trip_point_1_temp value: %d",
 temp_high);
         SAFE_FILE_PRINTF(trip_path, "%d", temp_high);
+}
+
+static void test_zone(int i)
+{
+       int sleep_time = SLEEPTIME;
+       double run_time = RUNTIME;
+
+       snprintf(temp_path, PATH_MAX,
 "/sys/class/thermal/thermal_zone%d/temp", i);
+       snprintf(trip_path, PATH_MAX,

"/sys/class/thermal/thermal_zone%d/trip_point_1_temp", i);

testcases/kernel/thermal/thermal_interrupt_events.c +4 -0
+
+       tst_res(TINFO, "Testing %s", temp_path);
+
+       set_trippoint();

        while (sleep_time > 0) {
                tst_res(TDEBUG, "Running for %f seconds, then sleeping for %d seconds", run_time, sleep_time);

testcases/kernel/thermal/thermal_interrupt_events.c static void test_zone(int i) · line 187

Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c +3 -1
@@ -173,7 +179,9 @@ static void test_zone(int i)
                 if (temp > temp_high)
                         break;
                 sleep(sleep_time--);
-               run_time -= 3;
+               run_time--;
+
+               set_trippoint();
         }
  }
 

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