From patchwork Mon Sep 5 08:23:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965772 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 78DB6ECAAD5 for ; Mon, 5 Sep 2022 08:23:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2026B801C8; Mon, 5 Sep 2022 04:23:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B31F8D0050; Mon, 5 Sep 2022 04:23:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07A2E801C8; Mon, 5 Sep 2022 04:23:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EDB288D0050 for ; Mon, 5 Sep 2022 04:23:46 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C729AC02D9 for ; Mon, 5 Sep 2022 08:23:46 +0000 (UTC) X-FDA: 79877343252.17.DA92AC0 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf15.hostedemail.com (Postfix) with ESMTP id 8577DA0063 for ; Mon, 5 Sep 2022 08:23:46 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id f24so7873591plr.1 for ; Mon, 05 Sep 2022 01:23:46 -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=AbhuZG4cLnD4jAtfo2ZO07aIOwcJJvwIZESzjpZ5Ee+82ZNdfngwPfiuw6v9PXi/eR /BxJ0orFnk5MpMZv+Y+LnbYJFKUzam+yFwSFhDCiAYDY6+eOU2UMsM9y+K0yq02gvGO5 3LeNv89oR7dUBGGFpFwPExYtdVrQijvYiu+Lo= 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=PVkNs1f7nGUp3uuOd2YntqDyZMy85Kyy4qT7f5LEhdZXv28nI9YMZ7Zwa4KRWijW0x n8qZ5Qx6lLz6NfN2V5fF4G9w1CXKElTB+m9vTkEhLpgjYLxsgHnpF5zt6iEHwUBbyHSA J5k/eyUrNiV3HzEUv0b2KoBw+cYZK1KeOfIinEHuHh8BbUuHOiCfEsS7mEiN5G2WRZ8y SIJxqxt3sv4CTx4hqMaeXlb+X8j7H45XiGDlLNDVB3kN4ClEcx2svld6SFqvhNE951c6 SlEuia8Jkak13PLP8xXbIW8F6qjm8/lRW1bgzb5+6x7qo343QKIcub/7b0i+kDCbwUU2 Br8Q== X-Gm-Message-State: ACgBeo1tcb0dBKUZF/3/uPPl2K3EMG3H0yuCOMHAaz87pnOp0m91J6fB TZQrxtne2pRsvCW80RRvN9N51Q== X-Google-Smtp-Source: AA6agR6MdV0jQOWw7gPUNPTuBQ7N8UC1YJh59UXImF2+oeIhZoDkkXTWCLMASpJ6FNqJ5k4s2QvS5A== X-Received: by 2002:a17:90b:1652:b0:1fd:eca8:d2be with SMTP id il18-20020a17090b165200b001fdeca8d2bemr18456213pjb.79.1662366225603; Mon, 05 Sep 2022 01:23:45 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:71e2:8444:42d9:4bb0]) by smtp.gmail.com with ESMTPSA id p14-20020a170902e74e00b001641b2d61d4sm6807093plf.30.2022.09.05.01.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:23:44 -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 RFC 5/7] documentation: Add recompression documentation Date: Mon, 5 Sep 2022 17:23:21 +0900 Message-Id: <20220905082323.2742399-6-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220905082323.2742399-1-senozhatsky@chromium.org> References: <20220905082323.2742399-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=AbhuZG4c; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.181 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662366226; a=rsa-sha256; cv=none; b=HH/Ba9FZF8NKTIYqSZQfFxByPgqfoRhwjh8q7W/BLSBJ3mffpCRzcF0VxQaw8EPSXuO+zG vps7pRNEBtVKIlyI95rfJUI1UbD1vTpTdXV2PJKRaQGvC9pey9MOOooFoYdOcMbZI+DM/M CKwfMSSVfLDtel7DEz0UdUoyrt/oT3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662366226; 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=SrXZhwozV6qfEZRiewa77xbKHTySG5GjL3Ak6ZNpD7LuihTyotJqg6PdY1vn+YEZPV4Seg VSeXu1RaC+BHqs5qg4//eshjIsnKgAyruMczOvZY2rTPaQl0nQAY37fs4wsxlSTNXn5zZ6 PyXi0MhRzjaKebzSIzgO9Bft5ikc0f4= X-Stat-Signature: ts46ajpcz1juopnxqua6nz83t1hebano X-Rspamd-Queue-Id: 8577DA0063 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=AbhuZG4c; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.181 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam07 X-HE-Tag: 1662366226-624281 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 ===============