美文网首页
how to disable or enable smt (hy

how to disable or enable smt (hy

作者: AppleLin_cdea | 来源:发表于2021-10-19 15:52 被阅读0次

2021年10月19日15:48:19
如何关闭 cpu 超线程
说明:这个重启后就恢复原样了

show logic core

# cat show_ht.sh 
#!/bin/bash
let cpu_number=$(getconf _NPROCESSORS_ONLN)
for ((i=${cpu_number}/2; i<${cpu_number}; i++));do
   echo “logical HT core $i.”
done

disable logic core

# cat disable_ht.sh 
#!/bin/bash
let cpu_number=$(getconf _NPROCESSORS_ONLN)
for ((i=${cpu_number}/2; i<${cpu_number}; i++));do
   echo “Disabling logical HT core $i.”
   echo 0 > /sys/devices/system/cpu/cpu${i}/online;
done

enable logic core

#!/bin/bash
let cpu_number=$(getconf _NPROCESSORS_ONLN)
for ((i=${cpu_number}; i<${cpu_number}*2; i++));do
   echo “enable logical HT core $i.”
   echo 1 > /sys/devices/system/cpu/cpu${i}/online;
done

demo

没有关超线程

lscpu|grep core:
Thread(s) per core:    2

关超线程

lscpu|grep core:
Thread(s) per core:    1
apple:~/smt$ lscpu|head -8
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             1
apple:~/smt$ sudo ./disable_ht.sh 
“Disabling logical HT core 8.”
“Disabling logical HT core 9.”
“Disabling logical HT core 10.”
“Disabling logical HT core 11.”
“Disabling logical HT core 12.”
“Disabling logical HT core 13.”
“Disabling logical HT core 14.”
“Disabling logical HT core 15.”
apple:~/smt$ lscpu|head -8
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-7
Off-line CPU(s) list:  8-15
Thread(s) per core:    1
Core(s) per socket:    8
apple:~/smt$ 

相关文章

网友评论

      本文标题:how to disable or enable smt (hy

      本文链接:https://www.haomeiwen.com/subject/jvyaoltx.html