Messages in this thread | | | Subject | Re: [PATCH 4/7] perf: Check if HT is supported and enabled | From | Peter Zijlstra <> | Date | Mon, 03 Jan 2011 11:58:32 +0100 |
| |
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?
| |