From patchwork Fri Feb 23 03:55:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13568556 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6D2610971 for ; Fri, 23 Feb 2024 03:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660570; cv=none; b=sdxYGXLYt+fW9p0RwBADpAqAf3YZb95Xlp3frpUZoyQh6eQLE60QmGbtCvQkHmU3hj8q4PoQDkjZAnClMug7k8v1ULvNWfuICK4hIDOrIht7vc6CCc8jWy4a3niH/SO27TTa1hKet1Z4SpSvtJqRr5tm3ZiQQ5OuMf5frSJ2TMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660570; c=relaxed/simple; bh=d/R/4aR4gC50xsS9lw/06sGRWh/mHdlq/aSZyPL2FnQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nDB6gxXmf+bRxXlEDLD+KoNFiTZKR4EjtfuE0vJoZjPcyqLhzTgs0aHBbcWbPqpdqc8UDz5NSu+riGi72oXC9+qnO52UhxeJSsrjwjV8qkU8ySASeh3vTXsLyEO9IlURp+kSY07Hdw/cXqXdmPYXVT6LPFoKIqmt7VvTYADP7TI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tgx3J0qT7z1xpBD; Fri, 23 Feb 2024 11:54:36 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 92D6C140136; Fri, 23 Feb 2024 11:56:00 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 23 Feb 2024 11:55:59 +0800 From: Kefeng Wang To: Johannes Weiner , Yosry Ahmed , Nhat Pham , Andrew Morton CC: Chengming Zhou , Huacai Chen , Minchan Kim , Sergey Senozhatsky , , , Kefeng Wang Subject: [PATCH 1/5] zram: zcomp: remove zcomp_set_max_streams() declaration Date: Fri, 23 Feb 2024 11:55:44 +0800 Message-ID: <20240223035548.2591882-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> References: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) The zcomp_set_max_streams() is removed from commit 43209ea2d17a ("zram: remove max_comp_streams internals"), remove the declaration. Signed-off-by: Kefeng Wang --- drivers/block/zram/zcomp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h index cdefdef93da8..e9fe63da0e9b 100644 --- a/drivers/block/zram/zcomp.h +++ b/drivers/block/zram/zcomp.h @@ -39,5 +39,4 @@ int zcomp_compress(struct zcomp_strm *zstrm, int zcomp_decompress(struct zcomp_strm *zstrm, const void *src, unsigned int src_len, void *dst); -bool zcomp_set_max_streams(struct zcomp *comp, int num_strm); #endif /* _ZCOMP_H_ */ From patchwork Fri Feb 23 03:55:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13568553 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCAD3B67F for ; Fri, 23 Feb 2024 03:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660566; cv=none; b=lN/doA7+YJl+QWxe7T0BHYr4/JNs1k3DTz/2KgzoO1oATKZ5cupUCdwUbfQn0ylPyDXIPMqZImTo3Yqim7qep9vdmt7v1gc9aHwUzN/5ozFGgYCayrT78bkfuRX4PWuwaVOVHpbbN2U5JKFr7pAaJvdo7kaNH+KHlnr/vbR0JvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660566; c=relaxed/simple; bh=brGBZ9P1VPb4XpFtJMfvT/hhEfEYKxqN4etRyOQiKfQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L9+9wF/TVB5hvcDv9qVPh9mPZDtFY0qnWTJfJosxAzVkBCGzlDhROJrQoVX0gARfXsOX+xQAZg1cvlbBfM11F/ZzhfRifm/WqHdHsPAFd1MI2vBgvEYOzp/6mNKpDBFmneySu9OfK8E2350dRiOALs+w9tu3wqbQrNhDPcGc5Lk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Tgx4G1kvhz1vtxj; Fri, 23 Feb 2024 11:55:26 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 2A7911A016C; Fri, 23 Feb 2024 11:56:01 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 23 Feb 2024 11:56:00 +0800 From: Kefeng Wang To: Johannes Weiner , Yosry Ahmed , Nhat Pham , Andrew Morton CC: Chengming Zhou , Huacai Chen , Minchan Kim , Sergey Senozhatsky , , , Kefeng Wang Subject: [PATCH 2/5] zram: make zram depends on SWAP Date: Fri, 23 Feb 2024 11:55:45 +0800 Message-ID: <20240223035548.2591882-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> References: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) The zram is useless when SWAP is disabled, make zram depends on SWAP. Signed-off-by: Kefeng Wang --- drivers/block/zram/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 7b29cce60ab2..0cee425da0f5 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 config ZRAM tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && MMU + depends on SWAP && SYSFS depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 select ZSMALLOC help From patchwork Fri Feb 23 03:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13568554 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1856D2E6 for ; Fri, 23 Feb 2024 03:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660567; cv=none; b=roJtIfJO2garm58R8DvZzaBGymqAnKOrq4TwMVKcADbr9dlZQ3N0+mPR3H+mv7p803A6LmvU8A1mal30l/GTwMofSmy5/lsePgmzW4ejYt9S5+H1AkNqNyDZgKXLiLRsCbCUMzjpQeSZkoy9thCKLsZFLbbXCLjCFGmDiwQyLng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660567; c=relaxed/simple; bh=p440YFG9lPgSq8HFwoKWlaFAhsV5uzvTMX4KQdrHDRk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m52n40J9//YQa6+KfSsmS9QF9FgYVsF2W1fkW9ZVTqkiz2PDIkf4xrBJSohLKiaQHxMn607zYcVhrA5sJd0Usx4mTHFYmkwvFzgrttqP0aZtlM4qqfNFmEdsdDANXnzOUyknUyxV1Zpn/4cohPsfJsopRtIZJBkb/jfpwlsMLcY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TgwzJ1DHHz1FKW7; Fri, 23 Feb 2024 11:51:08 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id BB1EA140155; Fri, 23 Feb 2024 11:56:01 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 23 Feb 2024 11:56:01 +0800 From: Kefeng Wang To: Johannes Weiner , Yosry Ahmed , Nhat Pham , Andrew Morton CC: Chengming Zhou , Huacai Chen , Minchan Kim , Sergey Senozhatsky , , , Kefeng Wang Subject: [PATCH 3/5] zram: support deflate compressor Date: Fri, 23 Feb 2024 11:55:46 +0800 Message-ID: <20240223035548.2591882-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> References: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) Add deflate compressor support, also it is prepare for unifying the default compressor compressor for zram and zswap. Signed-off-by: Kefeng Wang --- drivers/block/zram/Kconfig | 7 ++++++- drivers/block/zram/zcomp.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 0cee425da0f5..b007dda16430 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -2,7 +2,7 @@ config ZRAM tristate "Compressed RAM block device support" depends on SWAP && SYSFS - depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 + depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 || CRYPTO_DEFLATE select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). @@ -20,6 +20,10 @@ choice default ZRAM_DEF_COMP_LZORLE depends on ZRAM +config ZRAM_DEF_COMP_DEFLATE + bool "Deflate" + depends on CRYPTO_DEFLATE + config ZRAM_DEF_COMP_LZORLE bool "lzo-rle" depends on CRYPTO_LZO @@ -48,6 +52,7 @@ endchoice config ZRAM_DEF_COMP string + default "deflate" if ZRAM_DEF_COMP_DEFLATE default "lzo-rle" if ZRAM_DEF_COMP_LZORLE default "zstd" if ZRAM_DEF_COMP_ZSTD default "lz4" if ZRAM_DEF_COMP_LZ4 diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index 8237b08c49d8..1f9a431f771e 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -16,6 +16,9 @@ #include "zcomp.h" static const char * const backends[] = { +#if IS_ENABLED(CONFIG_CRYPTO_DEFLATE) + "deflate", +#endif #if IS_ENABLED(CONFIG_CRYPTO_LZO) "lzo", "lzo-rle", From patchwork Fri Feb 23 03:55:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13568555 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1896DDB1 for ; Fri, 23 Feb 2024 03:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660568; cv=none; b=SKPQoclzLdWiJ3mVNDX9FejxC6/bfIDTYuaqtngyJ9DCwnlzhbEV9aoWXE5st5b3H9enCH5tVs4YFZ+Y2R0DjBP8O/dBb7uW/XnbbChB7gSYZAOjfKfeVa03+heGQXkPI3wiz1U2vLSbu9HRyQEUMW0lWkGrgIw4sToTGRL8KaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660568; c=relaxed/simple; bh=KiOu5h3IDER5dAH5Zs/e4rFZ9RBxGacT4w9BAMy7iTk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qBDqGXESXa+9PpgcV11D3qWB511ODApy0CuFZ0qs5hgPzxzTG2vxx6tgt3SJN/dFcq9Mr1V96vjN1oDRCY2jB2Ud4fwbo4UaKn9ZT7cBJk6GEqiopLh4FlKXu3qpxKTJgO8x6dLhwbvT/K+RpnDwpQ/xBzYzdBNYUpaJLQPVEXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Tgx2S18Rwz1gyhf; Fri, 23 Feb 2024 11:53:52 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 5AC04140155; Fri, 23 Feb 2024 11:56:02 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 23 Feb 2024 11:56:01 +0800 From: Kefeng Wang To: Johannes Weiner , Yosry Ahmed , Nhat Pham , Andrew Morton CC: Chengming Zhou , Huacai Chen , Minchan Kim , Sergey Senozhatsky , , , Kefeng Wang Subject: [PATCH 4/5] mm: zswap: default to lzo-rle instead of lzo Date: Fri, 23 Feb 2024 11:55:47 +0800 Message-ID: <20240223035548.2591882-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> References: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) Since lzo-rle performance is better than lzo, see commit ce82f19fd580 ("zram: default to lzo-rle instead of lzo"), converting zswap to use lze-rle too. Signed-off-by: Kefeng Wang --- mm/Kconfig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index b1448aa81e15..f41a28b74efd 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -62,7 +62,7 @@ config ZSWAP_SHRINKER_DEFAULT_ON choice prompt "Default compressor" depends on ZSWAP - default ZSWAP_COMPRESSOR_DEFAULT_LZO + default ZSWAP_COMPRESSOR_DEFAULT_LZORLE help Selects the default compression algorithm for the compressed cache for swap pages. @@ -72,7 +72,7 @@ choice available at the following LWN page: https://lwn.net/Articles/751795/ - If in doubt, select 'LZO'. + If in doubt, select 'LZO-RLE'. The selection made here can be overridden by using the kernel command line 'zswap.compressor=' option. @@ -83,6 +83,12 @@ config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE help Use the Deflate algorithm as the default compression algorithm. +config ZSWAP_COMPRESSOR_DEFAULT_LZORLE + bool "LZO-RLE" + select CRYPTO_LZO + help + Use the LZO algorithm as the default compression algorithm. + config ZSWAP_COMPRESSOR_DEFAULT_LZO bool "LZO" select CRYPTO_LZO @@ -118,6 +124,7 @@ config ZSWAP_COMPRESSOR_DEFAULT string depends on ZSWAP default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE + default "lzo-rle" if ZSWAP_COMPRESSOR_DEFAULT_LZORLE default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO default "842" if ZSWAP_COMPRESSOR_DEFAULT_842 default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4 From patchwork Fri Feb 23 03:55:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13568558 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 150B810971 for ; Fri, 23 Feb 2024 03:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660573; cv=none; b=IxA1TmClcbjXut2UO2AFjezSwdd4UpMKH/ATblIbDTtCHV6lBrEXsUl8IYaCWJMULaR34aG14QP9PN6HIdbHxZIfDu9VqFzvLchMf4tjvnt0xRSWxg6sWqSDZ2Jqw2QMgjI07W/vK2QRyvtmcVAar2MDL4ZZmVSrSOh8j0dzac8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708660573; c=relaxed/simple; bh=d0PtJwRdu2CDYq+yoHIktTBuHu+ZlpxG4H9Yvv+yTDM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZKJZRH9h6jCcGfA6vi3kTBA10FjWZWlic6vriBJJbQkx0XFaiZmM+RYn6RuukW8WVrjv/pIlXA5l3F5ZGeG05NddMeQ+O3vj8D0ulGPJww6niDukk4UilFbCeobC3+nhX5ohyMeN6yJNm8uwnCu25+tsvvOra6yGd1JDxsXgA6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Tgx2j6Kc6zXh7x; Fri, 23 Feb 2024 11:54:05 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id E2B2B1400CA; Fri, 23 Feb 2024 11:56:02 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 23 Feb 2024 11:56:02 +0800 From: Kefeng Wang To: Johannes Weiner , Yosry Ahmed , Nhat Pham , Andrew Morton CC: Chengming Zhou , Huacai Chen , Minchan Kim , Sergey Senozhatsky , , , Kefeng Wang Subject: [PATCH 5/5] mm: unify default compressor algorithm for zswap and zram Date: Fri, 23 Feb 2024 11:55:48 +0800 Message-ID: <20240223035548.2591882-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> References: <20240223035548.2591882-1-wangkefeng.wang@huawei.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) Both zswap and zram could change compressor algorithm dynamically, it can be overridden at boot time by 'zswap.compressor=' for zswap, also there is a sysfs interface to change it, see /sys/block/zramX/comp_algorithm /sys/module/zswap/parameters/compressor So there is no need to maintain independence default compressor algorithm, unify the Kconfig to use lzo-rle as the default page compressor algorithm. Signed-off-by: Kefeng Wang --- Documentation/admin-guide/mm/zswap.rst | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- drivers/block/zram/Kconfig | 47 +------- drivers/block/zram/zram_drv.c | 2 +- mm/Kconfig | 131 +++++++++++---------- mm/zswap.c | 8 +- 6 files changed, 74 insertions(+), 118 deletions(-) diff --git a/Documentation/admin-guide/mm/zswap.rst b/Documentation/admin-guide/mm/zswap.rst index b42132969e31..375366b9a642 100644 --- a/Documentation/admin-guide/mm/zswap.rst +++ b/Documentation/admin-guide/mm/zswap.rst @@ -90,7 +90,7 @@ controlled policy: * max_pool_percent - The maximum percentage of memory that the compressed pool can occupy. -The default compressor is selected in ``CONFIG_ZSWAP_COMPRESSOR_DEFAULT`` +The default compressor is selected in ``CONFIG_COMPRESSOR_DEFAULT`` Kconfig option, but it can be overridden at boot time by setting the ``compressor`` attribute, e.g. ``zswap.compressor=lzo``. It can also be changed at runtime using the sysfs "compressor" diff --git a/arch/loongarch/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig index f18c2ba871ef..dc718089a530 100644 --- a/arch/loongarch/configs/loongson3_defconfig +++ b/arch/loongarch/configs/loongson3_defconfig @@ -91,7 +91,7 @@ CONFIG_BFQ_GROUP_IOSCHED=y CONFIG_BINFMT_MISC=m CONFIG_ZPOOL=y CONFIG_ZSWAP=y -CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD=y +CONFIG_COMPRESSOR_DEFAULT_ZSTD=y CONFIG_ZBUD=y CONFIG_Z3FOLD=y CONFIG_ZSMALLOC=m diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index b007dda16430..26558159824e 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -2,7 +2,7 @@ config ZRAM tristate "Compressed RAM block device support" depends on SWAP && SYSFS - depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 || CRYPTO_DEFLATE + select CRYPTO select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). @@ -15,51 +15,6 @@ config ZRAM See Documentation/admin-guide/blockdev/zram.rst for more information. -choice - prompt "Default zram compressor" - default ZRAM_DEF_COMP_LZORLE - depends on ZRAM - -config ZRAM_DEF_COMP_DEFLATE - bool "Deflate" - depends on CRYPTO_DEFLATE - -config ZRAM_DEF_COMP_LZORLE - bool "lzo-rle" - depends on CRYPTO_LZO - -config ZRAM_DEF_COMP_ZSTD - bool "zstd" - depends on CRYPTO_ZSTD - -config ZRAM_DEF_COMP_LZ4 - bool "lz4" - depends on CRYPTO_LZ4 - -config ZRAM_DEF_COMP_LZO - bool "lzo" - depends on CRYPTO_LZO - -config ZRAM_DEF_COMP_LZ4HC - bool "lz4hc" - depends on CRYPTO_LZ4HC - -config ZRAM_DEF_COMP_842 - bool "842" - depends on CRYPTO_842 - -endchoice - -config ZRAM_DEF_COMP - string - default "deflate" if ZRAM_DEF_COMP_DEFLATE - default "lzo-rle" if ZRAM_DEF_COMP_LZORLE - default "zstd" if ZRAM_DEF_COMP_ZSTD - default "lz4" if ZRAM_DEF_COMP_LZ4 - default "lzo" if ZRAM_DEF_COMP_LZO - default "lz4hc" if ZRAM_DEF_COMP_LZ4HC - default "842" if ZRAM_DEF_COMP_842 - config ZRAM_WRITEBACK bool "Write back incompressible or idle page to backing device" depends on ZRAM diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index f0639df6cd18..664c4012ced4 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -41,7 +41,7 @@ static DEFINE_IDR(zram_index_idr); static DEFINE_MUTEX(zram_index_mutex); static int zram_major; -static const char *default_compressor = CONFIG_ZRAM_DEF_COMP; +static const char *default_compressor = CONFIG_COMPRESSOR_DEFAULT; /* Module params (documentation at end) */ static unsigned int num_devices = 1; diff --git a/mm/Kconfig b/mm/Kconfig index f41a28b74efd..9da2671e0b20 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -9,9 +9,6 @@ menu "Memory Management options" config ARCH_NO_SWAP bool -config ZPOOL - bool - menuconfig SWAP bool "Support for paging of anonymous memory (swap)" depends on MMU && BLOCK && !ARCH_NO_SWAP @@ -22,116 +19,118 @@ menuconfig SWAP used to provide more virtual memory than the actual RAM present in your computer. If unsure say Y. -config ZSWAP - bool "Compressed cache for swap pages" - depends on SWAP - select CRYPTO - select ZPOOL - help - A lightweight compressed cache for swap pages. It takes - pages that are in the process of being swapped out and attempts to - compress them into a dynamically allocated RAM-based memory pool. - This can result in a significant I/O reduction on swap device and, - in the case where decompressing from RAM is faster than swap device - reads, can also improve workload performance. - -config ZSWAP_DEFAULT_ON - bool "Enable the compressed cache for swap pages by default" - depends on ZSWAP - help - If selected, the compressed cache for swap pages will be enabled - at boot, otherwise it will be disabled. - - The selection made here can be overridden by using the kernel - command line 'zswap.enabled=' option. - -config ZSWAP_SHRINKER_DEFAULT_ON - bool "Shrink the zswap pool on memory pressure" - depends on ZSWAP - default n - help - If selected, the zswap shrinker will be enabled, and the pages - stored in the zswap pool will become available for reclaim (i.e - written back to the backing swap device) on memory pressure. - - This means that zswap writeback could happen even if the pool is - not yet full, or the cgroup zswap limit has not been reached, - reducing the chance that cold pages will reside in the zswap pool - and consume memory indefinitely. +if SWAP choice - prompt "Default compressor" - depends on ZSWAP - default ZSWAP_COMPRESSOR_DEFAULT_LZORLE + prompt "Default page compressor algorithm" + depends on ZSWAP || ZRAM + default COMPRESSOR_DEFAULT_LZORLE help - Selects the default compression algorithm for the compressed cache - for swap pages. + Selects the default compression algorithm for compressing pages. For an overview what kind of performance can be expected from a particular compression algorithm please refer to the benchmarks available at the following LWN page: https://lwn.net/Articles/751795/ - If in doubt, select 'LZO-RLE'. + If in doubt, select 'LZO-rle'. - The selection made here can be overridden by using the kernel - command line 'zswap.compressor=' option. - -config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE +config COMPRESSOR_DEFAULT_DEFLATE bool "Deflate" select CRYPTO_DEFLATE help Use the Deflate algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_LZORLE +config COMPRESSOR_DEFAULT_LZORLE bool "LZO-RLE" select CRYPTO_LZO help Use the LZO algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_LZO +config COMPRESSOR_DEFAULT_LZO bool "LZO" select CRYPTO_LZO help Use the LZO algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_842 +config COMPRESSOR_DEFAULT_842 bool "842" select CRYPTO_842 help Use the 842 algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_LZ4 +config COMPRESSOR_DEFAULT_LZ4 bool "LZ4" select CRYPTO_LZ4 help Use the LZ4 algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_LZ4HC +config COMPRESSOR_DEFAULT_LZ4HC bool "LZ4HC" select CRYPTO_LZ4HC help Use the LZ4HC algorithm as the default compression algorithm. -config ZSWAP_COMPRESSOR_DEFAULT_ZSTD - bool "zstd" +config COMPRESSOR_DEFAULT_ZSTD + bool "ZSTD" select CRYPTO_ZSTD help Use the zstd algorithm as the default compression algorithm. + endchoice -config ZSWAP_COMPRESSOR_DEFAULT +config COMPRESSOR_DEFAULT string - depends on ZSWAP - default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE - default "lzo-rle" if ZSWAP_COMPRESSOR_DEFAULT_LZORLE - default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO - default "842" if ZSWAP_COMPRESSOR_DEFAULT_842 - default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4 - default "lz4hc" if ZSWAP_COMPRESSOR_DEFAULT_LZ4HC - default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD + depends on ZSWAP || ZRAM + default "deflate" if COMPRESSOR_DEFAULT_DEFLATE + default "lzo-rle" if COMPRESSOR_DEFAULT_LZORLE + default "lzo" if COMPRESSOR_DEFAULT_LZO + default "842" if COMPRESSOR_DEFAULT_842 + default "lz4" if COMPRESSOR_DEFAULT_LZ4 + default "lz4hc" if COMPRESSOR_DEFAULT_LZ4HC + default "zstd" if COMPRESSOR_DEFAULT_ZSTD default "" +config ZPOOL + bool + +config ZSWAP + bool "Compressed cache for swap pages" + depends on SWAP + select CRYPTO + select ZPOOL + help + A lightweight compressed cache for swap pages. It takes + pages that are in the process of being swapped out and attempts to + compress them into a dynamically allocated RAM-based memory pool. + This can result in a significant I/O reduction on swap device and, + in the case where decompressing from RAM is faster than swap device + reads, can also improve workload performance. + +config ZSWAP_DEFAULT_ON + bool "Enable the compressed cache for swap pages by default" + depends on ZSWAP + help + If selected, the compressed cache for swap pages will be enabled + at boot, otherwise it will be disabled. + + The selection made here can be overridden by using the kernel + command line 'zswap.enabled=' option. + +config ZSWAP_SHRINKER_DEFAULT_ON + bool "Shrink the zswap pool on memory pressure" + depends on ZSWAP + default n + help + If selected, the zswap shrinker will be enabled, and the pages + stored in the zswap pool will become available for reclaim (i.e + written back to the backing swap device) on memory pressure. + + This means that zswap writeback could happen even if the pool is + not yet full, or the cgroup zswap limit has not been reached, + reducing the chance that cold pages will reside in the zswap pool + and consume memory indefinitely. + choice prompt "Default allocator" depends on ZSWAP @@ -231,6 +230,8 @@ config ZSMALLOC_CHAIN_SIZE For more information, see zsmalloc documentation. +endif #SWAP + menu "Slab allocator options" config SLUB diff --git a/mm/zswap.c b/mm/zswap.c index 011e068eb355..907ae7797d98 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -96,7 +96,7 @@ static const struct kernel_param_ops zswap_enabled_param_ops = { module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644); /* Crypto compressor to use */ -static char *zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT; +static char *zswap_compressor = CONFIG_COMPRESSOR_DEFAULT; static int zswap_compressor_param_set(const char *, const struct kernel_param *); static const struct kernel_param_ops zswap_compressor_param_ops = { @@ -386,11 +386,11 @@ static struct zswap_pool *__zswap_pool_create_fallback(void) has_comp = crypto_has_acomp(zswap_compressor, 0, 0); if (!has_comp && strcmp(zswap_compressor, - CONFIG_ZSWAP_COMPRESSOR_DEFAULT)) { + CONFIG_COMPRESSOR_DEFAULT)) { pr_err("compressor %s not available, using default %s\n", - zswap_compressor, CONFIG_ZSWAP_COMPRESSOR_DEFAULT); + zswap_compressor, CONFIG_COMPRESSOR_DEFAULT); param_free_charp(&zswap_compressor); - zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT; + zswap_compressor = CONFIG_COMPRESSOR_DEFAULT; has_comp = crypto_has_acomp(zswap_compressor, 0, 0); } if (!has_comp) {