From patchwork Thu Jul 30 12:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Salvaterra X-Patchwork-Id: 1338807 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=fail (p=none dis=none) header.from=gmail.com 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=gv+GZqH1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KlVWUXYP; 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 4BHVfs370Lz9sR4 for ; Thu, 30 Jul 2020 22:52:05 +1000 (AEST) 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=4f3LF9/NSwB4ukD08o0HAPsHira3Q/l8I9gVSevOIJw=; b=gv+GZqH1YfW2S6QQCD9/L3jPoT rZrdURDUWmF1ioEASjzItocxNUl6w7XM2VGau0YPTD7cWcb1JpCyHJof3bGWH6M+nZDNNFAD+meQk oRREpY0jOdjaaMDcY16sCZ8qf42FNAsCz1SfghGFWub8e1e1doqRprwCJj1iAoE07fXsm9BCTkXsD ZF8xrOmv043LKzYeuuKuexSJ+JOFZiw1WH27b7eF7JF4dUUbxHL7qJ+0vB1D8VAC7hJMX1+L33VqL 1Yub1jv9ggj7BRqX4pM+TaauiSue6K57eTsIpz9kL1OPqpGe//q8z1sB0dzPGjQ7RTzrfDEAmsNrl qjp5pRag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1813-0006Rb-Rh; Thu, 30 Jul 2020 12:50:33 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1812-0006Qk-2P for openwrt-devel@lists.openwrt.org; Thu, 30 Jul 2020 12:50:32 +0000 Received: by mail-pl1-x641.google.com with SMTP id u10so4524183plr.7 for ; Thu, 30 Jul 2020 05:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+PqbRIdJ56EBNCjElaBThkajvc30CAbAq6M9KNeXukI=; b=KlVWUXYP562Zrev4lUGGPTRO9W5Oy6SFaPZNYetYGEtKxwzdYV4LsATJFHpaB76Hpa smC9XT8KevrCkov9epGmsLFjz+w9wzG7Xm4Hmr2gZhYHol9/gyPaUSxy0HQ3KZ6ZAO7J KuA5m1GPwLfWCW2QrXFFAxDkqaGrzE+pu65CclEYXbMGE2k8QMzvIidqCJHhfcfahEgz 9E/rlsUYzQZAmopzndEJbSjxViGj7sFUVWDDhd3uHgZfmN8itCG9Hmu+/Fw/VzaqxT3y Tv6kIAT86i9LXuNmoOeQ8RIUJT19AYTVfPEiJYmAxJubMoEFeH9RLyt18IpzEghiWT8p TdvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+PqbRIdJ56EBNCjElaBThkajvc30CAbAq6M9KNeXukI=; b=V6yRQd70YoW3RcC358/ZibjrZ1fNUYGOqyvys7bQo5UW5feU+1F0aMHLlZFTpNr+Qz C4tzR4kWPEnhKM0ZJfQIornkwplOoq3iDex9iWgHtdN+qQtAWjYn6VDz7RK5Lnlrx2Tv JHLT/2Y8BpcGJ2gylGgTrtUoZwHxy2JAXgJMTLUFRup5k28rcmWMYpgiWJzMIEICNNJr FtBn83VjgLZgDnyDkJMeffM9c9La2lHybBbZI6N/D4Xl6j5aPWnOzg/Qu2YjoD1JiBcw cq2Gw2WxeoUsw5JqrFPh/GbaE3crjF1zZLxzz9xAvhqo0I3QBLuMLSCqzi2emCGdKmUN aI3g== X-Gm-Message-State: AOAM530YdEPq4rtNx3N2hAhQqGs+GHAUIAXjylDJhR49cgOTM1A4dVSH hmj6oSsQ1WzIG+lACAxtkY2iizOvJQ== X-Google-Smtp-Source: ABdhPJwOiIz+4TBH7IxmSsFoSC3QCYAfFw/Rtc+VPPvM0KLlVjC9ssGrVdr91XFpS30fzOFea6wAHA== X-Received: by 2002:a17:902:7292:: with SMTP id d18mr32047935pll.137.1596113428663; Thu, 30 Jul 2020 05:50:28 -0700 (PDT) Received: from presler.lan (a109-49-6-66.cpe.netcabo.pt. [109.49.6.66]) by smtp.gmail.com with ESMTPSA id t11sm6190156pfh.35.2020.07.30.05.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 05:50:28 -0700 (PDT) From: Rui Salvaterra To: openwrt-devel@lists.openwrt.org Subject: [PATCH] zram-swap: default to lzo instead of lzo-rle compression Date: Thu, 30 Jul 2020 13:49:18 +0100 Message-Id: <20200730124917.199164-1-rsalvaterra@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_085032_130056_B28197D5 X-CRM114-Status: GOOD ( 12.57 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rsalvaterra[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: Rui Salvaterra Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org On devices with small amounts of RAM, zram-swap fails to initialise due to the default compression algorithm (lzo-rle). Startup example on an AirGrid M2, with 32 MiB of RAM: root@airgrid:/etc/config# /etc/init.d/zram start zram_start: activating '/dev/zram0' for swapping (13 MegaBytes) zram_reset: enforcing defaults via /sys/block/zram0/reset sh: write error: Out of memory mkswap: image is too small swapon: /dev/zram0: Invalid argument root@airgrid:/etc/config# Fix this by defaulting to traditional lzo, which works fine and is always available. Signed-off-by: Rui Salvaterra --- package/system/zram-swap/files/zram.init | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index f31a87438c..a42f019d92 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -85,8 +85,9 @@ zram_comp_algo() local dev="$1" local zram_comp_algo="$( uci -q get system.@system[0].zram_comp_algo )" - if [ -z "$zram_comp_algo" ] || [ ! -e /sys/block/$( basename $dev )/comp_algorithm ]; then - return 0 + if [ -z "$zram_comp_algo" ]; then + # lzo-rle fails on small RAM devices, default to lzo, which is always available + zram_comp_algo="lzo" fi if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then