[LTP] cpufreq.c: add new test for cpufreq sysfs interface validation

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Tue May 5 19:53:35 CEST 2026


Hi Piotr,

On Tue, 5 May 2026 13:02:09 +0200, Piotr Kubaj wrote:
> cpufreq.c: add new test for cpufreq sysfs interface validation

> +/*\
> + * Runs various sanity checks for intel_pstate cpufreq sysfs interface.
> + * ...
> + */

The doc comment does not state why root is needed. Per ground-rules rule 4,
document the reason in the doc block — e.g. "Requires root to write to
/sys/devices/system/cpu/intel_pstate/ and per-CPU cpufreq sysfs attributes."

[...]

> +	SAFE_FILE_SCANF("/sys/devices/system/cpu/intel_pstate/no_turbo", "%d", &no_turbo);
> +	SAFE_FILE_SCANF("/sys/devices/system/cpu/intel_pstate/status", "%15s", intel_pstate_status);

CONFIG_X86_INTEL_PSTATE=y does not guarantee the driver is active at runtime
(acpi_cpufreq may take over, or the driver may be in "off" mode). If the
sysfs files are absent, SAFE_FILE_SCANF calls tst_brk(TBROK). Guard with
an existence check and use tst_brk(TCONF, "intel_pstate driver not active")
instead.

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


More information about the ltp mailing list