lkml.org 
[lkml]   [2011]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/7] perf: Check if HT is supported and enabled
From
Date
On Tue, 2010-12-28 at 16:51 +0800, Lin Ming wrote:
> > +static bool ht_enabled(int cpu)
> > +{
> > + int total_logical_processors, total_cores;
> > + unsigned int eax, ebx, ecx, edx;
> > +
> > + cpuid(1, &eax, &ebx, &ecx, &edx);
> > +
> > + /* Bit 28 in EDX indicates if it's HT capable */
> > + if (!(edx & 0x10000000))
> > + return false;
> > +
> > + total_logical_processors = (ebx >> 16) & 0xff;
> > +
> > + ecx = 0;
> > + cpuid(4, &eax, &ebx, &ecx, &edx);
> > + total_cores = ((eax >> 26) & 0x3f) + 1;
> > +
> > + /* Thread nums per core */
> > + return (total_logical_processors / total_cores) > 1;
> > +}
> > +
>
> This function can be simplified as below,
>
> static bool ht_enabled()
> {
> if (!cpu_has(&boot_cpu_data, X86_FEATURE_HT))
> return false;
>
> return smp_num_siblings > 1;
> }
>
> But this still can't detect if HT is on or off.
> smp_num_siblings is always 2 even if HT is disabled in BIOS.
>
> Any idea how to detect if HT is on or not?

Not quite sure, the intel docs aren't really clear on how the HW
supports HT, has 2 siblings but BIOS disabled it thing works. I just
tried reading the arch/x86 code but that only got me more confused.

hpa, could you comment?


\
 
 \ /
  Last update: 2011-01-03 12:01    [W:0.438 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site