Skip to content

Commit 10ab64c

Browse files
authored
Update gaming-vm-performance.md
just some suggestions because cset is no longer usable for many: SUSE/cpuset#40 i tried to replicate what `cset` does in your original script with the suggestions from the linked issue. i am unsure if setting the `/sys/bus/workqueue/devices/writeback/cpumask` is superflous if `nohz_full` is configured
1 parent 28344ee commit 10ab64c

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

pages/gaming-vm-performance.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Script that orchestrates resource allocation and release. Change variables at st
101101
# Based on Thomas Lindroth's shell script which sets up host for VM: http://sprunge.us/JUfS
102102
# put this script to /etc/libvirt/hooks/qemu
103103

104+
# ideally also set the nohz_full=<$VIRT_CORES> kernel boot option to shield your VIRT_CORES from various kernel jobs (see https://www.suse.com/c/cpu-isolation-nohz_full-part-3/)
105+
104106
TOTAL_CORES='0-11'
105107
TOTAL_CORES_MASK=FFF # 0-11, bitmask 0b111111111111
106108
HOST_CORES='0-1,6-7' # Cores reserved for host
@@ -115,14 +117,37 @@ VM_NAME=$1
115117
VM_ACTION=$2
116118

117119
shield_vm() {
118-
cset set -c $TOTAL_CORES -s machine.slice
119120
# Shield two cores cores for host and rest for VM(s)
120-
cset shield --kthread on --cpu $VIRT_CORES
121+
systemctl set-property --runtime machine.slice AllowedCPUs=$TOTAL_CORES
122+
systemctl set-property --runtime init.scope AllowedCPUs=$HOST_CORES
123+
systemctl set-property --runtime user.slice AllowedCPUs=$HOST_CORES
124+
systemctl set-property --runtime system.slice AllowedCPUs=$HOST_CORES
125+
# Migrate irqs to HOST_CORES (see https://www.suse.com/c/cpu-isolation-practical-example-part-5/)
126+
for I in $(ls /proc/irq)
127+
do
128+
if [[ -d "/proc/irq/$I" ]]
129+
then
130+
echo "Affining vector $I to CPUs $HOST_CORES"
131+
echo $HOST_CORES > /proc/irq/$I/smp_affinity_list
132+
fi
133+
done
134+
>&2 echo "VMs Shielded"
121135
}
122136

123137
unshield_vm() {
124138
echo $TOTAL_CORES_MASK > /sys/bus/workqueue/devices/writeback/cpumask
125-
cset shield --reset
139+
systemctl set-property --runtime machine.slice AllowedCPUs=$TOTAL_CORES
140+
systemctl set-property --runtime init.scope AllowedCPUs=$TOTAL_CORES
141+
systemctl set-property --runtime user.slice AllowedCPUs=$TOTAL_CORES
142+
systemctl set-property --runtime system.slice AllowedCPUs=$TOTAL_CORES
143+
for I in $(ls /proc/irq)
144+
do
145+
if [[ -d "/proc/irq/$I" ]]
146+
then
147+
echo "Affining vector $I to CPUs $TOTAL_CORES"
148+
echo $TOTAL_CORES > /proc/irq/$I/smp_affinity_list
149+
fi
150+
done
126151
}
127152

128153
# For manual invocation

0 commit comments

Comments
 (0)