Skip to contentSkip to conversation

cpufreq.c: add new test for cpufreq sysfs interface validation

PATCH Superseded Piotr Kubaj 3 participants 3 messages Apr 22 – Apr 28

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq.c: add new test for cpufreq sysfs interface validation

Runs various sanity checks for intel_pstate cpufreq sysfs interface.

Checks whether intel_pstate driver is used, whether it is possible to switch scaling_governor to powersave and performance, whether it is possible to disable turbo frequency and whether it is possible to change scaling_min_freq and scaling_max_freq to its minimal valid and maximal valid values.

---
 runtest/power_management_tests               |   1 +
 testcases/kernel/power_management/.gitignore |   1 +
 testcases/kernel/power_management/cpufreq.c  | 355 +++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 testcases/kernel/power_management/cpufreq.c
runtest/power_management_tests +1 -0
index 884e615cd..f235f8f0b 100644
@@ -1,4 +1,5 @@
 #POWER_MANAGEMENT
+cpufreq cpufreq
 runpwtests01 runpwtests01.sh
 runpwtests02 runpwtests02.sh
 runpwtests03 runpwtests03.sh
testcases/kernel/power_management/.gitignore +1 -0
index 0c2a3ed4b..d0d7336ad 100644
@@ -1 +1,2 @@
+cpufreq
 pm_get_sched_values
testcases/kernel/power_management/cpufreq.c new file +355 -0

355 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/power_management/cpufreq.c line 35

Quoted 10 lines · Piotr Kubaj

cpufreq.c: add new test for cpufreq sysfs interface validation

testcases/kernel/power_management/cpufreq.c new file +6 -0
+static long *previous_scaling_max_freq, *previous_scaling_min_freq;
+
+static void cleanup(void)
+{
[...]
+               SAFE_FILE_PRINTF(path, "%ld", previous_scaling_max_freq[i]);
[...]
+               SAFE_FILE_PRINTF(path, "%ld", previous_scaling_min_freq[i]);

Both arrays are zeroed by SAFE_CALLOC in setup() and only populated inside run(). If run() aborts before reaching the per-CPU save loops (e.g. a SAFE_OPEN or SAFE_FILE_SCANF fails on an earlier cpufreq node), cleanup() writes 0 to scaling_max_freq and scaling_min_freq for every online CPU, leaving the system in an invalid state.

Read the original per-CPU values in setup() instead.

Pre-existing issues noticed in the surrounding code (not introduced by this patch):

- cpufreq.c:116 — strstr(contents, "performance powersave") assumes a specific governor ordering that the kernel does not guarantee.
- cpufreq.c:170 — same issue for "performance schedutil".

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