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 3B356FA372C for ; Fri, 8 Nov 2019 16:05:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DC1E320679 for ; Fri, 8 Nov 2019 16:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="OGeRhNwU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC1E320679 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 8CC916B0006; Fri, 8 Nov 2019 11:05:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A41D6B0007; Fri, 8 Nov 2019 11:05:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E1886B0008; Fri, 8 Nov 2019 11:05:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id 6B0566B0006 for ; Fri, 8 Nov 2019 11:05:08 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0ED72824999B for ; Fri, 8 Nov 2019 16:05:08 +0000 (UTC) X-FDA: 76133584296.07.cough78_fa8683ceaa4e X-HE-Tag: cough78_fa8683ceaa4e X-Filterd-Recvd-Size: 5147 Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 Nov 2019 16:05:07 +0000 (UTC) Received: by mail-il1-f193.google.com with SMTP id u17so683229ilq.5 for ; Fri, 08 Nov 2019 08:05:07 -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; bh=WWhxxwtXBsYr3ujNQbOniWk+oJ9McNvg7ht/PhD1bwA=; b=OGeRhNwUh5ZORqAH7nioyjRY3n4m1e0tf7rrXmZWM/nkvzRr+Jz78odb6aMdX1AfNN Gj0OXw+m5mb4FIsAEQ+hGtoBqv5rLgdhs/nG8KK8+8iDA5oofV8DmgMds9VPfp+IAYXJ jRi/aBENaspw3XTZrzU6IXgDDs4peaARaEpbY= 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=WWhxxwtXBsYr3ujNQbOniWk+oJ9McNvg7ht/PhD1bwA=; b=BUDdEfMtsh1f3VvLN5oKo+Jyiiv1OFYe6o3QeysnEhYtSNaAtymPOaJ27JMwoVlBlg YFNe2AVjNaiICxleKr3z6Xlwns7uur1L9O89Dhlmu18A4l4yTZgGh9Xi239R6CB7kdCl PEIe0TeAfl/4fLVyj3voEkl/yUjRR89vL/iYY6KciNyXxYpKaXUsdR7P8kTwvthswlfG WLZxpWnGOEwuhTlXfQlt0rDNPPd3yLJHvmAVRuG0a7GnUxUfuwxArDME2H33ALkj+oM2 DpZ5gpalwN/AwKAqo2vX03NbgrQXOxxMHyknK4+7p33zSdYTrpasomv+pvmWwui1wZve NkLQ== X-Gm-Message-State: APjAAAUTGp0dfKxSlQrcnVHcPyRzlBJSRqN3rbccLnSbcensuS+4wa/J CJCAQCxWmsb5Nr762nEdaN6+XtCCaeEbAUGMCPo= X-Google-Smtp-Source: APXvYqyMR9OW7SeX51o9tfRFIg3JQm5oVrpif96xXuOURB6DQd71NN/ekFza/Eww6hYPI147Lbj3qHHvKAelLBLe7fE= X-Received: by 2002:a92:a189:: with SMTP id b9mr14223728ill.259.1573229106630; Fri, 08 Nov 2019 08:05:06 -0800 (PST) MIME-Version: 1.0 References: <1571990538-6133-1-git-send-email-teawaterz@linux.alibaba.com> In-Reply-To: <1571990538-6133-1-git-send-email-teawaterz@linux.alibaba.com> From: Dan Streetman Date: Fri, 8 Nov 2019 11:04:29 -0500 Message-ID: Subject: Re: [PATCH] zswap: Add shrink_enabled that can disable swap shrink to increase store performance To: Hui Zhu Cc: Seth Jennings , Linux-MM , linux-kernel Content-Type: text/plain; charset="UTF-8" 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 Fri, Oct 25, 2019 at 4:02 AM Hui Zhu wrote: > > zswap will try to shrink pool when zswap is full. > This commit add shrink_enabled that can disable swap shrink to increase > store performance. User can disable swap shrink if care about the store > 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. > > 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 = 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 = 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 = true; > module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enabled, > bool, 0644); > > +/* Enable/disable zswap shrink (enabled by default) */ > +static bool zswap_shrink_enabled = 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 = zswap_pool_last_get(); > if (!pool) > return -ENOENT; > -- > 2.7.4 >