thermal: add new test group
PATCH v3 1/1 thermal: add new test group
This is a new test for checking thermal interrupt events. Addresses some review points from Petr.
--- runtest/thermal | 3 + scenario_groups/default | 1 + testcases/kernel/Makefile | 1 + testcases/kernel/thermal/Makefile | 11 ++ .../kernel/thermal/thermal_interrupt_events.c | 187 ++++++++++++++++++ 5 files changed, 203 insertions(+) create mode 100644 runtest/thermal 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
scenario_groups/default +1 -0
@@ -26,3 +26,4 @@ crypto kernel_misc uevent watchqueue +thermal
testcases/kernel/Makefile +1 -0
@@ -36,6 +36,7 @@ SUBDIRS += connectors \ sched \ security \ sound \ + thermal \ tracing \ uevents \ watchqueue \
testcases/kernel/thermal/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# 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 + +thermal_interrupt_events: LDLIBS += -lpthread + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/thermal/thermal_interrupt_events.c new file +187 -0
187 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,
not a complete review, just few thoughts.
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +0
-0
...
testcases/kernel/thermal/thermal_interrupt_events.c
Quoted 4 lines
testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+/*\ +* Tests the CPU package thermal sensor interface for Intel platforms. + +* Works by checking the initial count of thermal interrupts.
IMHO this part should be in setup function.
Quoted 3 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.
First, why test needs to run for 30 sec and then sleep for 10 sec? Is it possible to check the expected value from sysfs and quit testing before? Also we have TST_RETRY_FUNC() and TST_RETRY_FN_EXP_BACKOFF() which could be used for the loop (you create a function which does the check to quit before the timeout.
Quoted 3 lines
Finally, it restores
+ * the original thermal threshold and checks whether the number of thermal
+ * interrupts increased.
NOTE: the restore will not work if test exits before for some reason (i.e. any of SAFE_*() macros fail). Therefore restore should be in a cleanup function.
Quoted 5 lines
+ */
testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ +#include "tst_safe_stdio.h" +#include "tst_test.h" +#include <ctype.h>
testcases/kernel/thermal/thermal_interrupt_events.c line 29
Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c +10
-0+#include <pthread.h> +#define PATH_LEN 69 +#define STRING_LEN 23 + +static void *cpu_workload (void *arg) +{ +time_t start_time =time (NULL ); +int num =2 ; + +while (difftime (time (NULL ), start_time) < *(double *)arg) {
difftime() is sufficient, but FYI we have include/tst_timer.h for measuring time difference (which uses more precise struct timeval).
testcases/kernel/thermal/thermal_interrupt_events.c line 34
Quoted 5 lines
testcases/kernel/thermal/thermal_interrupt_events.c +5
-0+for (int i =2 ; i * i <= num; i++) { +if (num % i ==0 ) +break ; + } + num++;
This is supposed to do some real workload on CPU? Is that really enough?
Quoted 3 lines
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+ } +return NULL ; +}
...
testcases/kernel/thermal/thermal_interrupt_events.c line 79
Quoted 13 lines
testcases/kernel/thermal/thermal_interrupt_events.c +13
-0+static void run (void ) +{ +bool status =1 ; +char line[8192 ]; +int nproc =tst_ncpus (); +uint64_t interrupt_init[nproc], interrupt_later[nproc]; + +tst_res (TDEBUG ,"Number of logical cores: %d" , nproc); +read_interrupts (interrupt_init, nproc); + +DIR *dir =SAFE_OPENDIR ("/sys/class/thermal/" ); +struct dirent *entry; +uint8_t tz_counter =0 ;
I'm not sure if AI advices you to use it, but really we don't optimize that much that we could not afford just to use plain int. Using exact-width types is usually used only when needed, e.g. when mapping some struct from kernel.
testcases/kernel/thermal/thermal_interrupt_events.c line 86
Quoted 6 lines
testcases/kernel/thermal/thermal_interrupt_events.c +6
-0+while ((entry =SAFE_READDIR (dir))) { +if ((strncmp (entry->d_name,"thermal_zone" ,sizeof ("thermal_zone" ))) >0 ) + tz_counter++; + } +SAFE_CLOSEDIR (dir); +tst_res (TDEBUG ,"Found %d thermal zone(s)" , tz_counter);
I still think this part can be done in setup and needed values stored in static variables (outside function), i.e. static int tz_counter, nproc; Why? Because some people can run test 1000x via "-i 1000", therefore we cache various preparation results.
Quoted 14 lines
testcases/kernel/thermal/thermal_interrupt_events.c +14
-0+ +bool x86_pkg_temp_tz[tz_counter], x86_pkg_temp_tz_found =0 ; + +memset (x86_pkg_temp_tz,0 ,sizeof (x86_pkg_temp_tz)); + +for (uint8_t i =0 ; i < tz_counter; i++) { +char path[PATH_LEN ]; + +snprintf (path,PATH_LEN ,"/sys/class/thermal/thermal_zone%d/type" , i); +tst_res (TDEBUG ,"Checking whether %s is x86_pkg_temp" , path); + +SAFE_FILE_SCANF (path,"%s" , line); +if (strstr (line,"x86_pkg_temp" )) { +tst_res (TDEBUG ,"Thermal zone %d uses x86_pkg_temp" , i);
testcases/kernel/thermal/thermal_interrupt_events.c line 110
Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c +10
-0+ x86_pkg_temp_tz[i] =1 ; + x86_pkg_temp_tz_found =1 ; + } + } +if (!x86_pkg_temp_tz_found) { +tst_res (TINFO ,"No thermal zone uses x86_pkg_temp" ); + status =0 ; + } + +for (uint8_t i =0 ; i < tz_counter; i++) {
Again, please just use int.
testcases/kernel/thermal/thermal_interrupt_events.c line 112
Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+if (x86_pkg_temp_tz[i]) { +char path[PATH_LEN ], temp_path[PATH_LEN ], trip_path[PATH_LEN ], temp_high[12 ], trip[12 ];
You read and write integer values. Using char array is overcomplicated:
int trip, temp_high = temp + 10;
(But maybe have 10 defined as a constant with meaningful name. That is kind of documentation (instead reader having to read the code to understand the meaning of the number).
#define TEMP_INCREMENT 10
testcases/kernel/thermal/thermal_interrupt_events.c line 113
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+double run_time =30 ;
#define RUNTIME 30
testcases/kernel/thermal/thermal_interrupt_events.c line 114
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+uint8_t sleep_time =10 ;
#define SLEEP 10
testcases/kernel/thermal/thermal_interrupt_events.c line 120
Quoted 6 lines
testcases/kernel/thermal/thermal_interrupt_events.c +6
-0+int temp; + +snprintf (path,PATH_LEN ,"/sys/class/thermal/thermal_zone%d/" , i); +strncpy (temp_path, path,PATH_LEN ); +strncat (temp_path,"temp" ,4 ); +tst_res (TDEBUG ,"Testing %s" , temp_path);
nit: I'd put this as TINFO to get at least some debug info without -D.
testcases/kernel/thermal/thermal_interrupt_events.c
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+SAFE_FILE_SCANF (temp_path,"%d" , &temp);
All SAFE_*() macros quit testing, therefore the following check is not needed.
testcases/kernel/thermal/thermal_interrupt_events.c line 127
Quoted 6 lines
testcases/kernel/thermal/thermal_interrupt_events.c +6
-0+if (temp <0 ) { +tst_brk (TBROK ,"Unexpected zone temperature value %d" , temp); + status =0 ; + } +tst_res (TDEBUG ,"Current temperature for %s: %d" , path, temp); +
This would not be needed:
testcases/kernel/thermal/thermal_interrupt_events.c line 134
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c +7
-0+snprintf (temp_high,sizeof (temp_high),"%d" , temp +10 ); + +strncpy (trip_path, path,PATH_LEN ); +strncat (trip_path,"trip_point_1_temp" ,17 ); + +tst_res (TDEBUG ,"Setting new trip_point_1_temp value: %s" , temp_high); +SAFE_FILE_SCANF (trip_path,"%s" , trip);
SAFE_FILE_SCANF(trip_path, "%d", &trip);
testcases/kernel/thermal/thermal_interrupt_events.c line 135
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+SAFE_FILE_PRINTF (trip_path,"%s" , temp_high);
SAFE_FILE_PRINTF(trip_path, "%d", temp_high);
testcases/kernel/thermal/thermal_interrupt_events.c line 142
Quoted 8 lines
testcases/kernel/thermal/thermal_interrupt_events.c +7
-0+ +while (sleep_time >0 ) { +tst_res (TDEBUG ,"Running for %f seconds, then sleeping for %d seconds" , run_time, sleep_time); +pthread_t threads[nproc]; + +for (uint16_t j =0 ; j < nproc; j++) +pthread_create (&threads[j],NULL , cpu_workload, &run_time);
IMHO using pthread (and therefore -lpthread) is overkill. Could you please use simple fork()?
testcases/cve/cve-2017-2618.c
for (i = 0; i < nproc; i++) {
if (!SAFE_FORK()) {
cpu_workload();
exit(0);
}
tst_reap_children();
}Quoted 30 lines
testcases/kernel/thermal/thermal_interrupt_events.c +29
-0+for (uint16_t j =0 ; j < nproc; j++) +pthread_join (threads[j],NULL ); + +SAFE_FILE_SCANF (temp_path,"%d" , &temp); +tst_res (TDEBUG ,"Temperature for %s after a test: %d" , path, temp); + +if (temp >atol (temp_high)) +break ; +sleep (sleep_time--); + run_time -=3 ; + } +if (temp <=atol (temp_high)) { +tst_res (TINFO ,"Zone temperature is not rising as expected" ); + status =0 ; + } + +tst_res (TDEBUG ,"Restoring original trip_point_1_temp value: %s" , trip); +SAFE_FILE_PRINTF (trip_path,"%s" , trip); + } + } +read_interrupts (interrupt_later, nproc); + +for (uint16_t i =0 ; i < nproc; i++) { +if (interrupt_later[i] < interrupt_init[i]) { +tst_res (TINFO ,"For CPU %d interrupt counter is currently %ld, while it was %ld before the test" , i, interrupt_later[i], interrupt_init[i]); + status =0 ; + } + } +
testcases/kernel/thermal/thermal_interrupt_events.c line 180
Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c +9
-0+if (status) +tst_res (TPASS ,"x86 package thermal interrupt triggered" ); +else +tst_res (TFAIL ,"x86 package thermal interrupt did not trigger" ); +} + +static struct tst_test test = { + .min_runtime =180 , + .needs_root = true,
nit: We always set it as 1.
Kind regards,
Petr
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c +7
-0+ .supported_archs = (const char *const []) { +"x86" , +"x86_64" , +NULL + }, + .test_all = run +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
2026-01-22 (木) の 15:07 +0100 に Petr Vorel さんは書きました:
Quoted 7 lines
Hi Piotr,
not a complete review, just few thoughts.
Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c +0
-0...
Quoted 6 lines
Quoted 5 lines
+/*\
+ * Tests the CPU package thermal sensor interface for Intel platforms.
+
+ * Works by checking the initial count of thermal interrupts.IMHO this part should be in setup function.
Done.
Quoted 6 lines
Quoted 5 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.
Quoted 8 lines
First, why test needs to run for 30 sec and then sleep for 10 sec? Is it possible to check the expected value from sysfs and quit testing before?
Also we haveTST_RETRY_FUNC()andTST_RETRY_FN_EXP_BACKOFF()which could be used
for the loop (you create a function which does the check to quit before the
timeout.
Both those macros are unsuitable for this test. TST_RETRY_FUNC() uses a constant sleep time and TST_RETRY_FN_EXP_BACKOFF() increases its timeout.
Here the point is to use a decreasing timeout. The test starts with 10s cooldown to make sure that even pre-production CPU's, which might have their thermal protections disabled, cool down properly. Once sleep time reaches 0, the conclusion is that either there was not enough workload or somehow interrupts are not triggered after all.
Quoted 9 lines
Quoted 5 lines
Finally, it restores
+ * the original thermal threshold and checks whether the number of thermal
+ * interrupts increased.NOTE: the restore will not work if test exits before for some reason (i.e. any of SAFE_*() macros fail). Therefore restore should be in a cleanup
function.
Done.
Quoted 21 lines
Quoted 16 lines
+ */
testcases/kernel/thermal/thermal_interrupt_events.c +14
-0+ +#include "tst_safe_stdio.h" +#include "tst_test.h" +#include <ctype.h> +#include <pthread.h> +#define PATH_LEN 69 +#define STRING_LEN 23 + +static void *cpu_workload (void *arg) +{ +time_t start_time =time (NULL ); +int num =2 ; + +while (difftime (time (NULL ), start_time) < *(double *)arg)Quoted 1 line
{
difftime()is sufficient, but FYI we haveinclude/tst_timer.hfor measuring time difference (which uses more precise struct timeval).
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 34
Quoted 5 lines
testcases/kernel/thermal/thermal_interrupt_events.c +5
-0+for (int i =2 ; i * i <= num; i++) { +if (num % i ==0 ) +break ; + } + num++;This is supposed to do some real workload on CPU? Is that really enough?
Yes, my work desktop currently runs at around 38C, when I start this test it very quickly goes to around 80C, then when the fan starts running faster, it decreases to about 65C.
Quoted 15 lines
Quoted 3 lines
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+ } +return NULL ; +}...
Quoted 11 lines
testcases/kernel/thermal/thermal_interrupt_events.c +11
-0+static void run (void ) +{ +bool status =1 ; +char line[8192 ]; +int nproc =tst_ncpus (); +uint64_t interrupt_init[nproc], interrupt_later[nproc]; + +tst_res (TDEBUG ,"Number of logical cores: %d" , nproc); +read_interrupts (interrupt_init, nproc); + +DIR *dir =SAFE_OPENDIR ("/sys/class/thermal/" );
Quoted 8 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 79
Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+struct dirent *entry; +uint8_t tz_counter =0 ;I'm not sure if AI advices you to use it, but really we don't optimize that much
that we could not afford just to use plain int. Using exact-width types is
usually used only when needed, e.g. when mapping some struct from kernel.
Wrong address here :) I'm anti-FAMA, pro-selfhosting etc. and the current AI fad goes very much against my principles.
Quoted 16 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 86
Quoted 8 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+while ((entry =SAFE_READDIR (dir))) { + if ((strncmp(entry->d_name, "thermal_zone",
sizeof("thermal_zone"))) > 0)testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ tz_counter++; + } +SAFE_CLOSEDIR (dir); +tst_res (TDEBUG ,"Found %d thermal zone(s)" , tz_counter);I still think this part can be done in setup and needed values stored in static
variables (outside function), i.e. static inttz_counter, nproc; Why? Because some
people can run test 1000x via "-i 1000", therefore we cache various preparation
results.
Done.
Quoted 22 lines
Quoted 22 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+ + bool x86_pkg_temp_tz[tz_counter], x86_pkg_temp_tz_found =0;
testcases/kernel/thermal/thermal_interrupt_events.c +7
-0+ +memset (x86_pkg_temp_tz,0 ,sizeof (x86_pkg_temp_tz)); + +for (uint8_t i =0 ; i < tz_counter; i++) { +char path[PATH_LEN ]; + + snprintf(path, PATH_LEN,"/sys/class/thermal/thermal_zone%d/type", i);
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ tst_res(TDEBUG, "Checking whether %s is
x86_pkg_temp", path);testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ +SAFE_FILE_SCANF (path,"%s" , line); +if (strstr (line,"x86_pkg_temp" )) { + tst_res(TDEBUG, "Thermal zone %d uses
x86_pkg_temp", i);testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ x86_pkg_temp_tz[i] =1 ; + x86_pkg_temp_tz_found =1 ; + } + }
Quoted 8 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 110
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+if (!x86_pkg_temp_tz_found) { + tst_res(TINFO, "No thermal zone uses
x86_pkg_temp");testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ status =0 ; + } + +for (uint8_t i =0 ; i < tz_counter; i++) {Again, please just use int.
Done.
Quoted 15 lines
Quoted 4 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+if (x86_pkg_temp_tz[i]) { + char path[PATH_LEN], temp_path[PATH_LEN],trip_path[PATH_LEN], temp_high[12], trip[12];
You read and write integer values. Using char array is overcomplicated:
int trip,temp_high= temp + 10;(But maybe have 10 defined as a constant with meaningful name. That is kind of
documentation (instead reader having to read the code to understand the meaning
of the number).
Quoted 7 lines
#define
TEMP_INCREMENT10testcases/kernel/thermal/thermal_interrupt_events.c line 113
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+double run_time =30 ;#define RUNTIME 30
testcases/kernel/thermal/thermal_interrupt_events.c line 114
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+uint8_t sleep_time =10 ;#define SLEEP 10
Done.
Quoted 11 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 120
Quoted 8 lines
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+int temp; + + snprintf(path, PATH_LEN,"/sys/class/thermal/thermal_zone%d/", i);
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+strncpy (temp_path, path,PATH_LEN ); +strncat (temp_path,"temp" ,4 ); +tst_res (TDEBUG ,"Testing %s" , temp_path);nit: I'd put this as TINFO to get at least some debug info without - D.
Quoted 3 lines
testcases/kernel/thermal/thermal_interrupt_events.c
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+SAFE_FILE_SCANF (temp_path,"%d" , &temp);All SAFE_*() macros quit testing, therefore the following check is not needed.
It's necessary because if the temperature is below 0, there's most likely some kernel or sensor issue.
Quoted 10 lines
Quoted 9 lines
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+if (temp <0 ) { + tst_brk(TBROK, "Unexpected zonetemperature value %d", temp);
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+ status =0 ; + } + tst_res(TDEBUG, "Current temperature for%s: %d", path, temp);
+This would not be needed:
Done.
Quoted 31 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 134
Quoted 10 lines
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ snprintf(temp_high, sizeof(temp_high),"%d", temp + 10);
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+ +strncpy (trip_path, path,PATH_LEN ); + strncat(trip_path, "trip_point_1_temp",17);
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+ + tst_res(TDEBUG, "Setting new
trip_point_1_tempvalue: %s",temp_high);testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+SAFE_FILE_SCANF (trip_path,"%s" , trip);
SAFE_FILE_SCANF(trip_path, "%d", &trip);Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ SAFE_FILE_PRINTF(trip_path, "%s",
temp_high);
SAFE_FILE_PRINTF(trip_path, "%d", temp_high);Quoted 11 lines
testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+ +while (sleep_time >0 ) { + tst_res(TDEBUG, "Running for %fseconds, then sleeping for %d seconds",
run_time,sleep_time);testcases/kernel/thermal/thermal_interrupt_events.c +3
-0+pthread_t threads[nproc]; + + for (uint16_t j = 0; j < nproc;j++)
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ pthread_create(&threads[j], NULL,
cpu_workload,&run_time);IMHO using pthread (and therefore -lpthread) is overkill. Could you please use simple
fork()?
testcases/cve/cve-2017-2618.c
Quoted 9 lines
for (i = 0; i < nproc; i++) {
if (!SAFE_FORK()) {
cpu_workload();
exit(0);
}
tst_reap_children();
}Done.
Quoted 49 lines
Quoted 48 lines
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ for (uint16_t j = 0; j < nproc;j++)
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ pthread_join(threads[j],NULL);
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+ + SAFE_FILE_SCANF(temp_path, "%d",&temp);
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ tst_res(TDEBUG, "Temperature for%s after a test: %d", path, temp);
testcases/kernel/thermal/thermal_interrupt_events.c +8
-0+ +if (temp >atol (temp_high)) +break ; +sleep (sleep_time--); + run_time -=3 ; + } +if (temp <=atol (temp_high)) { + tst_res(TINFO, "Zone temperatureis not rising as expected");
testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+ status =0 ; + } + + tst_res(TDEBUG, "Restoring original
trip_point_1_tempvalue: %s", trip);testcases/kernel/thermal/thermal_interrupt_events.c +8
-0+SAFE_FILE_PRINTF (trip_path,"%s" , trip); + } + } +read_interrupts (interrupt_later, nproc); + +for (uint16_t i =0 ; i < nproc; i++) { +if (interrupt_later[i] < interrupt_init[i]) { + tst_res(TINFO, "For CPU %d interruptcounter is currently %ld, while it was %ld before the test", i, interrupt_later[i], interrupt_init[i]);
testcases/kernel/thermal/thermal_interrupt_events.c +6
-0+ status =0 ; + } + } + +if (status) + tst_res(TPASS, "x86 package thermal interrupttriggered");
testcases/kernel/thermal/thermal_interrupt_events.c +2
-0+else + tst_res(TFAIL, "x86 package thermal interrupt didnot trigger");
testcases/kernel/thermal/thermal_interrupt_events.c +4
-0+} + +static struct tst_test test = { + .min_runtime =180 ,
Quoted 2 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 180
Quoted 1 line
testcases/kernel/thermal/thermal_interrupt_events.c +1
-0+ .needs_root = true,nit: We always set it as 1.
Done.
Quoted 11 lines
Kind regards,
Petrtestcases/kernel/thermal/thermal_interrupt_events.c line 187
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c +7
-0+ .supported_archs = (const char *const []) { +"x86" , +"x86_64" , +NULL + }, + .test_all = run +};
---------------------------------------------------------------------
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
Hi Piotr,
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.First, why test needs to run for 30 sec and then sleep for 10 sec?
Maybe the most important of my questions / points.
Quoted 5 lines
Here the point is to use a decreasing timeout. The test starts with 10s cooldown to make sure that even pre-production CPU's, which might have their thermal protections disabled, cool down properly. Once sleep time reaches 0, the conclusion is that either there was not enough workload or somehow interrupts are not triggered after all.
Why 30 sec and then sleep for 10 sec? Is it really needed to do it this way? Aren't these times depending on the tested machine? Some of them will fail due time not running enough, other will waste time (if they get interrupt e.g. in 10 sec). The usual approach would be to have the timeout safe enough for any type of hardware but proactively check the temperature and stop testing once it's done.
...
Quoted 10 lines
Quoted 9 lines
testcases/kernel/thermal/thermal_interrupt_events.c line 120
Quoted 7 lines
testcases/kernel/thermal/thermal_interrupt_events.c new file +3
-0+int temp; + + snprintf(path, PATH_LEN,"/sys/class/thermal/thermal_zone%d/", i);
testcases/kernel/thermal/thermal_interrupt_events.c new file +3
-0+strncpy (temp_path, path,PATH_LEN ); +strncat (temp_path,"temp" ,4 ); +tst_res (TDEBUG ,"Testing %s" , temp_path);nit: I'd put this as TINFO to get at least some debug info without - D.
Quoted 5 lines
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ SAFE_FILE_SCANF(temp_path, "%d", &temp);All SAFE_*() macros quit testing, therefore the following check is not needed.
It's necessary because if the temperature is below 0, there's most likely some kernel or sensor issue.
I'm sorry, I was wrong here. I mixed up vfscanf() return value from LTP function, but you check the scanned value.
Kind regards,
Petr
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +2
-0+ if (temp < 0) { + tst_brk(TBROK, "Unexpected zonetemperature value %d", temp);
testcases/kernel/thermal/thermal_interrupt_events.c new file +3
-0+ status =0 ; + } + tst_res(TDEBUG, "Current temperature for%s: %d", path, temp);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 7 lines · Petr Vorel
Hi Piotr,
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.First, why test needs to run for 30 sec and then sleep for 10 sec?
Quoted 8 lines
Maybe the most important of my questions / points.
Quoted 5 lines
Here the point is to use a decreasing timeout. The test starts with 10s cooldown to make sure that even pre-production CPU's, which might have their thermal protections disabled, cool down properly. Once sleep time reaches 0, the conclusion is that either there was not enough workload or somehow interrupts are not triggered after all.
Why 30 sec and then sleep for 10 sec? Is it really needed to do it this way?
Of course not.
Quoted 2 lines
Aren't these times depending on the tested machine? Some of them will fail due time not running enough,
That's unexpected with the numbers that are used, so something is amiss if it fails (and so it should fail).
Quoted 1 line
other will waste time (if they get interrupt e.g. in 10 sec).
That very well may happen, but is it a big deal?
Quoted 3 lines
The usual approach would be to have the timeout safe enough for any type of hardware but proactively check the temperature and stop testing once it's done.
We want to create conditions in which the temperature should rise and if it doesn't, then there is a problem.
That said, the temperature can of course be checked more proactively, at least in principle, like say run cpu_workload() for 1s, check the temperature, repeat that several times, then cool down etc.
BR, Rafael
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 18 lines · Petr Vorel
Quoted 7 lines
Hi Piotr,
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.First, why test needs to run for 30 sec and then sleep for 10 sec?
Quoted 8 lines
Maybe the most important of my questions / points.
Quoted 5 lines
Here the point is to use a decreasing timeout. The test starts with 10s cooldown to make sure that even pre-production CPU's, which might have their thermal protections disabled, cool down properly. Once sleep time reaches 0, the conclusion is that either there was not enough workload or somehow interrupts are not triggered after all.
Why 30 sec and then sleep for 10 sec? Is it really needed to do it this way?
Quoted 8 lines
Of course not.
Quoted 2 lines
Aren't these times depending on the tested machine? Some of them will fail due time not running enough,
That's unexpected with the numbers that are used, so something is amiss if it fails (and so it should fail).
I tested on very old (~15 years) Thinkpad, quite powerful 3 years old Thinkpad and some random machine kind of between these two. All detect the threshold with less than 10% of time (heating CPU runtime 1s and sleep time 1s).
You go with 30s to smaller values. Wouldn't be faster to go the opposite (start with small values and increase)? The diff below runs successfully on all 3 machines. What am I missing?
Quoted 3 lines
Quoted 1 line
other will waste time (if they get interrupt e.g. in 10 sec).
That very well may happen, but is it a big deal?
We try to cut down the test runtime, because LTP test collection is huge and runtime for it is many hours [1]. For example, we have many CVE tests which detect race condition. Instead of running each test for "safe long time enough" which could be e.g. several minutes for many of them we have way to shorten the time (see include/tst_fuzzy_sync.h).
Quoted 6 lines
Quoted 3 lines
The usual approach would be to have the timeout safe enough for any type of hardware but proactively check the temperature and stop testing once it's done.
We want to create conditions in which the temperature should rise and if it doesn't, then there is a problem.
Sure.
Quoted 3 lines
That said, the temperature can of course be checked more proactively, at least in principle, like say run
cpu_workload()for 1s, check the temperature, repeat that several times, then cool down etc.
Yeah, that's kind of my proposal above.
Also, all of my 3 machines have only 1x x86_pkg_temp type, but I suppose there are devices with more (I was not able to figure that out from drivers/thermal/intel/x86_pkg_temp_thermal.c but otherwise the test would not try to test them all). But why it is important to test them all? Isn't it enough just to test a single one?
Kind regards,
Petr
Quoted 1 line
BR, Rafael
+++ testcases/kernel/thermal/thermal_interrupt_events.c @@ -117,8 +117,8 @@ static void *cpu_workload(double run_time)
static void test_zone(int i)
{
char path[NAME_MAX], temp_path[NAME_MAX];
- int sleep_time = SLEEP, temp_high, temp;
- double run_time = RUNTIME;
+ int sleep_time = 1, temp_high, temp;
+ double run_time = 1;
snprintf(path, NAME_MAX, "/sys/class/thermal/thermal_zone%d/", i); strncpy(temp_path, path, NAME_MAX);
@@ -138,7 +138,7 @@ static void test_zone(int i)
SAFE_FILE_SCANF(trip_path, "%d", &trip); SAFE_FILE_PRINTF(trip_path, "%d", temp_high);
- while (sleep_time > 0) {
+ while (sleep_time < SLEEP) {
tst_res(TDEBUG, "Running for %f seconds, then sleeping for %d seconds", run_time, sleep_time);
for (int j = 0; j < nproc; j++) {
@@ -155,8 +155,8 @@ static void test_zone(int i)
if (temp > temp_high)
break;
- sleep(sleep_time--);
- run_time -= 3;
+ sleep(sleep_time++);
+ run_time += 3;
}
if (temp <= temp_high)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 20 lines · Petr Vorel
Quoted 13 lines · Petr Vorel
Quoted 12 lines
Hi Piotr,
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Then it
+ * decreases the threshold for sending a thermal interrupt to just above
+ * the current temperature and runs a workload on the CPU.First, why test needs to run for 30 sec and then sleep for 10 sec?
Maybe the most important of my questions / points.
Quoted 5 lines
Here the point is to use a decreasing timeout. The test starts with 10s cooldown to make sure that even pre-production CPU's, which might have their thermal protections disabled, cool down properly. Once sleep time reaches 0, the conclusion is that either there was not enough workload or somehow interrupts are not triggered after all.
Quoted 7 lines
Quoted 1 line
Why 30 sec and then sleep for 10 sec? Is it really needed to do it this way?
Of course not.
Quoted 2 lines
Aren't these times depending on the tested machine? Some of them will fail due time not running enough,
That's unexpected with the numbers that are used, so something is amiss if it fails (and so it should fail).
Quoted 7 lines
I tested on very old (~15 years) Thinkpad, quite powerful 3 years old Thinkpad and some random machine kind of between these two. All detect the threshold with less than 10% of time (heating CPU runtime 1s and sleep time 1s).
You go with 30s to smaller values. Wouldn't be faster to go the opposite (start with small values and increase)? The diff below runs successfully on all 3 machines. What am I missing?
That can be done too, the question is when to decide that the thermal sensor does not work in the case of no response.
The 30 s of running the workload continuously is kind of a "worst case" choice, but a smaller value can be used to start with. If a system that needs a longer time is found, the test can be updated I suppose.
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
other will waste time (if they get interrupt e.g. in 10 sec).
That very well may happen, but is it a big deal?
We try to cut down the test runtime, because LTP test collection is huge and runtime for it is many hours [1]. For example, we have many CVE tests which detect race condition. Instead of running each test for "safe long time enough" which could be e.g. several minutes for many of them we have way to shorten the time (see
include/tst_fuzzy_sync.h).
Fair enough.
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines
The usual approach would be to have the timeout safe enough for any type of hardware but proactively check the temperature and stop testing once it's done.
We want to create conditions in which the temperature should rise and if it doesn't, then there is a problem.
Sure.
Quoted 3 lines
That said, the temperature can of course be checked more proactively, at least in principle, like say run
cpu_workload()for 1s, check the temperature, repeat that several times, then cool down etc.
Quoted 7 lines
Yeah, that's kind of my proposal above.
Also, all of my 3 machines have only 1x
x86_pkg_temptype, but I suppose there are devices with more (I was not able to figure that out fromdrivers/thermal/intel/x86_pkg_temp_thermal.cbut otherwise the test would not try to test them all). But why it is important to test them all? Isn't it enough just to test a single one?
The thermal sensors in question are per processor package. With multiple packages in a system, if any of them does not work as expected, we want to know.
BR, Rafael
Quoted 34 lines
+++
testcases/kernel/thermal/thermal_interrupt_events.c(quoted diff) +5
-5@@ -117,8 +117,8 @@ static void *cpu_workload(double run_time) static void test_zone(int i) { char path[NAME_MAX], temp_path[NAME_MAX]; - int sleep_time = SLEEP, temp_high, temp; - double run_time = RUNTIME; + int sleep_time = 1, temp_high, temp; + double run_time = 1; snprintf(path, NAME_MAX, "/sys/class/thermal/thermal_zone%d/", i); strncpy(temp_path, path, NAME_MAX);@@ -138,7 +138,7 @@ static void test_zone(int i) SAFE_FILE_SCANF(trip_path, "%d", &trip); SAFE_FILE_PRINTF(trip_path, "%d", temp_high); - while (sleep_time > 0) { + while (sleep_time < SLEEP) { tst_res(TDEBUG, "Running for %f seconds, then sleeping for %d seconds", run_time, sleep_time); for (int j = 0; j < nproc; j++) {@@ -155,8 +155,8 @@ static void test_zone(int i) if (temp > temp_high) break; - sleep(sleep_time--); - run_time -= 3; + sleep(sleep_time++); + run_time += 3; } if (temp <= temp_high)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp