Re: [PATCH 4/7] perf: Check if HT is supported and enabled
From: Peter Zijlstra
Date: Mon Jan 03 2011 - 05:58:24 EST
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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/