From patchwork Mon Sep 5 08:15:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965754 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 0CDBEC6FA89 for ; Mon, 5 Sep 2022 08:16:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69465801C1; Mon, 5 Sep 2022 04:16:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61EDB801B3; Mon, 5 Sep 2022 04:16:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BD46801C1; Mon, 5 Sep 2022 04:16:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 345AA801B3 for ; Mon, 5 Sep 2022 04:16:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0BCAAAB61E for ; Mon, 5 Sep 2022 08:16:27 +0000 (UTC) X-FDA: 79877324814.01.078C678 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf06.hostedemail.com (Postfix) with ESMTP id BF0E8180060 for ; Mon, 5 Sep 2022 08:16:26 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id y127so7964018pfy.5 for ; Mon, 05 Sep 2022 01:16:26 -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=cQVKvubgWaoRbZYTjgiOV04EQaA+PJkhinoKlPFno51F4mzronmiF7U+mwYxvF4s3Q 5MM6S8ICClfNa3uBwdz8UY2mlEFwhSxCfGXTPdxqT8WWBu42rdP7LQcLzDKvyWW73kts Q8Wwk1DHyX5Ob0hWV2EYNohECRVz9LUuGJxkg= 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=Rq1ObX3oe0aSRipXd1MwNQINT/uYcNezZr/G9M/ZCHoWvOtigtx+4M7KLmPQHafTzW dld/BPVMAuRHAD1aNoSC8klm+d56UELXtfQfHGuB+BzZr3pvw2feB64+lPBxV0/wgVxY sfX0FXNy2TNKMkPN9uK83Vhv6+y7FogE7TTK+EuLPyzLTnD2v0FEbbFC46WmcBeFBedT AvsNImoOtAU6k35u9baH0u+uz/qzOsW5reu3Ymb6ExE3d3GFOOZla3X7QG2vE6Ivd6AA SwNlUsH4FGyljlj+25XmiYOKQUz2OrH3kaCSXf+JvR+NtwFT1bC9kl/weuX/1eGSsOUs bmHg== X-Gm-Message-State: ACgBeo3Tzo1AXismrNzi/eh8Bxo/Gf9y3bSVMnZMVfKIHlKu3hIkdfYx 41AhztzgafjXu614Z9p5oUdjMA== X-Google-Smtp-Source: AA6agR6Y13UabkGj2Pw1xPeKlx9CcnBMiy4uG1v3LoUZbuUY3pNQYy723yfvhdQOcHQZVmLZNUpHkQ== X-Received: by 2002:a63:e317:0:b0:432:38c0:bde3 with SMTP id f23-20020a63e317000000b0043238c0bde3mr10927879pgh.567.1662365785944; Mon, 05 Sep 2022 01:16:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:16:25 -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:15:50 +0900 Message-Id: <20220905081552.2740917-9-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662365786; 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=c5PmU9G1qPXBEkAqfdXGZ3byMU1QzgO+Mm+AUQgGAkVjesSAxWzBHJEyVUl+1MbmyZcS3I +9w7iedf5FBThET8XytFJYdmR7+ExMQV5GigOeIOipD3+LEGvGhY5WzUmNxcyow9peQrtn SCZ+6nGPKhctYOqhjviDdyYQmQvLu/E= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=cQVKvubg; spf=pass (imf06.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.178 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=1662365786; a=rsa-sha256; cv=none; b=poiAEquvLiofOqpAdnwCIrO+q8cxkkM++E8Oj5XqapuSKTpg4HQhkzIKRqPV9iK2X6OKrB N4tSD9Ks2JSuRuFzcyv8qqPZ4C66no0wb6OBkxtYVh2hnxYoRFlVK+iS8W2A8oBpk7S8Bq RGzdvZNjzG2rlfi5HhfbsYCgK9NtTPo= X-Rspam-User: X-Stat-Signature: ts46ajpcz1juopnxqua6nz83t1hebano X-Rspamd-Queue-Id: BF0E8180060 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=cQVKvubg; spf=pass (imf06.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.178 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam04 X-HE-Tag: 1662365786-964623 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 ===============