From patchwork Mon Sep 5 08:15:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A235C6FA89 for ; Mon, 5 Sep 2022 08:16:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A0F801BA; Mon, 5 Sep 2022 04:16:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2E1801B3; Mon, 5 Sep 2022 04:16:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66B59801BA; Mon, 5 Sep 2022 04:16:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 50D4A801B3 for ; Mon, 5 Sep 2022 04:16:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 28C9F120D74 for ; Mon, 5 Sep 2022 08:16:07 +0000 (UTC) X-FDA: 79877323974.11.713ACEB Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf05.hostedemail.com (Postfix) with ESMTP id DC89B100073 for ; Mon, 5 Sep 2022 08:16:06 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso11507448pjk.0 for ; Mon, 05 Sep 2022 01:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ARMalt43cGQStsEP0fAYz16MOL60Ugpll7VhrHzWrN4=; b=R+L49dA4rCLdsc7mxoe36IKYzPKwp674LNy6oPrFh7m3bvbFXZJam6MTSuP+TEv+7O RDt8LqRmhtESdpQ0NcPJVGt4LuFExGMVjIKpmk81fOLo0FOILv/2L9t/HMuwZ8gvsMXf YdXBbfIzzwwM4mV5+OYIRZqB74ePC76ye0OsY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ARMalt43cGQStsEP0fAYz16MOL60Ugpll7VhrHzWrN4=; b=oaUVzJ+0e9iIrNQk1O2Ny9k+1omkVVHrwWu5en6+dHi+B1pD1uXfzakL36Jq+TAOgJ VbP+EvP6MfO3uGu8TVib3lU0UtVmMy0qQ0tenRR/It/7O7e1/gGWTaH5hQiCU66FpSEv 7x3M7DbC8wIvSz1WHlWDqBtS5Dz+ykHrlxn0RNotj99qlEiPIToCRh3G5yfgPrrl9qo+ ii/dW+oAV1AoclGmuXbV3oO1ArAZZZY3DG5F9TXSYIJATxOYbK+5857b9NXqaqa8sLVZ UNZTkLSs2Zd6H+4srXCtXyO7+gJdx7C1fD5CJ28MAPo9/7ydxV/czyXsikzRXFQcFiRn WKLA== X-Gm-Message-State: ACgBeo1W9RTKW1gqhVyzpnM4O2fwucDxgxNHqg/CwcVAKWx5KuPiC63v jZ2Edb90TsSnvm11tMesnSfZ6Q== X-Google-Smtp-Source: AA6agR7FJso6bnfvHqRxrl2G7vqu3sL7hSJiUx3LVxSxhi7XTb8chbTy7Se1vSlNdxTZto4tDiFwiQ== X-Received: by 2002:a17:902:c949:b0:172:e3c3:bdeb with SMTP id i9-20020a170902c94900b00172e3c3bdebmr47860330pla.80.1662365765853; Mon, 05 Sep 2022 01:16:05 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:71e2:8444:42d9:4bb0]) by smtp.gmail.com with ESMTPSA id w12-20020aa79a0c000000b005363bc65bafsm7075864pfj.57.2022.09.05.01.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:16:05 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH 1/3] documentation: Add recompression documentation Date: Mon, 5 Sep 2022 17:15:43 +0900 Message-Id: <20220905081552.2740917-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220905081552.2740917-1-senozhatsky@chromium.org> References: <20220905081552.2740917-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662365766; a=rsa-sha256; cv=none; b=CbcGE43LmvwIpVRiQdSn143s5vA4D6Lupm/tGh8TKAt0AR+feu8B088Z9/RrfdZ72VEcpm 8KoScIEptaDvB0M9PYhbKmxiXaktYPyouSXHrvUMcvwhgdXATN3h11qt/JOP6FZm6YGrW+ W8DOrCrSIwZHZArz+IS0ve3HRVFLn+4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=R+L49dA4; spf=pass (imf05.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.53 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662365766; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ARMalt43cGQStsEP0fAYz16MOL60Ugpll7VhrHzWrN4=; b=nN6EkgTuejbpkirWDs5ThjpeH5ar6Wrw863ck6zRNYSbFl86ynxT4VYsWE/zwVJyyzu4hz MpTGZFnhNjCZMOq4nAWBu3bWXTXqdjQotXyNSCcmWFWh/EsVlbM2T7fr5YcIxLoyaqozX4 +m1H0N8h4eexwUGSoMbqeU/43V9LyN8= X-Stat-Signature: 6jgp7g355hf55qmh1obinmf18mfwfbtp X-Rspamd-Queue-Id: DC89B100073 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=R+L49dA4; spf=pass (imf05.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.53 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1662365766-608407 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Document user-space visible device attributes that are enabled by ZRAM_MULTI_COMP. Signed-off-by: Sergey Senozhatsky --- Documentation/admin-guide/blockdev/zram.rst | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Documentation/admin-guide/blockdev/zram.rst b/Documentation/admin-guide/blockdev/zram.rst index c73b16930449..88957fcb6ad7 100644 --- a/Documentation/admin-guide/blockdev/zram.rst +++ b/Documentation/admin-guide/blockdev/zram.rst @@ -401,6 +401,61 @@ budget in next setting is user's job. If admin wants to measure writeback count in a certain period, they could know it via /sys/block/zram0/bd_stat's 3rd column. +recompression +------------- + +With CONFIG_ZRAM_MULTI_COMP, zram can recompress idle/huge pages using +alternative (secondary) compression algorithm. The basic idea is that +alternative compression algorithm can provide better compression ratio +at a price of (potentially) slower compression/decompression speeds. +Alternative compression algorithm can, for example, be more successful +compressing huge pages (those that default algorithm failed to compress). +Another application is idle pages recompression - pages that are cold and +sit in the memory can be recompressed using more effective algorithm and, +hence, reduce zsmalloc memory usage. + +With CONFIG_ZRAM_MULTI_COMP, zram will setup two compression algorithms +per-CPU: primary and secondary ones. Primary zram compressor is explained +in "3) Select compression algorithm", the secondary algorithm is configured +in a similar way, using recomp_algorithm device attribute: + +Examples:: + + #show supported recompression algorithms + cat /sys/block/zramX/recomp_algorithm + zstd [lzo] + + #select zstd recompression algorithm + echo zstd > /sys/block/zramX/recomp_algorithm + +Another device attribute that CONFIG_ZRAM_MULTI_COMP enables is recompress, +which controls recompression: + +Examples:: + + #IDLE pages recompression is activated by `idle` mode + echo idle > /sys/block/zramX/recompress + + #HUGE pages recompression is activated by `huge` mode + echo huge > /sys/block/zram0/recompress + + #HUGE_IDLE pages recompression is activated by `huge_idle` mode + echo huge_idle > /sys/block/zramX/recompress + +The number of idle pages can be significant, so user-space can pass a size +watermark value to the recompress knob, to filter out idle pages for +recompression: zram will recompress only idle pages of equal or greater +size::: + + #recompress idle pages larger than 3000 bytes + echo 3000 > /sys/block/zramX/recompress + + #recompress idle pages larger than 2000 bytes + echo 2000 > /sys/block/zramX/recompress + +Recompression is mostly focused on idle pages (except for huge pages +recompression), so it works better in conjunction with memory tracking. + memory tracking ===============