Search This Blog

Friday, June 22, 2012

Check whether hyperthreading is enabled or not ?

We can check whether hyper threading is enabled or not without checking in bios by giving following command
# cat /proc/cpuinfo
If the number of siblings and number of cores you see is same then hyper threading is not enabled. If they are not same then its enabled.
If its enabled, then "siblings" give logical cores present and "cpu core" gives actual physical cores.

Total number of cpu's is equal to maximum number of cpu id available in the result + 1.

If you want to find out how many cores are present in a particular cpu and what there numbers are then you can give following command.

#  cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list

1 comment:

Cyford Communications said...

I found this to be the easiest and less code way, which also worked on all my test environments. but requires bc

echo "testing ################################### "

nproc=$(grep -i "processor" /proc/cpuinfo | sort -u | wc -l)

phycore=$(cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\nphysical/g | grep -v ^$ | sort | uniq | wc -l)

if [ -z "$(echo "$phycore *2" | bc | grep $nproc)" ]

then

echo "Does not look like you have HT Enabled"

if [ -z "$( dmidecode -t processor | grep HTT)" ]

then

echo "HT is also not Possible on this server"

else

echo "This server is HT Capable, However it is Disabled"

fi

else

echo "yay HT Is working"

fi

echo "testing ################################### "

I believe this will work on all platforms, Will tell you if its cpu is capable, and if it is enabled... may be a little messy Im a beginner at scripting though. I tested with centos XENSERVER vm, Ubuntu, and Openfiler (rpath)

I have a similar cool script here, would like to see what you think?

http://www.cyfordtechnologies.com/linux-servers/linux-self-optimizing-and-repair-script