First push
parent
ea4a42a354
commit
180c82376f
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MEMORY=24576
|
||||||
|
## Calculate number of hugepages to allocate from memory (in MB)
|
||||||
|
HUGEPAGES="$(($MEMORY/$(($(grep Hugepagesize /proc/meminfo | awk '{print $2}')/1024))))"
|
||||||
|
## Node to allocate on (node1 for this VM)
|
||||||
|
NODESPATH=/sys/devices/system/node/node1
|
||||||
|
|
||||||
|
echo "Allocating hugepages..."
|
||||||
|
echo $HUGEPAGES > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages)
|
||||||
|
|
||||||
|
TRIES=0
|
||||||
|
while (( $ALLOC_PAGES != $HUGEPAGES && $TRIES < 1000 ))
|
||||||
|
do
|
||||||
|
echo 1 > /proc/sys/vm/compact_memory ## defrag ram
|
||||||
|
echo $HUGEPAGES > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages)
|
||||||
|
echo "Succesfully allocated $ALLOC_PAGES / $HUGEPAGES"
|
||||||
|
let TRIES+=1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ALLOC_PAGES" -ne "$HUGEPAGES" ]
|
||||||
|
then
|
||||||
|
echo "Not able to allocate all hugepages. Reverting..."
|
||||||
|
echo 0 > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
echo 0 > /proc/sys/vm/nr_hugepages
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
MEMORY=32768
|
||||||
|
SSDADDRESS=0000:04:00.0
|
||||||
|
|
||||||
|
## Calculate number of hugepages to allocate from memory (in MB)
|
||||||
|
HUGEPAGES="$(($MEMORY/$(($(grep Hugepagesize /proc/meminfo | awk '{print $2}')/1024))))"
|
||||||
|
## Node to allocate on (node1 for this VM)
|
||||||
|
NODESPATH=/sys/devices/system/node/node1
|
||||||
|
|
||||||
|
# BIND SSD
|
||||||
|
echo $SSDADDRESS > /sys/bus/pci/devices/$SSDADDRESS/driver/unbind
|
||||||
|
echo $SSDADDRESS > /sys/bus/pci/drivers/vfio-pci/bind
|
||||||
|
|
||||||
|
echo "Allocating hugepages..."
|
||||||
|
echo $HUGEPAGES > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages)
|
||||||
|
|
||||||
|
TRIES=0
|
||||||
|
while (( $ALLOC_PAGES != $HUGEPAGES && $TRIES < 10000 ))
|
||||||
|
do
|
||||||
|
echo 1 > /proc/sys/vm/compact_memory ## defrag ram
|
||||||
|
echo $HUGEPAGES > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages)
|
||||||
|
echo "Succesfully allocated $ALLOC_PAGES / $HUGEPAGES"
|
||||||
|
let TRIES+=1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ALLOC_PAGES" -ne "$HUGEPAGES" ]
|
||||||
|
then
|
||||||
|
echo "Not able to allocate all hugepages. Reverting..."
|
||||||
|
echo 0 > $NODESPATH/hugepages/hugepages-2048kB/nr_hugepages
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# libvirt likes to create a cpuset called "machine" and leave it behind after closing
|
||||||
|
# this confuses cset. remove it just in case
|
||||||
|
rmdir /sys/fs/cgroup/cpuset/machine
|
||||||
|
|
||||||
|
# reserve cpu 0,4 (core 0) for the host and give 1-3,5-7 (core 1-3) to the guest/vm
|
||||||
|
cset shield --kthread on --cpu 14-27,42-55
|
||||||
|
|
||||||
|
# cset reserves the cpusets for exclusive use but libvirt also wants to create
|
||||||
|
# new cpusets containing the same cpus. Remove the exclusive flag.
|
||||||
|
echo 0 > /sys/fs/cgroup/cpuset/system/cpuset.cpu_exclusive
|
||||||
|
echo 0 > /sys/fs/cgroup/cpuset/user/cpuset.cpu_exclusive
|
||||||
|
|
||||||
|
# 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 1 > /sys/devices/virtual/workqueue/cpumask
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
sysctl vm.stat_interval=1
|
||||||
|
sysctl -w kernel.watchdog=1
|
||||||
|
echo 1 > /sys/bus/workqueue/devices/writeback/numa
|
||||||
|
echo 0 > /proc/sys/vm/nr_hugepages
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MEMORY=98304
|
||||||
|
|
||||||
|
## Calculate number of hugepages to allocate from memory (in MB)
|
||||||
|
HUGEPAGES="$(($MEMORY/$(($(grep Hugepagesize /proc/meminfo | awk '{print $2}')/1024))))"
|
||||||
|
|
||||||
|
echo "Allocating hugepages..."
|
||||||
|
echo $HUGEPAGES > /proc/sys/vm/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat /proc/sys/vm/nr_hugepages)
|
||||||
|
|
||||||
|
TRIES=0
|
||||||
|
while (( $ALLOC_PAGES != $HUGEPAGES && $TRIES < 1000 ))
|
||||||
|
do
|
||||||
|
echo 1 > /proc/sys/vm/compact_memory ## defrag ram
|
||||||
|
echo $HUGEPAGES > /proc/sys/vm/nr_hugepages
|
||||||
|
ALLOC_PAGES=$(cat /proc/sys/vm/nr_hugepages)
|
||||||
|
echo "Succesfully allocated $ALLOC_PAGES / $HUGEPAGES"
|
||||||
|
let TRIES+=1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ALLOC_PAGES" -ne "$HUGEPAGES" ]
|
||||||
|
then
|
||||||
|
echo "Not able to allocate all hugepages. Reverting..."
|
||||||
|
echo 0 > /proc/sys/vm/nr_hugepages
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
echo 0 > /proc/sys/vm/nr_hugepages
|
Loading…
Reference in New Issue