From owner-freebsd-questions@freebsd.org Tue Jul 13 04:56:15 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A88B56527BA for ; Tue, 13 Jul 2021 04:56:15 +0000 (UTC) (envelope-from tomdean@wavecable.com) Received: from smtp02.emerald.cmh.synacor.com (smtp.emerald.synacor.com [208.47.184.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GP7dB6084z4YKJ for ; Tue, 13 Jul 2021 04:56:14 +0000 (UTC) (envelope-from tomdean@wavecable.com) X-Authed-Username: dG9tZGVhbkB3YXZlY2FibGUuY29t Received: from [24.113.143.192] ([24.113.143.192:44754] helo=[192.168.1.143]) by mail.wavecable.com (envelope-from ) (ecelerity 3.6.25.56547 r(Core:3.6.25.0)) with ESMTPA id A8/4A-12164-DEC1DE06; Tue, 13 Jul 2021 00:56:13 -0400 Subject: Re: How do I disable CPU throttling To: FreeBSD Questions References: <0be4883a-6bf6-28bc-a14b-9cb1f6d729ae@wavecable.com> <4d1e32fc-3e77-626e-138b-6af872445c5e@wavecable.com> From: "Thomas D. Dean" Message-ID: <48605aef-d1ba-c24a-bae7-cb69306410a8@wavecable.com> Date: Mon, 12 Jul 2021 21:56:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Vade-Verdict: clean X-Vade-Analysis-1: gggruggvucftvghtrhhoucdtuddrgedvtddrudeggdehiecutefuodetggdotefrodftvfcurfhrohhf X-Vade-Analysis-2: ihhlvgemucfujgfpteevqfftpdfgoffgtfetnfffpdfqfgfvnecuuegrihhlohhuthemuceftddunecu X-Vade-Analysis-3: secvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeer X-Vade-Analysis-4: tddtfeejnecuhfhrohhmpedfvfhhohhmrghsucffrdcuffgvrghnfdcuoehtohhmuggvrghnseifrghv X-Vade-Analysis-5: vggtrggslhgvrdgtohhmqeenucggtffrrghtthgvrhhnpeehfeffjeehfeduieelteetueehkeehvddv X-Vade-Analysis-6: tdeviedtheegudduveektedvieeuleenucfkphepvdegrdduudefrddugeefrdduledvnecuvehluhhs X-Vade-Analysis-7: thgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrdduudefrddugeefrdduledvpdhhvghl X-Vade-Analysis-8: oheplgduledvrdduieekrddurddugeefngdpmhgrihhlfhhrohhmpehtohhmuggvrghnseifrghvvggt X-Vade-Analysis-9: rggslhgvrdgtohhmpdhrtghpthhtohepfhhrvggvsghsugdqqhhuvghsthhiohhnshesfhhrvggvsghs X-Vade-Analysis-10: ugdrohhrghdphhhoshhtpehsmhhtphdrvghmvghrrghlugdrtghmhhdrshihnhgrtghorhdrtghomhdp X-Vade-Analysis-11: shhpfhepshhofhhtfhgrihhlpdgukhhimheppdhnsggprhgtphhtthhopedupdetuhhthhdqfghsvghr X-Vade-Analysis-12: pehtohhmuggvrghn X-Vade-Client: EMERALD X-Rspamd-Queue-Id: 4GP7dB6084z4YKJ X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of tomdean@wavecable.com designates 208.47.184.7 as permitted sender) smtp.mailfrom=tomdean@wavecable.com X-Spamd-Result: default: False [2.67 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[208.47.184.7:from]; R_SPF_ALLOW(-0.20)[+ip4:208.47.184.0/24]; HFILTER_HELO_IP_A(1.00)[smtp02.emerald.cmh.synacor.com]; HFILTER_HELO_NORES_A_OR_MX(0.30)[smtp02.emerald.cmh.synacor.com]; TO_DN_ALL(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[24.113.143.192:received]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[208.47.184.7:from]; ASN(0.00)[asn:36271, ipnet:208.47.184.0/23, country:US]; ARC_NA(0.00)[]; R_DKIM_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.45)[0.452]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[wavecable.com]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[208.47.184.7:from:127.0.2.255]; NEURAL_SPAM_LONG(0.21)[0.213]; RCVD_IN_DNSWL_NONE(0.00)[208.47.184.7:from]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 04:56:15 -0000 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 > 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.