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