Libvirt qemu hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PINNED=2-7,10-15 | |
UNPINNED=0-1,8-9 | |
if [[ $2 == "start" ]]; then | |
echo "Allocating hugepages..." | |
#hp 16 || ( echo "Could not allocate hugepages" >&2 && exit 1 ) | |
echo "Stopping sanoid" | |
systemctl stop sanoid.timer | |
echo "Isolating cpu set" | |
cset shield --kthread=on --cpu=$PINNED | |
echo '0' >> /sys/fs/cgroup/cpuset/system/cpuset.cpu_exclusive | |
echo '0' >> /sys/fs/cgroup/cpuset/user/cpuset.cpu_exclusive | |
echo "Setting min turbo perf to 40" | |
echo 40 > /sys/devices/system/cpu/intel_pstate/min_perf_pct | |
elif [[ $2 == "started" ]]; then | |
grep -e vfio /proc/interrupts | cut -d: -f1 | tr -d ' ' | grep -E '^[0-9]+$' | while read int; do | |
echo $PINNED > /proc/irq/$int/smp_affinity_list | |
done | |
grep -ve vfio /proc/interrupts | cut -d: -f1 | tr -d ' ' | grep -E '^[0-9]+$' | while read int; do | |
echo $UNPINNED > /proc/irq/$int/smp_affinity_list || true | |
done | |
true | |
elif [[ $2 == "stopped" ]]; then | |
cset shield --reset | |
cset set -d machine | |
systemctl start sanoid.timer | |
echo 16 > /sys/devices/system/cpu/intel_pstate/min_perf_pct # 16 was the default | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment