From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09D1C2D0DB for ; Sun, 26 Jan 2020 19:36:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 839932070A for ; Sun, 26 Jan 2020 19:36:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="Mtf7XaFs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 839932070A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ieee.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 345ED6B0006; Sun, 26 Jan 2020 14:36:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 325DB6B0007; Sun, 26 Jan 2020 14:36:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 259C06B0008; Sun, 26 Jan 2020 14:36:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 1334D6B0006 for ; Sun, 26 Jan 2020 14:36:57 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id D95DB21F0 for ; Sun, 26 Jan 2020 19:36:56 +0000 (UTC) X-FDA: 76420793232.02.glass05_3c9eb1522740b X-HE-Tag: glass05_3c9eb1522740b X-Filterd-Recvd-Size: 5982 Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Sun, 26 Jan 2020 19:36:56 +0000 (UTC) Received: by mail-il1-f194.google.com with SMTP id o13so5145435ilg.10 for ; Sun, 26 Jan 2020 11:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f6DqRhpM07gER0CIQybx4Q5yaH78YC17HKI/RuA1oZs=; b=Mtf7XaFswJSsqFzr+cwj5aK3KYVnfxsl4evwP6KLklaGe6unTp4B/A46mtnX6toHF3 Puyt8muN1wIQPnxPgShS+TUXAGwZkofrh6YzLhlQqEkB5O3Q85SbZ4zrLoLWwLPOt/y3 eRI6ahF9SZVq5PuQlsnXu5+BJBbxcQU2PjRxU= 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:content-transfer-encoding; bh=f6DqRhpM07gER0CIQybx4Q5yaH78YC17HKI/RuA1oZs=; b=uDcqltBYe7Kw060l2XVTsx57LmlesN0w6I6dBpGZYpB8wKM3gen8+0X2kheD2PBIiZ jQ+Jc+DSOH8dW0Ki5DaoARYh0kpkW1aecg0J8TupEv13RDLRbNdPbhFRL3YsNw8l1kFh MvBp6wNWsdveW75KZRi5UIybFcN+C51De9WecNf6gMnQh/T/NYhzYwYk38We1tYZj2P9 K5S6N5JZMo6zMqxP49rE69YQTrIR8UwoMi/952f2pCswDT817JFGC7M5jPVJZOdcynxD JLRd13Tdcc62Sd0p0rOWFRvql/5OJn9UtLxEdkeOBIoUu4iRBzoBGLaFJYYTW+fW0gxT wPwg== X-Gm-Message-State: APjAAAWnaHWXdAFb3ggA3Y7aMzwWCFYXythWJo6s3UmxR5nd/mBCrebR L3imsyezjoC+GZfJkG36sM8wPAoso13AktiHv+M= X-Google-Smtp-Source: APXvYqwMN5iGd9dAVOFMM57zHjMeuex3EyiB8ZwtJFN0MbLcZjIz/47yEcc/Az7MiSIXH6ZOnOG3FduwpXSoZ52Xnjg= X-Received: by 2002:a92:508:: with SMTP id q8mr6047962ile.187.1580067415773; Sun, 26 Jan 2020 11:36:55 -0800 (PST) MIME-Version: 1.0 References: <1571990538-6133-1-git-send-email-teawaterz@linux.alibaba.com> <42753fc6-e352-adcb-52c2-6b68472318f5@linux.alibaba.com> In-Reply-To: <42753fc6-e352-adcb-52c2-6b68472318f5@linux.alibaba.com> From: Dan Streetman Date: Sun, 26 Jan 2020 14:36:19 -0500 Message-ID: Subject: Re: [PATCH] zswap: Add shrink_enabled that can disable swap shrink to increase store performance To: Hui Zhu , Vitaly Wool Cc: Seth Jennings , Linux-MM , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Nov 10, 2019 at 8:58 PM Hui Zhu wrote= : > > > > On 2019/11/9 12:04 =E4=B8=8A=E5=8D=88, Dan Streetman wrote: > > On Fri, Oct 25, 2019 at 4:02 AM Hui Zhu w= rote: > >> > >> zswap will try to shrink pool when zswap is full. > >> This commit add shrink_enabled that can disable swap shrink to increas= e > >> store performance. User can disable swap shrink if care about the sto= re > >> performance. > > > > I don't understand - if zswap is full it can't store any more pages > > without shrinking the current pool. This commit will just force all > > pages to swap when zswap is full. This has nothing to do with 'store > > performance'. > > > > I think it would be much better to remove any user option for this and > > implement some hysteresis; store pages normally until the zpool is > > full, then reject all pages going to that pool until there is some % > > free, at which point allow pages to be stored into the pool again. > > That will prevent (or at least reduce) the constant performance hit > > when a zpool fills up, and just fallback to normal swapping to disk > > until the zpool has some amount of free space again. > > > > This idea is really cool! > Do you mind I make a patch for it? Sorry for the delay, again. I think Vitaly has a patch adding this. > > Thanks, > Hui > > >> > >> For example in a VM with 1 CPU 1G memory 4G swap: > >> echo lz4 > /sys/module/zswap/parameters/compressor > >> echo z3fold > /sys/module/zswap/parameters/zpool > >> echo 0 > /sys/module/zswap/parameters/same_filled_pages_enabled > >> echo 1 > /sys/module/zswap/parameters/enabled > >> usemem -a -n 1 $((4000 * 1024 * 1024)) > >> 4718592000 bytes / 114937822 usecs =3D 40091 KB/s > >> 101700 usecs to free memory > >> echo 0 > /sys/module/zswap/parameters/shrink_enabled > >> usemem -a -n 1 $((4000 * 1024 * 1024)) > >> 4718592000 bytes / 8837320 usecs =3D 521425 KB/s > >> 129577 usecs to free memory > >> > >> The store speed increased when zswap shrink disabled. > >> > >> Signed-off-by: Hui Zhu > >> --- > >> mm/zswap.c | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/mm/zswap.c b/mm/zswap.c > >> index 46a3223..731e3d1e 100644 > >> --- a/mm/zswap.c > >> +++ b/mm/zswap.c > >> @@ -114,6 +114,10 @@ static bool zswap_same_filled_pages_enabled =3D t= rue; > >> module_param_named(same_filled_pages_enabled, zswap_same_filled_page= s_enabled, > >> bool, 0644); > >> > >> +/* Enable/disable zswap shrink (enabled by default) */ > >> +static bool zswap_shrink_enabled =3D true; > >> +module_param_named(shrink_enabled, zswap_shrink_enabled, bool, 0644); > >> + > >> /********************************* > >> * data structures > >> **********************************/ > >> @@ -947,6 +951,9 @@ static int zswap_shrink(void) > >> struct zswap_pool *pool; > >> int ret; > >> > >> + if (!zswap_shrink_enabled) > >> + return -EPERM; > >> + > >> pool =3D zswap_pool_last_get(); > >> if (!pool) > >> return -ENOENT; > >> -- > >> 2.7.4 > >>