From patchwork Tue Oct 18 04:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13009906 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 1BFD7C4332F for ; Tue, 18 Oct 2022 04:55:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B01BB6B007E; Tue, 18 Oct 2022 00:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB10B8E0001; Tue, 18 Oct 2022 00:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92D046B0081; Tue, 18 Oct 2022 00:55:55 -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 8281E6B007E for ; Tue, 18 Oct 2022 00:55:55 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5FE431A034E for ; Tue, 18 Oct 2022 04:55:55 +0000 (UTC) X-FDA: 80032857870.08.D43F78F Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf17.hostedemail.com (Postfix) with ESMTP id E0DD340030 for ; Tue, 18 Oct 2022 04:55:54 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id q9so12313002pgq.8 for ; Mon, 17 Oct 2022 21:55:54 -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 :message-id:reply-to; bh=zqbNRdZv0AEZA2o65O/7d+PvuPWf+J/YFOhKZdVnIao=; b=ds+HJ6GR0TTrsjhdVBePPTb+ZYdPlv5VzdAyfO5kycvLRMKU33bufTdI0konnlBlZM 2jNp8xV7OmYFzIYYik/sjHdf7RJiNFshnSc4wMS+NII79AKetCRjFskA10EFZ/6QjeS5 QQZnpbF4K4nH6Tm/zfaat/KILJuoWiu3I4ZG4= 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:message-id:reply-to; bh=zqbNRdZv0AEZA2o65O/7d+PvuPWf+J/YFOhKZdVnIao=; b=w9ws4sWQtSZj8oWRXQ1iImymcYBtllxbX6MbTRMQVi3eWAeBgXwNKVlgLAjq2DbxbD F1a5VQY/lMN8f0cLBE7gtpgsE9/Hf6KdRem7X0yAyj55IP0QCQhsB/rtV1LdadF9icLf dls6GFaNghbK35xEZmQsSRA4EVx51gD8DlzsRXCNqOScsUdI4iiH0AczNM8qFALIaPMf jipJoGBqW2c+4vTSA5ejpf6qhs3OUlA/kGYNwQnJN3znQyfd0t8opm4Qj6mPIMnRjkos Qt0FXp0dw74+yimHa+0MqW1QMsP6I7KK5QyZTZoTDCCR9R6MmJ2YuHqqlTPx5dnx04fD NUoA== X-Gm-Message-State: ACrzQf2DapliKb8m0SaLPqrY0+cA/xy/Mm/0z72+WBRVs+c854npU+4o T5NULpPfAI321z49+9fsl7dK8w== X-Google-Smtp-Source: AMsMyM4gF8hnVrDD4vEMZDKoG10O5uE+BlIbYnroail7BaHbMICR6KtHATfACK4nJDhUHhjX+lvO1g== X-Received: by 2002:a05:6a00:1a92:b0:565:d5c0:f627 with SMTP id e18-20020a056a001a9200b00565d5c0f627mr1383823pfv.10.1666068953954; Mon, 17 Oct 2022 21:55:53 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:17a9:73b0:c262:eccd]) by smtp.gmail.com with ESMTPSA id p4-20020a170902e74400b0017b69f99321sm7549220plf.219.2022.10.17.21.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 21:55:53 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv4 5/9] documentation: Add recompression documentation Date: Tue, 18 Oct 2022 13:55:29 +0900 Message-Id: <20221018045533.2396670-6-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221018045533.2396670-1-senozhatsky@chromium.org> References: <20221018045533.2396670-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666068955; a=rsa-sha256; cv=none; b=LPmpz539N+xrBMmGRc00Oo8D8BDyPIhIHHkpRw9NogOdCqaCuJSEAYbQzsbPWIwAVDOHXI s5VjnJ4ZanGetFlN543PhepEgX9V1EeTr8dd8zEbDc8qY02H1RclMegWRTSZQJFXht6YKa 15Wc2bF4jAshzsQXKkFohFcDDumb9+g= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ds+HJ6GR; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf17.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666068954; 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=zqbNRdZv0AEZA2o65O/7d+PvuPWf+J/YFOhKZdVnIao=; b=36Z+svsF1QKxHEAmODYrkJwYx0tLT3K0D721lpDBcFD/qlhyrkdwX/xtG/io8ji+Xhjmr7 wso9QC+mdp8lHKmBZf/35h8va4tRknZtjqsYpdHny1rrNmzsZOzhTwRENgDIvKc6Q+CbBB yD2fNxn04FvHRITgCHtCT6VVe0EjqcQ= X-Rspamd-Queue-Id: E0DD340030 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ds+HJ6GR; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf17.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-Rspam-User: X-Rspamd-Server: rspam08 X-Stat-Signature: 9pif6j1zsiuwmup1y8x7fekko6t59jw1 X-HE-Tag: 1666068954-851623 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..c916c2b9da55 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 (in bytes) 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 ===============