Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp981068rdg; Fri, 13 Oct 2023 07:03:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpaRoFh/N+GEp4RrGZOVLIFix9kebe2kurrty6gGBPCbd5vB9awystgk1Zf3D6g6fXohEN X-Received: by 2002:a05:6a20:6a25:b0:163:f945:42da with SMTP id p37-20020a056a206a2500b00163f94542damr30900242pzk.48.1697205780882; Fri, 13 Oct 2023 07:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697205780; cv=none; d=google.com; s=arc-20160816; b=bma5+ZiMMkUR7GqjnctzoPtvnc2i2o0Az/YdPCWYtYF5NviFGVC4OchdpIAbIQpaoR TKdTk6aQLT4aQ2TRoR4ca/92IFT8PHYj9EZmiTFRGSOidoHet4qU6MaXAEC7pYMG2B6h qQgr2ZejPzI4e04OJXg2ikGwkOuFYNsbcZVFFXXq4iKIzzHC+fiW+hKdkcbsCmgn1z++ CFsCFH7AnCPIcQ3UAtXb/5rDppm0I/2X7RQ3oOSlbv8kSjpzBCT1HGq8p2Lqf0cnebPl 8nYRVXGI1lBoYsubWulcordxzkSbUmTm27kUTJBRkYbqK4p2OtQ4t3H8EAP0YAFQMvkE S5wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=4F4Q1hPIpiSX7DqkBD7+SomvxsQ8tXqGNsU/QJenPxQ=; fh=B1EnIH//Z6vJHkSFvAtRUBexvfLQ5qmwwhwzjivV41I=; b=IpF4zRkbbPUoPvdzwG4hn1J5Z5PI7imOUfyq2ToBEkdzbm3LInR7XKPLAs/1bBsxjs EfzQqtzAuxcNV3AtFQ1s4V/4N44ZqVc3HYOP/mH0o6PFdCnFfsCeW9E8V59y7KYI2ThX 4kMyjuexWaLUM2g8y+0Z8FKKnFni8ZJkFc35c5nszO/UUJXG75A6c04OSUbZtHGFoaRK RNexAaaFCNrISImRfQjebSlcc0vlc8B9sGviEYKuTVSJ28mBrUoZX0TIoijCDZ4OL28F iBQbChfbUkEquEbgTAViGuMANMGeoDqcmoWt8ADWkmBfkKwy76eUKqcTVu9UbS7poMd2 pclQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=KdEbHdWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e33-20020a631e21000000b005783367f97fsi4553993pge.342.2023.10.13.07.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 07:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=KdEbHdWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 94DB18031AE7; Fri, 13 Oct 2023 07:02:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231489AbjJMOCw (ORCPT + 99 others); Fri, 13 Oct 2023 10:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjJMOCv (ORCPT ); Fri, 13 Oct 2023 10:02:51 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690DABD for ; Fri, 13 Oct 2023 07:02:27 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5068692b0d9so2707369e87.1 for ; Fri, 13 Oct 2023 07:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697205745; x=1697810545; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4F4Q1hPIpiSX7DqkBD7+SomvxsQ8tXqGNsU/QJenPxQ=; b=KdEbHdWX1lq9B8+lag6MBPAKmNGZXi8Wi5tLD21lIdKh5NmXH/rMr3OXhl+Ld3bfgh jhYu6lcxLtbhorg/R4pgH+infUGbItYhSpR3RLpLjqhzwPb7s7Q3L8Dj/8kWaxCQxorL tbk4XeuR9CAAZQTd16nTfL3jKhGz+veCjtw16DQgvIPhXw4fJ05JLOCV4TshDhNJHv92 Hhbev6HkrZd/jRha9gSsQtei/3mVe6Gk3SwuPAMibgtQ9TzXyxt5uiEEY/6tq+XqW6qg 1Quo6hN7aChxQrfK4d6P617U7B0u3HEzvH9GMM/dpfia0P6jNIDiCiH/eCaOvln34L/b hXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697205745; x=1697810545; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4F4Q1hPIpiSX7DqkBD7+SomvxsQ8tXqGNsU/QJenPxQ=; b=UvRevE3Ka4d9KA+/cBqHkdlQ8HeK6Ph7XbUeB0hdaz7uMyvpMriK8uzXGlLj9/Tfdt mLWradLu48zdGC4YkCeXdhhMw2cGuXnpjtgtgvrhP+CvFPhEl8TtPC2D9MpyAYx33VM5 aPcjd6S+MaA9sri+nWD7gGoKUKuU9nVtKY188EClE85HCq5RNfJOJeT+q4AVhrYz4Xz/ 7WAboVzsLpdbbUy38SYGfmKw9aPOV9iHAnTFlGEtciJrDS1q9XtXfMFpCJfo7y1r4NHK J++LG1j9SRXxm+YQjykCvCE00UaRJntR23abtvAtdgrMq7haIr4bzT5yCsit/lFfzyoc Y/ww== X-Gm-Message-State: AOJu0YwitN3yre1/rE53IP1/U0oSi2WAoHp9OjBGNoUY41DXt0yjoQQo Rd5YOMpZQOG6dXHDwOlxEoHbtv+fQ1QyCyDjCOA0Vw== X-Received: by 2002:a19:6754:0:b0:503:3278:3225 with SMTP id e20-20020a196754000000b0050332783225mr20512405lfj.63.1697205745635; Fri, 13 Oct 2023 07:02:25 -0700 (PDT) MIME-Version: 1.0 References: <20231011051117.2289518-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: =?UTF-8?B?6LS65Lit5Z2k?= Date: Fri, 13 Oct 2023 22:02:14 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH] zswap: add writeback_time_threshold interface to shrink zswap pool To: Yosry Ahmed Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, nphamcs@gmail.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 13 Oct 2023 07:02:58 -0700 (PDT) Thanks for your reply. > I prefer if this can be done through memory.reclaim when the zswap > shrinker is in place, as others have suggested. I understand that this > provides more control by specifying the time at which to start writing > pages out, which is similar to zram writeback AFAICT, but it is also > difficult to determine the right value to write here. > > I am also not sure how you decide that it is better to writeback cold > pages in zswap or compress cold pages in the LRUs. The pages in zswap > are obviously colder, but accessing them after they are written back > is much more expensive, to the point that it could be better to > compress more cold memory from the LRUs. This is obviously not > straightforward and requires a fair amount of tuning to do more good > than harm. I do agree. For some applications, a common value will work, such as 600s. Besides, this patch provides a more flexible way to offload compress pages. > > That being said, if we decide to move forward with this I have a > couple of comments: > > - I think you should check out how zram implements idle writeback and > try to make things consistent. Zswap and zram don't really see eye to > eye, but some consistency would be nice. If you looked at zram's > implementation you would realize that you also need to update the > access time when a page is read (unless the load is exclusive). Thanks for your suggestion=EF=BC=8Ci will fix it and check it again. > > - This should be behind a config option. Every word that we add to > struct zswap_entry reduces the zswap savings by roughly 0.2%. Maybe > this doesn't sound like much but it adds up. Let's not opt everyone in > unless they ask for it. > Good idea=EF=BC=8C Thanks.