In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to enable and disable hyperthreading technology dynamically in Linux". In daily operation, I believe many people have doubts about how to enable and disable hyperthreading technology dynamically in Linux. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to enable and disable hyperthreading technology dynamically in Linux". Next, please follow the editor to study!
Intel's hyper-threading technology allows two threads to be executed in parallel on a physical core, which in most cases can improve the utilization of hardware resources and enhance system performance. For cpu-intensive numerical programs, hyper-threading technology may lead to a decline in overall program performance. For this reason, it is recommended to turn off hyper-threading when executing OpenMP or MPI numeric programs.
Here are the scripts found on github to dynamically turn on and off hyper-threading technology. The principle is to find the relationship between the logical core according to the / sys/devices/system/cpu/cpuX/topology/thread_siblings_list file, and then edit the / sys/devices/system/cpu/cpuX/online file to dynamically open and close hyper-threading technology.
#! / bin/bashHYPERTHREADING=1function toggleHyperThreading () {for CPU in/ sys/devices/system/cpu/cpu [0-9] *; do CPUID= `basename $CPU | cut-b4-`basename $CPU | cut-b4-`basename en "CPU: $CPUID\ t" [- e $CPU/online] & & echo "1" > $CPU/online THREAD1= `cat $CPU/topology/thread_siblings_list | cut-F1-d, `if [$CPUID= $THREAD1] Then echo "- > enable" [- e $CPU/online] & & echo "1" > $CPU/online else if ["$HYPERTHREADING"-eq "0"]; then echo "- > disabled"; else echo "- > enabled" Fi echo "$HYPERTHREADING" > $CPU/online fi done} function enabled () {echo-en "Enabling HyperThreading\ n" HYPERTHREADING=1 toggleHyperThreading} function disabled () {echo-en "Disabling HyperThreading\ n" HYPERTHREADING=0 toggleHyperThreading} # ONLINE=$ (cat / sys/devices/system/cpu/online) OFFLINE=$ (cat / sys/devices/system/cpu/offline) echo "- -- "echo-en" CPU's online: $ONLINE\ t CPU's offline: $OFFLINE\ n "echo"-"while true Do read-p "Type in e to enable or d disable hyperThreading or q to quit [e/d/q]?" Ed case $ed in [Ee] *) enabled; break;; [Dd] *) disabled;exit;; [Qq] *) exit;; *) echo "Please answer e for enable or d for disable hyperThreading."; esacdone
Note:
Script needs root permission to execute
You can view the enabled cpu information through cat / proc/cpuinfo, which does not require root permission
The lscpu command can view the status of cpu (no root permission is required): the threads per core value is 2 in hyperthreaded state and 1. 0 when disabled.
Referenc
Disable / Enable HyperThreading cores on runtime-linux
At this point, the study on "how to dynamically enable and disable hyper-threading technology in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.