Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2789280ybc; Mon, 18 Nov 2019 04:47:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxOZATXqN0sQGj2jk1FDLOvzGky3uLOvdbSNH90+U3srPGuOeOh8/0NzW17xHmo7Vstxd7/ X-Received: by 2002:a17:906:709:: with SMTP id y9mr25630293ejb.321.1574081272671; Mon, 18 Nov 2019 04:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574081272; cv=none; d=google.com; s=arc-20160816; b=oLYdlVilYzv7IyYlJB4CDy5RPX0YQ3Rvb7ztS5R4SFFDDnWwot31OHYCSP3lkhCvRB 7sIFPZ4KzfOc643xOjy8SexEqSyc2VFYyPyMTcpf/07Jr1GbJD0VF9a0gdbm0fvi5qH3 pkXjGgj3f1qfpKXYP78XggyX3ynZfHH1NCJ2eo+dnEQIIbP9ZaCTMQE6p7VywdmcyF3c JyfY2BZ7PlceRP/4v8msp37UymU7X0PBPMj+4Te5J1+NIsPYif4acClD/j4+aPvh18SJ ixVFKWRppYUTqsEs3P7leBiNdLQYMYXE1SfdMmWmOULhmTjrqx3V9iMM+XOP9JHTGBlC YkOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=weamprY/BAAhsZ3zJUJ69hq1P4hOTR5QL4AMQKW40F4=; b=KsEuU7yT3tV8c8RyQleuOH0VLm0c/7BdK+xIL2k1/AwD6R9HWdxZxmiK4ZgZ0mF/Jk oCjZn+DHOcZsh3XfMFnXVoW3Hnzk+ISsvJjycNszJJ0lyeufvEjVcTJy5c32N6jFZnJt 65c2GHvhO5jp+zv6vUSwnYfmi7e8x8KJ7Gps7GEyU2nmvG81Pt4w3eB/vgM+nRHdB234 Ye34t43NZHxRe8QUs/xtsCPq9LIrQk5hobsChRAx8YROkzSAMP310qFl1fYWR67e73Yx 8lRzP72hT4rnUgx+RyfiEZpNTZJYnlTK7zhfXKIB3mTEZoElkOxyJV6uMhA15TGGfAVk F79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WJgUBCKI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si6708127edr.154.2019.11.18.04.47.29; Mon, 18 Nov 2019 04:47:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WJgUBCKI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbfKRMoO (ORCPT + 99 others); Mon, 18 Nov 2019 07:44:14 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44162 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfKRMoO (ORCPT ); Mon, 18 Nov 2019 07:44:14 -0500 Received: by mail-lf1-f65.google.com with SMTP id n186so1257332lfd.11 for ; Mon, 18 Nov 2019 04:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=weamprY/BAAhsZ3zJUJ69hq1P4hOTR5QL4AMQKW40F4=; b=WJgUBCKIuW3ZXPWP+1ey063mDSjF5yHQVnF1Ogrvh5I+CM+qTo4ZG0YUHlcLxb4zvc jPVVd9GRl/8XS2fOUmNl5TWlTT93lUIODTUVlVDOz23VgJjVjeAtmp1cMsuggwlpqvVv tFOOT1ZsCY6EUJmwDsHSaqyYqlzUXEFlzSynVe0SxLVgjuKg8cpJwV7xpg2WIVJbzzdU dt5VP21UfU/A+mDvgu1AY6RvZEdTTuNcfz8JoW9FyimfoJ1RlhbEaK7vGpsmmub85TLa TmGApGw2zEWJos2Xlw1ojWBUN0eWILpRasyi59/jNveNIAMJNfQvPJcuS2Fr9CZ4ZeQV oRHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=weamprY/BAAhsZ3zJUJ69hq1P4hOTR5QL4AMQKW40F4=; b=b154T6OyaqlI7DmEHF5VnHkQuHBY+/IEp+7VcgJm+ZxtGY2UOIthtIcVqYhn79xKt8 h+XM/W2b+2U8cllTwwUZPSsLf9VLZz//KN1X8RcWvQ9YWO200rfINENf9aJtRfyd+6QD GiPfAA8+5P2ys/DAS+bNyw63LkF/wgoweB3xIv/e21uj2Y5FW6YIIBKipBd8kZpoLWfi XlpUFtvD4dElXkXihrFHevOmimbjgXMMDejobeQbeNKv6X7TUx9cs2/o2V/omDoUOxAk 3ddMn3psmESGwYAslbt46yqCLNNX1Esmnc0SIQUdDbT0H7R0fPUVJiWyVGxjHR0OpVzF Z88w== X-Gm-Message-State: APjAAAW2fWpEYajmbkfhCOD888fefdXTvUm/PKSqd2j2pV/kcoANOR90 qyPfEy95fjYG9oZdZlstjewBYIILfV7OjClW3Yc= X-Received: by 2002:ac2:4a8a:: with SMTP id l10mr20353422lfp.185.1574081051168; Mon, 18 Nov 2019 04:44:11 -0800 (PST) MIME-Version: 1.0 References: <20191117000544.1019556-1-mail@maciej.szmigiero.name> In-Reply-To: <20191117000544.1019556-1-mail@maciej.szmigiero.name> From: Vitaly Wool Date: Mon, 18 Nov 2019 13:43:58 +0100 Message-ID: Subject: Re: [PATCH v4] zswap: allow setting default status, compressor and allocator in Kconfig To: "Maciej S. Szmigiero" Cc: Seth Jennings , Dan Streetman , Vlastimil Babka , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maciej, sorry for jumping in late into this discussion. On Sun, Nov 17, 2019 at 1:05 AM Maciej S. Szmigiero wrote: > +config ZSWAP_COMPRESSOR_DEFAULT > + string > + default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE > + 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 > + default "" I guess this should also depend on ZSWAP. It looks a bit awkward when this option is present in dotconfig while ZSWAP is not. > + > +choice > + prompt "Compressed cache for swap pages default allocator" > + depends on ZSWAP > + default ZSWAP_ZPOOL_DEFAULT_ZBUD > + help > + Selects the default allocator for the compressed cache for > + swap pages. > + The default is 'zbud' for compatibility, however please do > + read the description of each of the allocators below before > + making a right choice. > + > + The selection made here can be overridden by using the kernel > + command line 'zswap.zpool=' option. > + > +config ZSWAP_ZPOOL_DEFAULT_ZBUD > + bool "zbud" > + select ZBUD > + help > + Use the zbud allocator as the default allocator. > + > +config ZSWAP_ZPOOL_DEFAULT_Z3FOLD > + bool "z3fold" > + select Z3FOLD > + help > + Use the z3fold allocator as the default allocator. > + > +config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC > + bool "zsmalloc" > + select ZSMALLOC > + help > + Use the zsmalloc allocator as the default allocator. > +endchoice > + > +config ZSWAP_ZPOOL_DEFAULT > + string > + default "zbud" if ZSWAP_ZPOOL_DEFAULT_ZBUD > + default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD > + default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC > + default "" Same here. > + > +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 ZPOOL > tristate "Common API for compressed memory storage" > help > diff --git a/mm/zswap.c b/mm/zswap.c > index 46a322316e52..71795b6f5b71 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -71,8 +71,12 @@ static u64 zswap_duplicate_entry; > > #define ZSWAP_PARAM_UNSET "" > > -/* Enable/disable zswap (disabled by default) */ > +/* Enable/disable zswap */ > +#ifdef CONFIG_ZSWAP_DEFAULT_ON > +static bool zswap_enabled = true; > +#else > static bool zswap_enabled; > +#endif Wouldn't it be better to have 'static bool zswap_enabled = IS_ENABLED(CONFIG_ZSWAP_DEFAULT_ON);' instead? > static int zswap_enabled_param_set(const char *, > const struct kernel_param *); > static struct kernel_param_ops zswap_enabled_param_ops = { > @@ -82,8 +86,7 @@ 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" > -static char *zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT; > +static char *zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT; > static int zswap_compressor_param_set(const char *, > const struct kernel_param *); > static struct kernel_param_ops zswap_compressor_param_ops = { > @@ -95,8 +98,7 @@ module_param_cb(compressor, &zswap_compressor_param_ops, > &zswap_compressor, 0644); > > /* Compressed storage zpool to use */ > -#define ZSWAP_ZPOOL_DEFAULT "zbud" > -static char *zswap_zpool_type = ZSWAP_ZPOOL_DEFAULT; > +static char *zswap_zpool_type = CONFIG_ZSWAP_ZPOOL_DEFAULT; > static int zswap_zpool_param_set(const char *, const struct kernel_param *); > static struct kernel_param_ops zswap_zpool_param_ops = { > .set = zswap_zpool_param_set, > @@ -569,11 +571,12 @@ static __init struct zswap_pool *__zswap_pool_create_fallback(void) > bool has_comp, has_zpool; > > has_comp = crypto_has_comp(zswap_compressor, 0, 0); > - if (!has_comp && strcmp(zswap_compressor, ZSWAP_COMPRESSOR_DEFAULT)) { > + if (!has_comp && strcmp(zswap_compressor, > + CONFIG_ZSWAP_COMPRESSOR_DEFAULT)) { > pr_err("compressor %s not available, using default %s\n", > - zswap_compressor, ZSWAP_COMPRESSOR_DEFAULT); > + zswap_compressor, CONFIG_ZSWAP_COMPRESSOR_DEFAULT); > param_free_charp(&zswap_compressor); > - zswap_compressor = ZSWAP_COMPRESSOR_DEFAULT; > + zswap_compressor = CONFIG_ZSWAP_COMPRESSOR_DEFAULT; > has_comp = crypto_has_comp(zswap_compressor, 0, 0); > } > if (!has_comp) { > @@ -584,11 +587,12 @@ static __init struct zswap_pool *__zswap_pool_create_fallback(void) > } > > has_zpool = zpool_has_pool(zswap_zpool_type); > - if (!has_zpool && strcmp(zswap_zpool_type, ZSWAP_ZPOOL_DEFAULT)) { > + if (!has_zpool && strcmp(zswap_zpool_type, > + CONFIG_ZSWAP_ZPOOL_DEFAULT)) { > pr_err("zpool %s not available, using default %s\n", > - zswap_zpool_type, ZSWAP_ZPOOL_DEFAULT); > + zswap_zpool_type, CONFIG_ZSWAP_ZPOOL_DEFAULT); > param_free_charp(&zswap_zpool_type); > - zswap_zpool_type = ZSWAP_ZPOOL_DEFAULT; > + zswap_zpool_type = CONFIG_ZSWAP_ZPOOL_DEFAULT; > has_zpool = zpool_has_pool(zswap_zpool_type); > } > if (!has_zpool) {