Date: Mon, 12 Jul 2021 21:56:11 -0700 From: "Thomas D. Dean" <tomdean@wavecable.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: How do I disable CPU throttling Message-ID: <48605aef-d1ba-c24a-bae7-cb69306410a8@wavecable.com> In-Reply-To: <CAFbbPuh5aCUF_07y-fiyg7kxRxSOCNQHAtSTDPQYrZQpA4HsOQ@mail.gmail.com> References: <f982b8fd-0ec0-24a9-8272-4da3bd5d19c4@wavecable.com> <0be4883a-6bf6-28bc-a14b-9cb1f6d729ae@wavecable.com> <CAFbbPuhuWdzjfH2e7RSwiUa2UORAoJE_-yQeqyoMz7gTMjfxTA@mail.gmail.com> <4d1e32fc-3e77-626e-138b-6af872445c5e@wavecable.com> <CAFbbPuh5aCUF_07y-fiyg7kxRxSOCNQHAtSTDPQYrZQpA4HsOQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 7/12/21 8:17 PM, Paul Procacci wrote:
>
> sysctl dev.cpu.0 | grep freq
dev.cpu.0.freq_levels: 3700/4070 2800/2800 2200/1980
dev.cpu.0.freq: 2200
These numbers are in GHz.
What I want to do is understand where the numbers 3700 and 4070 come from.
It seems powerd_profile picks 3700 as the highest value and 2200 as the
lowest value.
The CPU specs say 4500.
How does the code get the numbers in dev.cpu.0.freq_levels?
I read the code in /usr/src/sys/kern/kern_cpu.c and found a hint
/*
* Used by the cpufreq core, this function will populate *level with the
* current frequency as either determined by a cached value
* sc->curr_level, or in the case the lower level driver has set the
** CPUFREQ_FLAG_UNCACHED flag, it will obtain the frequency from the
** driver itself.
*/
levels = malloc(count * sizeof(*levels), M_TEMP, M_NOWAIT);
CPUFREQ_LEVELS(sc->dev, levels, &count)
/*
* If still booting and secondary CPUs not started yet, don't allow
* changing the frequency until they're online. This is because we
* can't switch to them using sched_bind() and thus we'd only be
*** switching the main CPU. XXXTODO: Need to think more about how to
*** handle having different CPUs at different frequencies.
*/
The numbers 3700, 4070, 2800, 2200, 1980 can not be changed with boot or
runtime config. These values are derived or read from BIOS.
>
> On Mon, Jul 12, 2021 at 5:01 PM Thomas D. Dean <tomdean@wavecable.com
> <mailto:tomdean@wavecable.com>> wrote:
>
> On 7/12/21 1:12 PM, Paul Procacci wrote:
> > sysctl's get set generally in /etc/sysctl.conf
> >
> > dev.cpu.0.freq_levels <-- This format is called a mib in the native
> > parlance.
> > sysctl.conf(5) and sysctl(8) go into much further detail.
> >
> > ~Paul
>
>
> > grep -Rail freq_levels /etc/*
> shows the source of freq_levels
>
> I believe this is hardwired somewhere. Maybe read from the cpu? BIOS?
>
>
> Most mib's have defaults. They are compiled into the kernel statically
> or made available to it via kernel modules.
> What you are looking for is located in this source file:
> /usr/src/sys/kern/kern_cpu.c
>
> Really though, I can tell that's way too much for ya. Instead what you
> are looking to do is
> detailed in rc.conf(5):
>
> " powerd_enable
> (bool) If set to "YES", enable the system power control
> facility with the powerd(8) daemon."
>
> AND
>
> " performance_cpu_freq
> (str) CPU clock frequency to use while on AC power. The
> string "LOW" indicates that cpufreq(4) should use the
> lowest
> frequency available while "HIGH" indicates that the
> highest
> frequency (less power savings) should be used."
>
> What you want to most likely do is the following:
>
> echo powerd_enable=\"YES\" >> /etc/rc.conf
> echo performance_cpu_freq=\"HGH\" >> /etc/rc.conf
>
> Follow that up by restarting the powerd daemon:
>
> /etc/rc.d/powerd restart
>
> If you have a supported cpu, which I have no reason to believe
> otherwise, your
> goal of running your machine at full speed without throttling should be
> within your grasp.
>
> powerd, a userland daemon, controls this mib as necessary on the fly.
>
> rc.conf(5) is a godsend for stuff like this and its documentation is
> amazing.
>
> On another note, I see no reason to change this at all. CPU's are
> nearly instantaneous
> at scaling as necessary to accomodate loads for their needs. I digress
> however.
>
> Take Care.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48605aef-d1ba-c24a-bae7-cb69306410a8>
