[Ukfreebsd] Disabling hyperthreading on Intel CPUs

Robert N. M. Watson rwatson at FreeBSD.org
Wed Jan 26 11:16:32 GMT 2011

On 26 Jan 2011, at 09:44, andy thomas wrote:

> On Wed, 26 Jan 2011, Mark Blackman wrote:
>> On Wed, 26 Jan 2011 09:33:12 -0000, andy thomas <andy at time-domain.co.uk> wrote:
>>> I want to disable HT because it can impact performance when used to execute code compiled for parallel execution across multiple PCs.
>> So your code is so efficient at utilizing execution resources, (i.e. not really ever stalling), that the HT overhead slows you down?
> I suspect it is! So that's why we'd like to find out by running benchmarks over maybe 150 PCs but fiddling with the BIOS on this many machines is not an enjoyable use of my time. If it can't be disabled via sysctl, then we may well have to do this one weekend and as you have hinted, it could all be a massive waste of time if there's no difference in the results!

FreeBSD treats threads as CPU cores, so you should be able to disable them in device.hints using lines like:


Of course, this requires awareness of the specific topology of a machine to decide which APICs to disable. You can query the scheduler's idea of the topology (which is derived from ACPI, usually, which is sometimes right), by reading the sysctl kern.sched.topology_spec. What with packages, cores, threads, ... scheduler policy is becoming more and more tricky. For some of the SMP work I'm doing for Juniper, we want to have software worker threads for each hardware package, rather than each core, or each thread, etc, and then direct work from within the same package to its dedicated worker thread. Then non-uniform memory access kicks in..

If they're all identical boxes, then you can figure it out on one, and then apply the device.hints to all of them (I think it those lines can also go into loader.conf, if that's more convenient for you).


More information about the Ukfreebsd mailing list