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

Kubaj, Piotr piotr.kubaj@intel.com
Thu Jun 11 15:05:58 CEST 2026


The current check is correct. This is exactly the way our architect
suggested. This is because the values written by the user are not
written raw, but kernel uses them only as a suggestion and can be lower
or higher than specified, but need to always abide the values of
scaling_min_freq and scaling_max_freq - which is exactly what this test
checks.

2026-06-11 (木) の 12:32 +0000 に linuxtestproject.agent@gmail.com
さんは書きました:
> Hi Piotr,
> 
> On Thu, 11 Jun 2026 13:42:20 +0200, Piotr Kubaj wrote:
> > cpufreq.c: add new test for cpufreq sysfs interface validation
> 
> > +		if (cpuinfo_max_freq < scaling_max_freq) {
> > +			tst_res(TINFO, "cpuinfo_max_freq: %ld",
> > cpuinfo_max_freq);
> > +			tst_res(TINFO, "scaling_max_freq: %ld",
> > scaling_max_freq);
> > +			tst_res(TFAIL, "Failure setting %s",
> > path);
> > +		} else {
> > +			tst_res(TPASS, "Successfully set up %s",
> > path);
> > +		}
> 
> The frequency write-back checks throughout run() use one-directional
> comparisons. Here the test writes cpuinfo_max_freq to
> scaling_max_freq
> and reads it back, but only fails when the read value is *higher*
> than what was written. If the kernel rounded the value *down* (or the
> write silently failed to a lower value), the test would still report
> TPASS with "Successfully set up".
> 
> The same pattern applies to the scaling_min_freq checks further down,
> which only fail when the read value is *lower* than what was written.
> 
> Since the purpose of these checks is to validate that exact boundary
> values can be written, would it not be more correct to use != instead
> of < / > here?
> 
> > +		if (cpuinfo_max_freq < scaling_min_freq) {
> 
> Same issue: only catches upward deviations.
> 
> > +		if (cpuinfo_min_freq > scaling_min_freq) {
> 
> Same issue: only catches downward deviations.
> 
> > +		if (cpuinfo_min_freq > scaling_max_freq) {
> 
> Same issue: only catches downward deviations.
> 
> Verdict: Needs revision
> 
> ---
> 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
---------------------------------------------------------------------
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.


More information about the ltp mailing list