Re: methods of hyperthreading on or off

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Mon, 21 Apr 2025 19:06:28 UTC
On Mon, Apr 21, 2025 at 12:56:35PM -0600, John Nielsen wrote:
> On Apr 21, 2025, at 5:34 AM, void <void@f-m.fm> wrote:
> > 
> > 
> > I'd like to turn off hyperthreading on some (most) freebsd machines,
> > the rationale being greater network throughput.
> > 
> > HT can be turned off in the bios and/or via a read-only sysctl
> > in /boot/loader.conf (machdep.hyperthreading_allowed="0")
> > 
> > Which method is superior, and why?
> 
> “Superior” is entirely subjective in this case. The outcome will the largely the same with either method; your machine will not use hyperthreads. If you disable it in the BIOS then the OS will never see them. If you disable it via the tunable then the OS will never use them. The one benefit I can think of is that the tunable is easier to change remotely since you typically need console access to manage BIOS settings.
> 
> As to whether this will help whatever network throughput issue you’re seeing (or if there could be a better way to approach that) I have no idea.
> 

I believe that at least on some CPUs the partition of the execution resources
is static.  So even if OS does not init the dormant hyperthreading cores, it
might consume resources which are then not available to running threads.

Then disabling the threads by a magic MSR would give all resources to the
only one thread.  Note that this is a speculation.