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: 3940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1777720wrs; Mon, 17 Oct 2022 21:58:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5RfrshYkp4GNVnWlTTjB+W+bj31M/FE4h5bZO16RDawvtOp+bn+pTCB2fQpJE/jkSTB9Vi X-Received: by 2002:a17:907:c15:b0:78d:9c3c:fb8f with SMTP id ga21-20020a1709070c1500b0078d9c3cfb8fmr912524ejc.347.1666069080745; Mon, 17 Oct 2022 21:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666069080; cv=none; d=google.com; s=arc-20160816; b=IhqCuJG+2kRKFyU8yR5LwvInZij3JV3+sRtzt/xhGLSpaQgjzcIm0+FciLywSKb52r aL148LMnp7eJZNhmPyQni6taH11AbaZfcExcW2laJxjhn5X0VomPQfSwT6QoPYD7zEmX B+YU/KXyQyJ1VfY+szf8uo5jU3A3NT8/DSfr6U4UyYy2fKjIW0H1Cjo8PICIw4PT+j5a EKMdJZ886uGat2Az2CgKhDlEviRUCq5P+Tz1Ldj8hJAMniI36pTBp/uIB61+Zurs1+Q6 BP1B51OSGf3apeWtlNIXA3os1+rmpbfYGsLJWx+YKdMhq/j2JzJ6bia2H5usyNZU0BVB LGjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zqbNRdZv0AEZA2o65O/7d+PvuPWf+J/YFOhKZdVnIao=; b=QH7ghotOfr54GYmjlVjM3M4bH4BHvhOGkIrOrT/9T0ZTopTUXbxPGN8LudotJWAtYi bKVlJibZ7nRBzASpdXvlCB4pfesEqu+es9lHOdPCOZXQ+pXnIAacsNsLoMemWr6vxmME Fwi3UZyFs3AHe3vcqplHKHYw6j5mp0+7SRSu4ZTkrsn3y44WvYl9rynnZOgulutMLJz8 t6D7wX/ZaVcJalPtNdbnh6FtDzh0F5SK1Umx8gydDKcfYrHjSc5lbp1FQ9+ObsmTLQY2 FHTs5d0wmrKZ0WJwxahq/9OX4Hl+z3NnXkvGgD0BsxWn+/iCg/A38g9NsHh6iEwAU8Jd ag6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ds+HJ6GR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a1709066d5500b00782933fe436si9280549ejt.965.2022.10.17.21.57.35; Mon, 17 Oct 2022 21:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ds+HJ6GR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbiJRE4U (ORCPT + 99 others); Tue, 18 Oct 2022 00:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiJREzz (ORCPT ); Tue, 18 Oct 2022 00:55:55 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3647A0256 for ; Mon, 17 Oct 2022 21:55:54 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 129so12329364pgc.5 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=pRxDUrTNMDUsdtVj9pojf6akSsBL8ufzaAVVPyntw7pzwj6gHJiCvKq5hAIUg73XYd 6Zv0Xge7EnKtdJ18etzGardj7zJvWUlSu2BOFbqVTzFQrqCBKDaXf6g39ELaShMSBPPQ QyBo+NfvoF1TYMhW9Wect2eelYe4zano3wVkbzjc1MCeTf2EpQE4H+eGdgcgRd38RZTf KySzvNd7ceP5ufc30Mtx3iNCivMjo+GnPj4yM7ww0Lud56Vc9IwiZKOOQ3b0gdgQ6j1I 0jnfxek4nMcMTS+pxvDEjIEcUp+G/jS7EvLQqJMkHFGtBseiwkEKFXv62gMAp9ymm9KI BEEA== X-Gm-Message-State: ACrzQf1xwiS+MEKKfBOC9vE2lOglSzWlpM5wR2E9SLBhcOoUkTWHuy3W ejZMr3dfNWBSbMfZM1GTULAFxg== 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 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747000052471654586?= X-GMAIL-MSGID: =?utf-8?q?1747000052471654586?= 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 ===============