From patchwork Tue Nov 24 06:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannu Nyman X-Patchwork-Id: 1405312 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=mJSRjPyo; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=C/Q8lVZb; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CgDwH727mz9sRR for ; Tue, 24 Nov 2020 17:42:23 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=vzsQizfzb4v6/uF1aBASlcigmaLVMgvllFFOfRl0h5c=; b=mJSRjPyoJXcQ6TtEWYCLxCYWoO K2IwdVKAC5aJQtwWyPSJIQRizg4eLPGrpEE+lr1cyU2rfaAS3/kVzETpExqdNodmEKOfid6TmVX2S 6CxJ8hsV4tL8FjcVoXgmRWlsU79Q1Mtfngv+LwxSlYxBR3Q9sd6NopNvIdzychUVl8GSGk7gr6nM2 /hUoozIYJVNldpjK5sWPn0xlWhIvZYoGul42VnMjxQxJ2QQ2HrOZUAJWTAxtqS++QYbmqXzD/QBlX wVYhuwwBe+X2YIXhcrr/k8YKq6ZsHxEIX9Tnca0EI2GjXEZfG+ihTRLF1t7uj6ruxBTYLm2/HpoW7 YLVZ5uQg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khRzu-0002Fs-MO; Tue, 24 Nov 2020 06:40:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khRzs-0002FZ-C0 for openwrt-devel@merlin.infradead.org; Tue, 24 Nov 2020 06:40:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=8m6pQ932Yq5Z5ooF44qL3btuSozPE8L9TLMky4u6XA8=; b=C/Q8lVZbSrnf0fJc9IB9TRpzSw jgH7xeXqXVyE6Br3aR1pD4qJwcbFBDr5F0RLkpUkZMi8EvlHZ712rSeW328+5NKzil9+3G2di1EX6 oYoc7v/B3xzM6+XY4MwKIfljlSWpsBMI0gRawlS5K7qaSxbNckYV90Qep0vjeSDwvsgnTOxngmyVl to9Crgc6B1inC9srMm6yLfeSI7YWARWQPAbdJfnW5j+9hSPRzVnOXDcF9bHSRtQvxDhV3rv+56fp3 rVyIyH9pgMSinns7qCvPHPyNDe2Fhla/98zq1A9xpvybSv6m3mXniH3VsISbcDBlvHw9twpXciwxq amzN9Zug==; Received: from welho-filter2b.welho.com ([83.102.41.28] helo=welho-filter2.welho.com) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khRzo-000615-I4 for openwrt-devel@lists.openwrt.org; Tue, 24 Nov 2020 06:40:15 +0000 Received: from localhost (localhost [127.0.0.1]) by welho-filter2.welho.com (Postfix) with ESMTP id 942ECD051C; Tue, 24 Nov 2020 08:39:59 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from welho-smtp2.welho.com ([IPv6:::ffff:83.102.41.85]) by localhost (welho-filter2.welho.com [::ffff:83.102.41.24]) (amavisd-new, port 10024) with ESMTP id BBtVoVcVtfiF; Tue, 24 Nov 2020 08:39:59 +0200 (EET) Received: from localhost.localdomain (78-27-113-81.bb.dnainternet.fi [78.27.113.81]) by welho-smtp2.welho.com (Postfix) with ESMTP id 04FC972; Tue, 24 Nov 2020 08:39:56 +0200 (EET) From: Hannu Nyman To: openwrt-devel@lists.openwrt.org Subject: [PATCH] base-files: flush kernel memory cache during sysupgrade Date: Tue, 24 Nov 2020 08:39:48 +0200 Message-Id: <20201124063948.3103-1-hannu.nyman@iki.fi> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201124_064012_847184_7638EF3E X-CRM114-Status: GOOD ( 10.34 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hannu Nyman Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org 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 --- I have noticed this to help in 64 MB WNDR3700v2, where sysupgrade typically has failed when the router has been running some time, but succeeded when sysupgrade is done right after a reboot. The cache flushing is non-destructive and as the router is going to sysupgrade, there aren't "long-term" performance issues. Reference to mailing list discussion in http://lists.openwrt.org/pipermail/openwrt-devel/2020-November/032266.html Kernel documentation: https://www.kernel.org/doc/Documentation/sysctl/vm.txt package/base-files/files/lib/upgrade/common.sh | 1 + package/base-files/files/lib/upgrade/stage2 | 1 + 2 files changed, 2 insertions(+) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index a5c27dc2fb..b44a5998f4 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -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 diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index c7629c383f..23d356a447 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -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"