2019-11-02 20:35:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
TOTAL_CORES='0-7'
|
|
|
|
HOST_CORES='0-1' # Cores reserved for host
|
|
|
|
HOST_CORES_MASK=C0 # 0-1,6-7, bitmask 0b000011000011
|
|
|
|
VIRT_CORES='2-7' # Cores reserved for virtual machine(s)
|
|
|
|
|
|
|
|
# Stretch package contains an old version of cset which doesn't work (or never worked)
|
|
|
|
#cset set -c $TOTAL_CORES -s machine.slice
|
|
|
|
#cset shield --kthread on --cpu $VIRT_CORES
|
|
|
|
# Reduce VM jitter: https://www.kernel.org/doc/Documentation/kernel-per-CPU-kthreads.txt
|
|
|
|
echo 3 > /proc/sys/vm/drop_caches
|
|
|
|
echo 1 > /proc/sys/vm/compact_memory
|
|
|
|
# the kernel's dirty page writeback mechanism uses kthread workers. They introduce
|
|
|
|
# massive arbitrary latencies when doing disk writes on the host and aren't
|
|
|
|
# migrated by cset. Restrict the workqueue to use only cpu 0.
|
|
|
|
echo $HOST_CORES_MASK > /sys/bus/workqueue/devices/writeback/cpumask
|
|
|
|
echo $HOST_CORES_MASK > /sys/devices/virtual/workqueue/cpumask
|
|
|
|
echo "C0" | tee /sys/devices/virtual/workqueue/*/cpumask
|
|
|
|
# THP can allegedly result in jitter. Better keep it off.
|
|
|
|
echo never > /sys/kernel/mm/transparent_hugepage/enabled
|
|
|
|
# Force P-states to P0
|
|
|
|
echo "Setting governor on all cores:"
|
|
|
|
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
|
|
|
echo 0 > /sys/bus/workqueue/devices/writeback/numa
|
|
|
|
echo 0 > /proc/sys/kernel/watchdog
|
|
|
|
echo 300 > /proc/sys/vm/stat_interval
|
|
|
|
|
2022-01-14 01:14:54 +00:00
|
|
|
# For single GPU passthrough
|
|
|
|
# Unbind VTconsoles
|
|
|
|
echo 0 > /sys/class/vtconsole/vtcon0/bind
|
|
|
|
echo 0 > /sys/class/vtconsole/vtcon1/bind
|
|
|
|
# Unbind EFI-Framebuffer
|
|
|
|
echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind
|
2019-11-02 20:35:55 +00:00
|
|
|
|