|
|
383d26 |
#!/bin/bash
|
|
|
383d26 |
|
|
|
383d26 |
kvm_setup_powerpc () {
|
|
|
383d26 |
isPowerNV=no
|
|
|
383d26 |
isPOWER8=no
|
|
|
383d26 |
|
|
|
383d26 |
grep -q '^platform[[:space:]]*:[[:space:]]*PowerNV' /proc/cpuinfo && isPowerNV=yes
|
|
|
383d26 |
grep -q '^cpu[[:space:]]*:[[:space:]]*POWER8' /proc/cpuinfo && isPOWER8=yes
|
|
|
383d26 |
|
|
|
383d26 |
if [ "$isPowerNV" = "yes" ] ; then
|
|
|
383d26 |
# PowerNV platform, which is KVM HV capable
|
|
|
383d26 |
|
|
|
383d26 |
if [ -z "$SUBCORES" ]; then
|
|
|
383d26 |
SUBCORES=1
|
|
|
383d26 |
fi
|
|
|
383d26 |
|
|
|
383d26 |
# Step 1. Load the KVM HVmodule
|
|
|
383d26 |
if ! modprobe -b kvm_hv; then
|
|
|
383d26 |
return
|
|
|
383d26 |
fi
|
|
|
383d26 |
|
|
|
383d26 |
# On POWER8 a host core can only run threads of a single
|
|
|
383d26 |
# guest, meaning that SMT must be disabled on the host in
|
|
|
383d26 |
# order to run KVM guests. (Also applieds to POWER7, but we
|
|
|
383d26 |
# don't support that).
|
|
|
383d26 |
#
|
|
|
383d26 |
# Additionally, POWER8 guests can't benefit from transparent
|
|
|
383d26 |
# hugepages used to back them, and THPs allocated by any app
|
|
|
383d26 |
# can potentially interfere with HPT allocation (if they
|
|
|
383d26 |
# become locked, they can fragment the CMA). So, also disable
|
|
|
383d26 |
# THPs system wide.
|
|
|
383d26 |
#
|
|
|
383d26 |
# POWER9 doesn't have this limitation (though it will for hash
|
|
|
383d26 |
# guests on radix host when that's implemented). So, only set
|
|
|
383d26 |
# up subcores and disable SMT for POWER*.
|
|
|
383d26 |
if [ "$isPOWER8" = "yes" ] ; then
|
|
|
383d26 |
# Step 2. Configure subcore mode
|
|
|
383d26 |
/usr/sbin/ppc64_cpu --subcores-per-core=$SUBCORES
|
|
|
383d26 |
|
|
|
383d26 |
# Step 3. Disable SMT (multithreading)
|
|
|
383d26 |
/usr/sbin/ppc64_cpu --smt=off
|
|
|
383d26 |
|
|
|
383d26 |
# Step 4. Disable transparent hugepages (THP)
|
|
|
383d26 |
echo never > /sys/kernel/mm/transparent_hugepage/enabled
|
|
|
383d26 |
fi
|
|
|
383d26 |
fi
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
case $(uname -m) in
|
|
|
383d26 |
ppc64|ppc64le)
|
|
|
383d26 |
kvm_setup_powerpc
|
|
|
383d26 |
;;
|
|
|
383d26 |
esac
|
|
|
383d26 |
|
|
|
383d26 |
exit 0
|