core: add support for setting CPUAffinity= to special "numa" value

systemd will automatically derive CPU affinity mask from NUMA node
mask.

Fixes #13248
This commit is contained in:
Michal Sekletár
2020-03-16 08:57:28 +01:00
parent 1808f76870
commit e2b2fb7f56
9 changed files with 125 additions and 13 deletions
+18
View File
@@ -279,6 +279,18 @@ else
# Maks must be ignored
grep -E "set_mempolicy\((MPOL_LOCAL|0x4 [^,]*), NULL" $straceLog
echo "Unit file CPUAffinity=NUMA support"
writeTestUnitNUMAPolicy "bind" "0"
echo "CPUAffinity=numa" >> $testUnitNUMAConf
systemctl daemon-reload
systemctl start $testUnit
systemctlCheckNUMAProperties $testUnit "bind" "0"
pid=$(systemctl show --value -p MainPID $testUnit)
cpulist=$(cat /sys/devices/system/node/node0/cpulist)
affinity_systemd=$(systemctl show --value -p CPUAffinity $testUnit)
[ $cpulist = $affinity_systemd ]
pid1StopUnit $testUnit
echo "systemd-run NUMAPolicy support"
runUnit='numa-systemd-run-test.service'
@@ -309,6 +321,12 @@ else
systemd-run -p NUMAPolicy=local -p NUMAMask=0 --unit $runUnit sleep 1000
systemctlCheckNUMAProperties $runUnit "local" ""
pid1StopUnit $runUnit
systemd-run -p NUMAPolicy=local -p NUMAMask=0 -p CPUAffinity=numa --unit $runUnit sleep 1000
systemctlCheckNUMAProperties $runUnit "local" ""
systemctl cat $runUnit | grep -q 'CPUAffinity=numa'
pid1StopUnit $runUnit
fi
# Cleanup