lkml.org 
[lkml]   [2011]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/7] perf: Check if HT is supported and enabled
On 01/03/2011 02:58 AM, Peter Zijlstra wrote:
>>
>> 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?
>

Zeroeth of all: anyone who writes () in a function prototype in C needs
to get severely napalmed, maimed, hung and then really hurt. It is
(void) in C, () means (...) which is literally NEVER what you want.

Now, *first* of all: smp_num_siblings as it sits is obviously broken;
the whole notion of a global variable for what is inherently a per-cpu
property is just braindead. At least theoretically there could be cores
with and without HT or with different thread count in the same system.

Second, perf should get this from /proc/cpuinfo, not by grotting around
cpuid by itself.

Third, the code in the kernel is indeed pretty confusing, and it also
has the global variable braindamage... but either it works (in which
case getting the data from /proc/cpuinfo works) or it needs fixing in
addition to the global variable issue.

-hpa


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