base-files: flush kernel memory cache during sysupgrade
authorHannu Nyman <hannu.nyman@iki.fi>
Tue, 24 Nov 2020 06:39:48 +0000 (08:39 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 22 Dec 2020 17:59:10 +0000 (18:59 +0100)
Flush kernel memory caches during sysupgrade in order
to mitigate the impact from memory consumption spikes
in low-RAM devices.

This may help to prevent sysupgrade causing a reboot
before the actual flashing starts.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
package/base-files/files/lib/upgrade/common.sh
package/base-files/files/lib/upgrade/stage2

index a5c27dc2fbb63d9d5be8202f4ddc147a083b62dd..b44a5998f4e5fa77fbc56c0f0fd1edf4ac4a5787 100644 (file)
@@ -297,6 +297,7 @@ indicate_upgrade() {
 # $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m
 default_do_upgrade() {
        sync
+       echo 3 > /proc/sys/vm/drop_caches
        if [ -n "$UPGRADE_BACKUP" ]; then
                get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j "$UPGRADE_BACKUP" write - "${PART_NAME:-image}"
        else
index c7629c383f3cbd9b8a44fe85c22f15db46dc50e1..23d356a447fa3b94c386e26792ecd3913a9bb6c0 100755 (executable)
@@ -123,6 +123,7 @@ kill_remaining KILL 1
 
 sleep 1
 
+echo 3 > /proc/sys/vm/drop_caches
 
 if [ -n "$IMAGE" ] && type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then
        platform_pre_upgrade "$IMAGE"