lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0i_u7ds4sO-UdQ4gfX-8-z1-3NOOWAd3DS0b7E3uma0dA@mail.gmail.com>
Date: Fri, 23 May 2025 20:57:46 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Russell Haley <yumpusamongus@...il.com>
Cc: Shashank Balaji <shashank.mahadasyam@...y.com>, Viresh Kumar <viresh.kumar@...aro.org>, 
	Jonathan Corbet <corbet@....net>, linux-pm@...r.kernel.org, linux-doc@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Shinya Takumi <shinya.takumi@...y.com>
Subject: Re: [PATCH] cpufreq, docs: (userspace governor) add that actual freq
 is >= scaling_setspeed

On Thu, May 22, 2025 at 1:54 PM Rafael J. Wysocki <rafael@...nel.org> wrote:
>
> On Thu, May 22, 2025 at 1:15 PM Russell Haley <yumpusamongus@...il.com> wrote:
> >
> >
> >
> > On 5/22/25 4:47 AM, Rafael J. Wysocki wrote:
> > > On Thu, May 22, 2025 at 10:51 AM Russell Haley <yumpusamongus@...il.com> wrote:
> > >>
> > >>
> > >> On 5/22/25 3:05 AM, Shashank Balaji wrote:
> > >>> The userspace governor does not have the CPUFREQ_GOV_STRICT_TARGET flag, which
> > >>> means the requested frequency may not strictly be followed. This is true in the
> > >>> case of the intel_pstate driver with HWP enabled. When programming the
> > >>> HWP_REQUEST MSR, the min_perf is set to `scaling_setspeed`, and the max_perf
> > >>> is set to the policy's max. So, the hardware is free to increase the frequency
> > >>> beyond the requested frequency.
> > >>>
> > >>> This behaviour can be slightly surprising, given the current wording "allows
> > >>> userspace to set the CPU frequency". Hence, document this.
> > >>>
> > >>
> > >> In my opinion, the documentation is correct, and it is the
> > >> implementation in intel_pstate that is wrong. If the user wanted two
> > >> separate knobs that control the minimum and maximum frequencies, they
> > >> could leave intel_pstate in "active" mode and change scaling_min_freq
> > >> and scaling_max_freq.
> > >>
> > >> If the user asks for the frequency to be set from userspace, the
> > >> frequency had damn well better be set from userspace.
> > >
> > > The userspace governor requests a frequency between policy->min and
> > > policy->max on behalf of user space.  In intel_pstate this translates
> > > to setting DESIRED_PERF to the requested value which is also the case
> > > for the other governors.
> >
> > Huh.  On this Skylake box with kernel 6.14.6, it seems to be setting
> > Minimum_Performance, and leaving desired at 0.
> >
> > > echo userspace | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
> > userspace
> > > echo 1400000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed
> > 1400000
> > > sudo x86_energy_perf_policy &| grep REQ
> > cpu0: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu1: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu2: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu3: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu4: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu5: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu6: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
> > cpu7: HWP_REQ: min 14 max 40 des 0 epp 128 window 0x0 (0*10^0us) use_pkg 0
>
> OK, let me double check the code.

I stand corrected, HWP_MIN_PERF is indeed set in accordance with the
target frequency, not HWP_DESIRED_PERF.

The reason why is because running at a frequency below the target
might cause insufficient performance to be delivered which would break
the assumptions of the schedutil governor.

However, setting HWP_DESIRED_PERF to 0 may be a mistake because it may
cause the CPU to always run above the target frequency which is not
desirable from the power perspective.

What can be done is to set HWP_MIN_PERF and HWP_DESIRED_PERF to the same value.

[Note that intel_cpufreq_adjust_perf() used by the schedutil governor
actually sets HWP_DESIRED_PERF in accordance with the target
frequency, but it also sets HWP_MIN_PERF to the minimum sufficient
perf value supplied by schedutil.  Since intel_cpufreq_fast_switch()
and intel_cpufreq_target() only get one target frequency, they cannot
really say if any frequency below the target will be sufficient.]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ