From 7250cfe9373ab72989ad6a8f33cddcf8dcfd1d7b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 3 Mar 2006 02:01:19 +0000 Subject: [PATCH] proper check if HT is enabled --- src/os/linux/linux_sigar.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index fb4fed39..5b64f6f2 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -216,8 +216,23 @@ static int is_ht_enabled(sigar_t *sigar) sigar_cpuid(1, &eax, &ebx, &ecx, &edx); if (edx & (1<<28)) { + unsigned long apic_id = + (ebx & 0xFF000000) >> 24; + unsigned long log_id, phy_id_mask=0xFF, i=1; + sigar->lcpu = (ebx & 0x00FF0000) >> 16; + while (i < sigar->lcpu) { + i *= 2; + phy_id_mask <<= 1; + } + + log_id = apic_id & ~phy_id_mask; + + if (log_id == 0) { + sigar->lcpu = 1; + } + if (sigar->lcpu > 1) { sigar->ht_enabled = 1; sigar_log_printf(sigar, SIGAR_LOG_DEBUG,