aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-10-03 13:01:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-10-04 06:17:08 +0200
commit899741eefb59f4d368324a618cc7c79092373d51 (patch)
treed989df6e8b12edbd59c1f1658c35617b163b400c
parentd00dbc029fa41ba93e088d11c5ec82dcd5119feb (diff)
Add support for buildos.ram_total, buildos.cpu_affinity
-rwxr-xr-xbuildos26
1 files changed, 20 insertions, 6 deletions
diff --git a/buildos b/buildos
index 9808719..6510977 100755
--- a/buildos
+++ b/buildos
@@ -229,13 +229,17 @@ fi
# And to make it easier to provision memory it's really helpful to base it
# on the physical value.
#
-ram_total=0
-for i in $(sudo dmidecode -t 17 | sed -n -re 's/^\s*Size:\s*([0-9]+)\s*GB.*$/\1/p'); do
- ram_total=$(($ram_total + $i * 1024 * 1024))
-done
+if [ -z "$ram_total" ]; then
+ ram_total=0
+ for i in $(sudo dmidecode -t 17 | sed -n -re 's/^\s*Size:\s*([0-9]+)\s*GB.*$/\1/p'); do
+ ram_total=$(($ram_total + $i * 1024 * 1024))
+ done
-if [ "$ram_total" -eq 0 ]; then
- error "unable to determine physical memory size"
+ if [ "$ram_total" -eq 0 ]; then
+ error "unable to determine physical memory size, use buildos.ram_total to specify"
+ fi
+else
+ ram_total=$(($ram_total * 1024 * 1024))
fi
cpu_total="$(lscpu | sed -n -re 's/^CPU\(s\): *([0-9]+)$/\1/p')"
@@ -277,6 +281,9 @@ function print ()
echo "cpu_reserved: $cpu_reserved"
echo "cpu_overcommit: $cpu_overcommit"
echo "cpu_slice: $cpu_slice"
+ if [ -n "$cpu_affinity" ]; then
+ echo "cpu_affinity: $cpu_affinity"
+ fi
echo
echo "ram_total: $ram_total KB"
@@ -921,6 +928,13 @@ function bbot_start () # <toolchain-name> <toolchain-index>
-e "s#^ExecStart=[^ ]+(.*)#ExecStart=$id/bin/bbot-agent\1#" \
"$id/lib/systemd/system/bbot-agent@.service"
+ # Patch in CPU affinity.
+ #
+ if [ -n "$cpu_affinity" ]; then
+ sed -i -r -e "s/^(CPUAffinity)=.*/\1=$cpu_affinity/" \
+ "$id/lib/systemd/system/bbot-agent@.service"
+ fi
+
# Patch in build/bootstrap/interactive timeouts.
#
if [ -n "$tbt" ]; then