Originally posted by xnor
View Post
I'd link you to my repo but my account's still fresh, so here it is raw:
Code:
#!/bin/bash # Try your best to control SMT on original Ryzen CPUs (and maybe others?) # Usage: ./smt.sh (enable|disable|status) num_cores=`lscpu | grep "CPU(s):" | grep -v "," | grep -v "-" | cut -d: -f2 | awk '{print $1}'` num_procs=`nproc` coreLoop() { i="1" while [ "${i}" -lt "${num_cores}" ]; do echo "$1" > /sys/devices/system/cpu/cpu${i}/online i=$[ $i + 2 ] done echo "Done." return 0 } disable() { if [ "${num_procs}" -lt "${num_cores}" ]; then echo "SMT has already been disabled!" return 1 else echo -n "Disabling SMT: " coreLoop 0 fi } enable() { if [ "${num_procs}" -eq "${num_cores}" ]; then echo "SMT has already been enabled!" return 1 else echo -n "Enabling SMT: " coreLoop 1 fi } status() { cat /proc/cpuinfo |egrep "processor|physical id|core id" | sed 's/^processor/\nprocessor/g' } case "$1" in disable) disable;; enable) enable;; status) status;; *) echo " Usage: ./smt.sh (disable | enable | status)";; esac
Comment