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
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
fi
for cpu in /sys/devices/system/cpu/cpu[1-9]*; do
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
echo off > /sys/devices/system/cpu/smt/control

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env bash
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
fi
for cpu in /sys/devices/system/cpu/cpu[1-9]*; do
echo 1 > "$cpu/online"
done
echo on > /sys/devices/system/cpu/smt/control

View File

@@ -3,17 +3,21 @@
source utils.sh
if [ "$EUID" -ne 0 ]; then
echo "Error: nanoBench requires root privileges"
echo "Try \"sudo ./kernel-nanoBench.sh ...\""
echo "Error: nanoBench requires root privileges" >&2
echo "Try \"sudo ./kernel-nanoBench.sh ...\"" >&2
exit 1
fi
if [ ! -e /sys/nb ]; then
echo "Error: nanoBench kernel module not loaded"
echo "Load with \"sudo insmod kernel/nb.ko\""
echo "Error: nanoBench kernel module not loaded" >&2
echo "Load with \"sudo insmod kernel/nb.ko\"" >&2
exit 1
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
taskset=""

View File

@@ -240,6 +240,9 @@ if os.geteuid() != 0:
if not os.path.exists('/sys/nb'):
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')
writeFile('/proc/sys/kernel/nmi_watchdog', '0')

View File

@@ -3,17 +3,21 @@
source utils.sh
if [ "$EUID" -ne 0 ]; then
echo "Error: nanoBench requires root privileges" 1>&2
echo "Try \"sudo ./nanoBench-asm.sh ...\"" 1>&2
echo "Error: nanoBench requires root privileges" >&2
echo "Try \"sudo ./nanoBench-asm.sh ...\"" >&2
exit 1
fi
if ! command -v rdmsr &>/dev/null; then
echo "Error: nanoBench requires msr-tools"
echo "Install with \"sudo apt install msr-tools\""
echo "Error: nanoBench requires msr-tools" >&2
echo "Install with \"sudo apt install msr-tools\"" >&2
exit 1
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
for p in "$@"; do
if [[ "$p" == -de* ]]; then