building-notes: Use bc instead of bash built-in for converting GB to B

It's more readable.

Also add an explanation about 2^30.
This commit is contained in:
Xi Ruoyao 2023-09-19 03:54:04 +08:00
parent 33c1959ae0
commit 087dc222a5
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3

View File

@ -364,7 +364,7 @@ systemd-run --user --pty --pipe --wait -G -d \
sudo sh -c \
"echo 0-3 > /sys/fs/cgroup/$$/cpuset.cpus"
sudo sh -c \
"echo $((8 << 30)) > /sys/fs/cgroup/$$/memory.high"
"echo $(bc -e '8*2^30') > /sys/fs/cgroup/$$/memory.high"
(
sudo sh -c "echo $BASHPID > /sys/fs/cgroup/$$/cgroup.procs"
exec make -j5
@ -378,8 +378,9 @@ EOF</userinput></screen>
<parameter>MemoryHigh=8G</parameter>
</phrase>
<phrase revision='sysv'>
<literal>8589934592</literal> (expanded from
<userinput>$((8 &lt;&lt; 30))</userinput>) in the
<literal>8589934592</literal> (the output of
<userinput>bc -e '8*2^30'</userinput>, 2^30 represents
2<superscript>30</superscript>, i.e. a Gigabyte) in the
<filename>memory.high</filename> entry
</phrase>, a soft limit of memory usage is set.
If the processes in the cgroup (<command>make</command> and all the