From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 5CFC46B0010 for ; Sun, 15 Jul 2018 00:22:07 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id p5-v6so5625191edh.16 for ; Sat, 14 Jul 2018 21:22:07 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c25-v6sor639732eds.7.2018.07.14.21.22.05 for (Google Transport Security); Sat, 14 Jul 2018 21:22:05 -0700 (PDT) MIME-Version: 1.0 References: <20180701065616.3512-1-wdignazio@gmail.com> In-Reply-To: <20180701065616.3512-1-wdignazio@gmail.com> From: Will Dignazio Date: Sat, 14 Jul 2018 21:21:47 -0700 Message-ID: Subject: Re: [PATCH] Add option to configure default zswap compressor algorithm. Content-Type: multipart/alternative; boundary="0000000000002c41c60571020e42" Sender: owner-linux-mm@kvack.org List-ID: To: sjenning@redhat.com Cc: ddstreet@ieee.org, linux-mm@kvack.org --0000000000002c41c60571020e42 Content-Type: text/plain; charset="UTF-8" Apologies for bumping. I also should give a better description: This patch introduces a configuration option for the default cryptographic compression algorithm used by zswap. Previous to this patch, one would use the default compression algorithm until changed from userspace. This patch allows a compilation time change, which will remain the default from boot until changed. On Sat, Jun 30, 2018 at 11:56 PM Will Ziener-Dignazio wrote: > - Add Kconfig option for default compressor algorithm > - Add the deflate and LZ4 algorithms as default options > > Signed-off-by: Will Ziener-Dignazio > --- > mm/Kconfig | 35 ++++++++++++++++++++++++++++++++++- > mm/zswap.c | 11 ++++++++++- > 2 files changed, 44 insertions(+), 2 deletions(-) > > diff --git a/mm/Kconfig b/mm/Kconfig > index ce95491abd6a..09df6650e96a 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -535,7 +535,6 @@ config MEM_SOFT_DIRTY > config ZSWAP > bool "Compressed cache for swap pages (EXPERIMENTAL)" > depends on FRONTSWAP && CRYPTO=y > - select CRYPTO_LZO > select ZPOOL > default n > help > @@ -552,6 +551,40 @@ config ZSWAP > they have not be fully explored on the large set of potential > configurations and workloads that exist. > > +choice > + prompt "Compressed cache cryptographic compression algorithm" > + default ZSWAP_COMPRESSOR_DEFAULT_LZO > + depends on ZSWAP > + help > + The default cyptrographic compression algorithm to use for > + compressed swap pages. > + > +config ZSWAP_COMPRESSOR_DEFAULT_LZO > + bool "lzo" > + select CRYPTO_LZO > + help > + This option sets the default zswap compression algorithm to LZO, > + the Lempel-Ziv-Oberhumer algorithm. This algorthm focuses on > + decompression speed, but has a lower compression ratio. > + > +config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE > + bool "deflate" > + select CRYPTO_DEFLATE > + help > + This option sets the default zswap compression algorithm to > DEFLATE. > + This algorithm balances compression and decompression speed to > + compresstion ratio. > + > +config ZSWAP_COMPRESSOR_DEFAULT_LZ4 > + bool "lz4" > + select CRYPTO_LZ4 > + help > + This option sets the default zswap compression algorithm to LZ4. > + This algorithm focuses on high compression speed, but has a lower > + compression ratio and decompression speed. > + > +endchoice > + > config ZPOOL > tristate "Common API for compressed memory storage" > default n > diff --git a/mm/zswap.c b/mm/zswap.c > index 7d34e69507e3..30f9f25da4d0 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -91,7 +91,16 @@ static struct kernel_param_ops zswap_enabled_param_ops > = { > module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_enabled, 0644); > > /* Crypto compressor to use */ > -#define ZSWAP_COMPRESSOR_DEFAULT "lzo" > +#if defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZO) > + #define ZSWAP_COMPRESSOR_DEFAULT "lzo" > +#elif defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_DEFLATE) > + #define ZSWAP_COMPRESSOR_DEFAULT "deflate" > +#elif defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4) > + #define ZSWAP_COMPRESSOR_DEFAULT "lz4" > +#else > + #error "Default zswap compression algorithm not defined." > +#endif > + > static char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT; > static int zswap_compressor_param_set(const char *, > const struct kernel_param *); > -- > 2.18.0 > > -- Bytes Go In, Words Go Out --0000000000002c41c60571020e42 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Apologies for bumping. I also should give a better de= scription:

This patch introduces a configuration o= ption for the default cryptographic compression algorithm used by zswap. Pr= evious to this patch, one would use the default compression algorithm until= changed from userspace. This patch allows a compilation time change, which= will remain the default from boot until changed.

On Sat, Jun 30, 2018 at 11:56 PM Will Zie= ner-Dignazio <wdignazio@gmail.com= > wrote:
=C2=A0 =C2=A0 - Add= Kconfig option for default compressor algorithm
=C2=A0 =C2=A0 - Add the deflate and LZ4 algorithms as default options

Signed-off-by: Will Ziener-Dignazio <wdignazio@gmail.com>
---
=C2=A0mm/Kconfig | 35 ++++++++++++++++++++++++++++++++++-
=C2=A0mm/zswap.c | 11 ++++++++++-
=C2=A02 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index ce95491abd6a..09df6650e96a 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -535,7 +535,6 @@ config MEM_SOFT_DIRTY
=C2=A0config ZSWAP
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool "Compressed cache for swap pages (EXP= ERIMENTAL)"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 depends on FRONTSWAP && CRYPTO=3Dy
-=C2=A0 =C2=A0 =C2=A0 =C2=A0select CRYPTO_LZO
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select ZPOOL
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default n
=C2=A0 =C2=A0 =C2=A0 =C2=A0 help
@@ -552,6 +551,40 @@ config ZSWAP
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 they have not be fully explored on the l= arge set of potential
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 configurations and workloads that exist.=

+choice
+=C2=A0 =C2=A0 =C2=A0 =C2=A0prompt "Compressed cache cryptographic com= pression algorithm"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default ZSWAP_COMPRESSOR_DEFAULT_LZO
+=C2=A0 =C2=A0 =C2=A0 =C2=A0depends on ZSWAP
+=C2=A0 =C2=A0 =C2=A0 =C2=A0help
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The default cyptrographic compression al= gorithm to use for
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compressed swap pages.
+
+config ZSWAP_COMPRESSOR_DEFAULT_LZO
+=C2=A0 =C2=A0 =C2=A0 =C2=A0bool "lzo"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0select CRYPTO_LZO
+=C2=A0 =C2=A0 =C2=A0 =C2=A0help
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This option sets the default zswap compr= ession algorithm to LZO,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0the Lempel-Ziv-Oberhumer algorithm. This= algorthm focuses on
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0decompression speed, but has a lower com= pression ratio.
+
+config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0bool "deflate"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0select CRYPTO_DEFLATE
+=C2=A0 =C2=A0 =C2=A0 =C2=A0help
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This option sets the default zswap compr= ession algorithm to DEFLATE.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This algorithm balances compression and = decompression speed to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compresstion ratio.
+
+config ZSWAP_COMPRESSOR_DEFAULT_LZ4
+=C2=A0 =C2=A0 =C2=A0 =C2=A0bool "lz4"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0select CRYPTO_LZ4
+=C2=A0 =C2=A0 =C2=A0 =C2=A0help
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This option sets the default zswap compr= ession algorithm to LZ4.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0This algorithm focuses on high compressi= on speed, but has a lower
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compression ratio and decompression spee= d.
+
+endchoice
+
=C2=A0config ZPOOL
=C2=A0 =C2=A0 =C2=A0 =C2=A0 tristate "Common API for compressed memory= storage"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default n
diff --git a/mm/zswap.c b/mm/zswap.c
index 7d34e69507e3..30f9f25da4d0 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -91,7 +91,16 @@ static struct kernel_param_ops zswap_enabled_param_ops = =3D {
=C2=A0module_param_cb(enabled, &zswap_enabled_param_ops, &zswap_ena= bled, 0644);

=C2=A0/* Crypto compressor to use */
-#define ZSWAP_COMPRESSOR_DEFAULT "lzo"
+#if defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZO)
+=C2=A0 #define ZSWAP_COMPRESSOR_DEFAULT "lzo"
+#elif defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_DEFLATE)
+=C2=A0 #define ZSWAP_COMPRESSOR_DEFAULT "deflate"
+#elif defined(CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4)
+=C2=A0 #define ZSWAP_COMPRESSOR_DEFAULT "lz4"
+#else
+=C2=A0 #error "Default zswap compression algorithm not defined."=
+#endif
+
=C2=A0static char *zswap_compressor =3D ZSWAP_COMPRESSOR_DEFAULT;
=C2=A0static int zswap_compressor_param_set(const char *,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const struct ke= rnel_param *);
--
2.18.0

--
Bytes Go In, Words Go Out
--0000000000002c41c60571020e42--