detecting hyperthreading

Alan Somers asomers at freebsd.org
Wed Mar 11 15:19:58 UTC 2015


On Wed, Mar 11, 2015 at 2:55 AM, Gary Jennejohn <gljennjohn at gmail.com> wrote:
> On Tue, 10 Mar 2015 10:07:19 -0600
> Alan Somers <asomers at freebsd.org> wrote:
>
>> On Tue, Mar 10, 2015 at 10:02 AM, Freddie Cash <fjwcash at gmail.com> wrote:
>> > On Tue, Mar 10, 2015 at 8:56 AM, Pokala, Ravi <rpokala at panasas.com> wrote:
>> >
>> >> -----Original Message-----
>> >> From: "lokadamus at gmx.de" <lokadamus at gmx.de>
>> >> Date: 2015-03-10, Tuesday at 08:52
>> >> To: Ravi Pokala <rpokala at panasas.com>, Rui Paulo <rpaulo at me.com>
>> >> Cc: "freebsd-hackers at freebsd.org" <freebsd-hackers at freebsd.org>
>> >> Subject: Re: detecting hyperthreading
>> >>
>> >> >Have you look at dmesg?
>> >> >My system is a P4 with HTT.
>> >> >dmesg |more
>> >> [...]
>> >> >CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz (3000.00-MHz 686-class CPU)
>> >> >  Origin = "GenuineIntel"  Id = 0xf29  Family = 0xf  Model = 0x2
>> >> >Stepping = 9
>> >> >
>> >> >Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,M
>> >> >CA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
>> >> >  Features2=0x4400<CNXT-ID,xTPR>
>> >>
>> >> Of course. :-)
>> >>
>> >> But there are two problems:
>> >>
>> >> (1) That just tells me HTT is supported by the CPU, not that if kernel is
>> >> using it.
>> >> (2) It's difficult to parse.
>> >>
>> >> Of the two, (1) is the bigger concern for my use-case.
>> >>
>> >
>> > 6 lines or so below the Features line shows the kernel loading "cpu0
>> > (BSP)", and then "cpu1 (AP/HT)".
>> >
>> > Compare that to a system without HTT, where any extra cpus only show "(AP)".
>> >
>> > It's not perfect, but one could grep through /var/run/dmesg.boot looking
>> > for "cpu" lines and checking for "(AP)" or "(AP/HT)".
>> >
>> > --
>> > Freddie Cash
>> > fjwcash at gmail.com
>>
>> I always look at "sysctl kern.sched.topology_spec" to tell if
>> hyperthreading is enabled.  It's overkill, but it works.
>>
> [snip Ruby]
>
> Is this ULE-specific?  This OID isn't present on my box using the
> BSD scheduler.  Something to be aware of.
>
> --
> Gary Jennejohn

I never noticed because I don't use the BSD scheduler.  But now that
you mention it, yes it is.  The OID is defined in kern/sched_ule.c.


More information about the freebsd-hackers mailing list