Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4008019ybg; Fri, 25 Oct 2019 12:01:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSZRTINdk2KSQz0bXg/XOy6c6/G+rQYSI1Dc/77Y1L5Wq+ix/oyPh0pbQmBOX/ANjGiltF X-Received: by 2002:a50:8dc5:: with SMTP id s5mr5737586edh.115.1572030113925; Fri, 25 Oct 2019 12:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572030113; cv=none; d=google.com; s=arc-20160816; b=Zkud9oomQbBnHezr0KCCBYTw9mxEEKPahAYHwzNLrmGFw+BsWEHx31vfaKcpm7/nry 8kQuq1lgKbV2uUmndxK3D4wkA3MpaMluqwfeVMDdcYRF7Djga606T5dGMJrjvwhl0kSy a++4AI8OKbOWiyszOAFqLm/DZMYWIam6+MxXgpL+kHuC+ydQbsBIF0sAdbuSdDu+XURZ MdO/GdlXrBJ7B8i9N99Hlheuj1XOkKxlL+j0NaZweMjrYKlVI6ybt9OqaTSHQqeokoM5 gIgRcR3c4cn8zGCcW7VzNThng7FTFQHvWG2gVDt8CdotcVU36xvxJtQH0BKuaH+ZMHMG rjqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=okB0gFPItW3vH6ME4Hi5dFMb/lCTR2lSZIFJejzx9vA=; b=Q1X1o4caVKbzf0N4qWenHbJvkTXKGpCWRIspIRSCYrpDzU3cBW19ML6RCy4C0eeJRS +LEJ+AOBAeRcbVNuAC9DUbOADTwda4O7irnCDYNCopojgWYuGIQAUgtthJ6LxvQEMBxe NOAHqSS605qAA7T/Ernwu6cvbSqGXyxyoTEvw1yYwMVQU5E1X+PzQ+Hp90/4Am/9yJxl Xv1E86VaJge6aBTeLl1TBbaqX/xHziMLCWMl7pWzKUBZ1zmOmBxatoH6KKr2+Kgm3ly0 Oyvft9RXqiqxLDVghJ9nzCp8kZAPjElCr9OPoyzBg1MAxLS6W0KPKygUBL7fj8lePxY/ u9GQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c26si1957126edc.416.2019.10.25.12.01.29; Fri, 25 Oct 2019 12:01:53 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437260AbfJXTqe (ORCPT + 99 others); Thu, 24 Oct 2019 15:46:34 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:34010 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437148AbfJXTqe (ORCPT ); Thu, 24 Oct 2019 15:46:34 -0400 Received: from MUA by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) (envelope-from ) id 1iNj40-0000Bu-7X; Thu, 24 Oct 2019 21:46:28 +0200 Subject: Re: [PATCH v2] zswap: allow setting default status, compressor and allocator in Kconfig To: Vlastimil Babka Cc: Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20191023232209.3016231-1-mail@maciej.szmigiero.name> From: "Maciej S. Szmigiero" Openpgp: preference=signencrypt Autocrypt: addr=mail@maciej.szmigiero.name; prefer-encrypt=mutual; keydata= mQINBFpGusUBEADXUMM2t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DnpQpjAlgVmDgMgYTBW1W9etU 36YW0pTqEYuv6cmRgSAKEDaYHhFLTR1+lLJkp5fFo3Sjm7XqmXzfSv9JGJGMKzoFOMBoLYv+ VFnMoLX5UJAs0JyFqFY2YxGyLd4J103NI/ocqQeU0TVvOZGVkENPSxIESnbxPghsEC0MWEbG svqA8FwvU7XfGhZPYzTRf7CndDnezEA69EhwpZXKs4CvxbXo5PDTv0OWzVaAWqq8s8aTMJWW AhvobFozJ63zafYHkuEjMo0Xps3o3uvKg7coooH521nNsv4ci+KeBq3mgMCRAy0g/Ef+Ql7m t900RCBHu4tktOhPc3J1ep/e2WAJ4ngUqJhilzyCJnzVJ4cT79VK/uPtlfUCZdUz+jTC88Tm P1p5wlucS31kThy/CV4cqDFB8yzEujTSiRzd7neG3sH0vcxBd69uvSxLZPLGID840k0v5sft PA== Message-ID: Date: Thu, 24 Oct 2019 21:46:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24.10.2019 13:04, Vlastimil Babka wrote: > On 10/24/19 1:22 AM, Maciej S. Szmigiero wrote: >> The compressed cache for swap pages (zswap) currently needs from 1 to 3 >> extra kernel command line parameters in order to make it work: it has to be >> enabled by adding a "zswap.enabled=1" command line parameter and if one >> wants a different compressor or pool allocator than the default lzo / zbud >> combination then these choices also need to be specified on the kernel >> command line in additional parameters. >> >> Using a different compressor and allocator for zswap is actually pretty >> common as guides often recommend using the lz4 / z3fold pair instead of >> the default one. >> In such case it is also necessary to remember to enable the appropriate >> compression algorithm and pool allocator in the kernel config manually. >> >> Let's avoid the need for adding these kernel command line parameters and >> automatically pull in the dependencies for the selected compressor >> algorithm and pool allocator by adding an appropriate default switches to >> Kconfig. >> >> The default values for these options match what the code was using >> previously as its defaults. >> >> Signed-off-by: Maciej S. Szmigiero >> --- >> Changes from v1: >> Rename CONFIG_ZSWAP_DEFAULT_COMP_* to CONFIG_ZSWAP_COMPRESSOR_DEFAULT_* >> and CONFIG_ZSWAP_DEFAULT_ZPOOL_* to CONFIG_ZSWAP_ZPOOL_DEFAULT_* while >> dropping the "_NAME" suffix from the final string option in both cases. >> >> mm/Kconfig | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++- >> mm/zswap.c | 26 ++++++++------ >> 2 files changed, 117 insertions(+), 12 deletions(-) >> >> diff --git a/mm/Kconfig b/mm/Kconfig >> index a5dae9a7eb51..267316941324 100644 >> --- a/mm/Kconfig >> +++ b/mm/Kconfig >> @@ -525,7 +525,6 @@ config MEM_SOFT_DIRTY >> config ZSWAP >> bool "Compressed cache for swap pages (EXPERIMENTAL)" >> depends on FRONTSWAP && CRYPTO=y >> - select CRYPTO_LZO >> select ZPOOL >> help >> A lightweight compressed cache for swap pages. It takes >> @@ -541,6 +540,108 @@ config ZSWAP >> they have not be fully explored on the large set of potential >> configurations and workloads that exist. >> >> +choice >> + prompt "Compressed cache for swap pages default compressor" >> + depends on ZSWAP >> + default ZSWAP_COMPRESSOR_DEFAULT_LZO >> + help >> + Selects the default compression algorithm for the compressed cache >> + for swap pages. >> + If in doubt, select 'LZO'. > > Could it e.g. suggest which one is the fastest and which most space > efficient? While even the algorithms themselves (CRYTPO_{DEFLATE,LZO,..}) don't have any particular descriptions with respect to their performance I guess we can add a reference to, for example, a recent benchmark of various in-kernel algorithms (when used for zram) that is available at https://lwn.net/Articles/751795/. This way the user will have at least some kind of reference. It is also worth noting here that similar CONFIG_PSTORE_* and CONFIG_RD_* options don't have detailed descriptions either. > Also does this cover all compression algorithms? Yes. > Are we going to add new > options if there are new ones? Wouldn't a string instead of choice be > sufficient here? If this is changed to a string prompt we'll lose automatic pulling in of an appropriate CONFIG_CRYPTO_* dependency. Other similar options are presented as a choice, too, see for example CONFIG_KERNEL_{GZIP,BZIP2,LZMA,XZ,LZO,LZ4,UNCOMPRESSED} and CONFIG_INITRAMFS_COMPRESSION_{NONE,GZIP,BZIP2,LZMA,XZ,LZO,LZ4} (that maps to an extension string table called CONFIG_INITRAMFS_COMPRESSION). New compression algorithm being added to the kernel is a rare event, I also envision that not every new algorithm will need to be presented as a choice for zswap default. >> + >> +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. > > It's somewhat unfortunate that the choice options don't include the > description and one has to go look for it elsewhere. Could copy the allocator descriptions into these choice options but since the allocators themselves are literally the next set of options in Kconfig are their descriptions really worth repeating here? > Also, shouldn't the list include zsmalloc? You are right, will add zsmalloc in a respin. >> + 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. >> +endchoice >> + >> +config ZSWAP_ZPOOL_DEFAULT >> + string >> + default "zbud" if ZSWAP_ZPOOL_DEFAULT_ZBUD >> + default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD >> + default "" >> + >> +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 Thanks, Maciej