HT warning

This commit is contained in:
Andreas Abel
2021-11-12 16:46:23 +01:00
parent bcea7500f6
commit c44530c8d2
5 changed files with 25 additions and 21 deletions

View File

@@ -1,15 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root" 1>&2 echo "This script must be run as root" >&2
echo "Try \"sudo ./disable-HT.sh\"" >&2
exit 1 exit 1
fi fi
for cpu in /sys/devices/system/cpu/cpu[1-9]*; do echo off > /sys/devices/system/cpu/smt/control
if [ -e "$cpu/topology/thread_siblings_list" ]; then
sibling=$(awk -F '[^0-9]' '{ print $2 }' $cpu/topology/thread_siblings_list)
if [ ! -z $sibling ]; then
echo 0 > "/sys/devices/system/cpu/cpu$sibling/online"
fi
fi
done

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root" 1>&2 echo "This script must be run as root" >&2
echo "Try \"sudo ./enable-HT.sh\"" >&2
exit 1 exit 1
fi fi
for cpu in /sys/devices/system/cpu/cpu[1-9]*; do echo on > /sys/devices/system/cpu/smt/control
echo 1 > "$cpu/online"
done

View File

@@ -3,17 +3,21 @@
source utils.sh source utils.sh
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "Error: nanoBench requires root privileges" echo "Error: nanoBench requires root privileges" >&2
echo "Try \"sudo ./kernel-nanoBench.sh ...\"" echo "Try \"sudo ./kernel-nanoBench.sh ...\"" >&2
exit 1 exit 1
fi fi
if [ ! -e /sys/nb ]; then if [ ! -e /sys/nb ]; then
echo "Error: nanoBench kernel module not loaded" echo "Error: nanoBench kernel module not loaded" >&2
echo "Load with \"sudo insmod kernel/nb.ko\"" echo "Load with \"sudo insmod kernel/nb.ko\"" >&2
exit 1 exit 1
fi fi
if [ $(cat /sys/devices/system/cpu/smt/active) -ne 0 ]; then
echo "Note: Hyper-threading is enabled; it can be disabled with \"sudo ./disable-HT.sh\"" >&2
fi
cat /sys/nb/reset cat /sys/nb/reset
taskset="" taskset=""

View File

@@ -240,6 +240,9 @@ if os.geteuid() != 0:
if not os.path.exists('/sys/nb'): if not os.path.exists('/sys/nb'):
sys.exit('Error: nanoBench kernel module not loaded\nLoad with "sudo insmod kernel/nb.ko"') sys.exit('Error: nanoBench kernel module not loaded\nLoad with "sudo insmod kernel/nb.ko"')
if readFile('/sys/devices/system/cpu/smt/active').startswith('1'):
print('Note: Hyper-threading is enabled; it can be disabled with "sudo ./disable-HT.sh"', file=sys.stderr)
prevNMIWatchdogState = readFile('/proc/sys/kernel/nmi_watchdog') prevNMIWatchdogState = readFile('/proc/sys/kernel/nmi_watchdog')
writeFile('/proc/sys/kernel/nmi_watchdog', '0') writeFile('/proc/sys/kernel/nmi_watchdog', '0')

View File

@@ -3,17 +3,21 @@
source utils.sh source utils.sh
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "Error: nanoBench requires root privileges" 1>&2 echo "Error: nanoBench requires root privileges" >&2
echo "Try \"sudo ./nanoBench-asm.sh ...\"" 1>&2 echo "Try \"sudo ./nanoBench-asm.sh ...\"" >&2
exit 1 exit 1
fi fi
if ! command -v rdmsr &>/dev/null; then if ! command -v rdmsr &>/dev/null; then
echo "Error: nanoBench requires msr-tools" echo "Error: nanoBench requires msr-tools" >&2
echo "Install with \"sudo apt install msr-tools\"" echo "Install with \"sudo apt install msr-tools\"" >&2
exit 1 exit 1
fi fi
if [ $(cat /sys/devices/system/cpu/smt/active) -ne 0 ]; then
echo "Note: Hyper-threading is enabled; it can be disabled with \"sudo ./disable-HT.sh\"" >&2
fi
debug=false debug=false
for p in "$@"; do for p in "$@"; do
if [[ "$p" == -de* ]]; then if [[ "$p" == -de* ]]; then