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