summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-12-17 19:13:34 +0100
committerTails developers <amnesia@boum.org>2013-01-23 15:13:51 +0100
commitffc8e1d34cccbc04dfa7e117103345c0529cb497 (patch)
tree6bcff1dffa68ae5a527eb4e7a719fdd316ba36b1
parentca7f1127120627691a3f684d3860d9958d936a36 (diff)
Make parallel sdmem faster.
We avoid running too many parallel instances (which adds overhead) by only running one instance per 2048 MiB of RAM (which is below the x86 per-process limitation). This also seems to play better with VirtualBox, which often hangs when running too many sdmem in parallel. Furthermore we kill all sdmem instances as soon as one of them has been oom killed; after all, that implies that the memory has been completely filled, so we're done. If we don't kill the others they may continue running unecessarily, filling the freed memory of the killed instance, and so on. Another consequence of this is cleaner output so that the debug message (that memory dumping can ensue) will be easier to spot when running with boot option debug=wipemem. That will be a helpful cue for the automated test suite.
-rwxr-xr-xconfig/chroot_local-includes/usr/share/initramfs-tools/scripts/init-premount/sdmem12
1 files changed, 9 insertions, 3 deletions
diff --git a/config/chroot_local-includes/usr/share/initramfs-tools/scripts/init-premount/sdmem b/config/chroot_local-includes/usr/share/initramfs-tools/scripts/init-premount/sdmem
index ed95adc..a291ff7 100755
--- a/config/chroot_local-includes/usr/share/initramfs-tools/scripts/init-premount/sdmem
+++ b/config/chroot_local-includes/usr/share/initramfs-tools/scripts/init-premount/sdmem
@@ -29,9 +29,15 @@ if [ -n "${sdmem}" ] ; then
if [ -z "${sdmemopts}" ] ; then
sdmemopts="v"
fi
- for i in $(seq 0 30) ; do /usr/bin/sdmem "-${sdmemopts}" & done
- # Wait for at least one sdmem job to complete.
- /usr/bin/sdmem "-${sdmemopts}"
+ # We run one instance of sdmem per 2 GiB of RAM to deal with the
+ # x86 per-process memory limitation.
+ mem=$(free | awk '/Mem:/ { print $2 }')
+ instances=$((${mem}/(2*1024*1024)+1))
+ for i in $(seq 1 "${instances}") ; do
+ ( /usr/bin/sdmem "-${sdmemopts}" ; killall sdmem >/dev/null 2>&1 ) &
+ done
+ # Wait for sdmem jobs to finish.
+ wait
fi
if [ "${sdmemdebug}" = 1 ] ; then