feat(darwin): check if SMT is enabled on darwin
This commit is contained in:
parent
e1ee983245
commit
c30c4612b5
18
quickemu
18
quickemu
|
@ -315,9 +315,23 @@ function configure_cpu() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Account for Hyperthreading/SMT.
|
if [ ${DARWIN} -eq 1 ]; then
|
||||||
if [ -e /sys/devices/system/cpu/smt/control ] && [ "${GUEST_CPU_CORES}" -ge 2 ]; then
|
# Get the number of physical cores
|
||||||
|
physicalcpu=$(sysctl -n hw.physicalcpu)
|
||||||
|
# Get the number of logical processors
|
||||||
|
logicalcpu=$(sysctl -n hw.logicalcpu)
|
||||||
|
# Check if Hyper-Threading is enabled
|
||||||
|
if [ "${logicalcpu}" -gt "${physicalcpu}" ]; then
|
||||||
|
HOST_CPU_SMT="on"
|
||||||
|
else
|
||||||
|
HOST_CPU_SMT="off"
|
||||||
|
fi
|
||||||
|
elif [ -e /sys/devices/system/cpu/smt/control ]; then
|
||||||
HOST_CPU_SMT=$(cat /sys/devices/system/cpu/smt/control)
|
HOST_CPU_SMT=$(cat /sys/devices/system/cpu/smt/control)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Account for Hyperthreading/SMT.
|
||||||
|
if [ "${GUEST_CPU_CORES}" -ge 2 ]; then
|
||||||
case ${HOST_CPU_SMT} in
|
case ${HOST_CPU_SMT} in
|
||||||
on) GUEST_CPU_THREADS=2
|
on) GUEST_CPU_THREADS=2
|
||||||
GUEST_CPU_LOGICAL_CORES=$(( GUEST_CPU_CORES / GUEST_CPU_THREADS ));;
|
GUEST_CPU_LOGICAL_CORES=$(( GUEST_CPU_CORES / GUEST_CPU_THREADS ));;
|
||||||
|
|
Loading…
Reference in New Issue