Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading
@ 2026-08-28 23:09 Wake Liu via ltp
  2026-08-29  3:33 ` [LTP] " linuxtestproject.agent
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wake Liu via ltp @ 2026-08-28 23:09 UTC (permalink / raw)
  To: ltp; +Cc: Wake Liu, Grzegorz Jaszczyk

From: Grzegorz Jaszczyk <jaszczyk@google.com>

In setup(), the test assumes that all secondary CPUs (cpu1..cpuN-1)
expose '/sys/devices/system/cpu/cpu<N>/online' and attempts to read
their status using SAFE_FILE_SCANF().

However, on systems where CPU hotplugging is disabled (e.g. kernels
built without CONFIG_HOTPLUG_CPU or platforms where CPUs are not
hotpluggable), the per-CPU 'online' sysfs attributes are not created.
Calling SAFE_FILE_SCANF() on a non-existent file results in ENOENT
and breaks test setup with TBROK.

Check for the existence of the per-CPU 'online' file with access()
first. If the file exists, read the status via SAFE_FILE_SCANF(); if
it does not exist, assume the CPU is not hotpluggable and is
permanently online.

Signed-off-by: Grzegorz Jaszczyk <jaszczyk@google.com>
Signed-off-by: Wake Liu <wakel@google.com>
---
 testcases/kernel/power_management/cpufreq_intel.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/power_management/cpufreq_intel.c b/testcases/kernel/power_management/cpufreq_intel.c
index 11896258e..a2a3f3475 100644
--- a/testcases/kernel/power_management/cpufreq_intel.c
+++ b/testcases/kernel/power_management/cpufreq_intel.c
@@ -94,8 +94,16 @@ static void setup(void)
 		int tmp;
 
 		snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/online", i);
-		SAFE_FILE_SCANF(path, "%d", &tmp);
-		online[i] = (bool)tmp;
+		if (access(path, F_OK) == 0) {
+			SAFE_FILE_SCANF(path, "%d", &tmp);
+			online[i] = (bool)tmp;
+		} else {
+			/*
+			 * If the 'online' file is missing, the CPU is not
+			 * hotpluggable and is permanently online.
+			 */
+			online[i] = true;
+		}
 	}
 
 	SAFE_FILE_PRINTF("/sys/devices/system/cpu/intel_pstate/status", "active");
-- 
2.55.0.897.gb25b4bd76c-goog


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] cpufreq_intel: Check for per-CPU online file presence before reading
  2026-08-28 23:09 [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading Wake Liu via ltp
@ 2026-08-29  3:33 ` linuxtestproject.agent
  2026-08-31  9:58 ` [LTP] [PATCH] " Kubaj, Piotr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: linuxtestproject.agent @ 2026-08-29  3:33 UTC (permalink / raw)
  To: Wake Liu; +Cc: ltp

Hi Grzegorz,

On Aug 28, 2026, Grzegorz Jaszczyk wrote:
> cpufreq_intel: Check for per-CPU online file presence before reading

Verdict - Reviewed

---
Note:

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

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading
  2026-08-28 23:09 [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading Wake Liu via ltp
  2026-08-29  3:33 ` [LTP] " linuxtestproject.agent
@ 2026-08-31  9:58 ` Kubaj, Piotr
  2026-08-31 10:49 ` Andrea Cervesato via ltp
  2026-08-31 10:50 ` Andrea Cervesato via ltp
  3 siblings, 0 replies; 5+ messages in thread
From: Kubaj, Piotr @ 2026-08-31  9:58 UTC (permalink / raw)
  To: ltp@lists.linux.it, wakel@google.com; +Cc: jaszczyk@google.com

W dniu pią, 28.08.2026 o godzinie 23∶09 +0000, użytkownik Wake Liu
napisał:
> From: Grzegorz Jaszczyk <jaszczyk@google.com>
> 
> In setup(), the test assumes that all secondary CPUs (cpu1..cpuN-1)
> expose '/sys/devices/system/cpu/cpu<N>/online' and attempts to read
> their status using SAFE_FILE_SCANF().
> 
> However, on systems where CPU hotplugging is disabled (e.g. kernels
> built without CONFIG_HOTPLUG_CPU or platforms where CPUs are not
> hotpluggable), the per-CPU 'online' sysfs attributes are not created.
> Calling SAFE_FILE_SCANF() on a non-existent file results in ENOENT
> and breaks test setup with TBROK.
> 
> Check for the existence of the per-CPU 'online' file with access()
> first. If the file exists, read the status via SAFE_FILE_SCANF(); if
> it does not exist, assume the CPU is not hotpluggable and is
> permanently online.
> 
> Signed-off-by: Grzegorz Jaszczyk <jaszczyk@google.com>
> Signed-off-by: Wake Liu <wakel@google.com>
> ---
>  testcases/kernel/power_management/cpufreq_intel.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/power_management/cpufreq_intel.c
> b/testcases/kernel/power_management/cpufreq_intel.c
> index 11896258e..a2a3f3475 100644
> --- a/testcases/kernel/power_management/cpufreq_intel.c
> +++ b/testcases/kernel/power_management/cpufreq_intel.c
> @@ -94,8 +94,16 @@ static void setup(void)
>  		int tmp;
>  
>  		snprintf(path, sizeof(path),
> "/sys/devices/system/cpu/cpu%d/online", i);
> -		SAFE_FILE_SCANF(path, "%d", &tmp);
> -		online[i] = (bool)tmp;
> +		if (access(path, F_OK) == 0) {
> +			SAFE_FILE_SCANF(path, "%d", &tmp);
> +			online[i] = (bool)tmp;
> +		} else {
> +			/*
> +			 * If the 'online' file is missing, the CPU
> is not
> +			 * hotpluggable and is permanently online.
> +			 */
> +			online[i] = true;
> +		}
>  	}
>  
>  	SAFE_FILE_PRINTF("/sys/devices/system/cpu/intel_pstate/statu
> s", "active");

LGTM.
Reviewed-by: Piotr Kubaj <piotr.kubaj@intel.com>
---------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading
  2026-08-28 23:09 [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading Wake Liu via ltp
  2026-08-29  3:33 ` [LTP] " linuxtestproject.agent
  2026-08-31  9:58 ` [LTP] [PATCH] " Kubaj, Piotr
@ 2026-08-31 10:49 ` Andrea Cervesato via ltp
  2026-08-31 10:50 ` Andrea Cervesato via ltp
  3 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-31 10:49 UTC (permalink / raw)
  To: Wake Liu; +Cc: Grzegorz Jaszczyk, ltp

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading
  2026-08-28 23:09 [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading Wake Liu via ltp
                   ` (2 preceding siblings ...)
  2026-08-31 10:49 ` Andrea Cervesato via ltp
@ 2026-08-31 10:50 ` Andrea Cervesato via ltp
  3 siblings, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-31 10:50 UTC (permalink / raw)
  To: Wake Liu; +Cc: Grzegorz Jaszczyk, ltp

Merged, Thanks!

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-31 10:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 23:09 [LTP] [PATCH] cpufreq_intel: Check for per-CPU online file presence before reading Wake Liu via ltp
2026-08-29  3:33 ` [LTP] " linuxtestproject.agent
2026-08-31  9:58 ` [LTP] [PATCH] " Kubaj, Piotr
2026-08-31 10:49 ` Andrea Cervesato via ltp
2026-08-31 10:50 ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox