Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp865192rdb; Fri, 17 Nov 2023 15:31:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFehfdNjRvlTawWqg66DxPHD2qGP+ndLR7xtyjcO/ZFlv6eW07qBcHybQMvq5UMcYDvngli X-Received: by 2002:a05:6808:3c9b:b0:3ae:3d0:d74a with SMTP id gs27-20020a0568083c9b00b003ae03d0d74amr1310857oib.52.1700263878115; Fri, 17 Nov 2023 15:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700263878; cv=none; d=google.com; s=arc-20160816; b=mC5EXwNY9T0qZTz3qDrLQEww2SACsnL07lnzLUu7DqWwvJi/2krBEbxUxDhu/OZssv 5AEDSBvrZAGYMQU+oYfyhnqj57yJp9rAl+6sZjnWWrYN26X1ghpbHbMT21kFug1/tWqe 1bC15iCTNXAE7g6gYT+ACOAeJ2RbtKFUALyBmu/VqMhsOQR1FEToMMHTPKRr5/oa7TNJ mLn5QtWvftEuhscMTMteV3kk5QeMTZm246rXmPkZNkJfvkRgMhH+rOBJipSzoA6fKZAE C9wHDKS2Nlf/G4mBrTVdbFGJE1pjiXiOBBYdz6Gxvef4d5pDcHD/sJRnpS6zsol2BcCG 7jzA== 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=6eDL7djPiWpU1iwx3XT1f0tSrxdiI8JgBvFkVYh7c+c=; fh=m7ChAaP62mefYjgTndas/guZ525O/6R0Mq9l2biEjtk=; b=RwNss5+EqchR5Eu+lWwrq268cPAaV2JZXqARNgHu1AqhsnHVOx+gCWDioR/20xHi7j bdDSmpehM9uM6qjQxrOWYpayQiZ80DFiF7rMbJ8KvtybVNm9Pphckvta4/jA2C10R4Ep oj9ZIZciHLjbvgMsuIX5u3dntaRmdefrP18pZU7LHkPHyS++8FDuyJgKCOMG6MTaCraJ Ms/y5peiTfh3hR2SRk6cx2x37LhzqVqyAzKSSip5uqfumhUjZlY0Qw2GZ2YEvdkaiBUu VcRjUs80PWBk2k3KHjVNPg+SEezUgs6kFZAap4jet3R17o7lZpB+P08N4W/yP88XviMA FErg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=asqiPxQI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n1-20020a6543c1000000b005bd335981e2si2715920pgp.678.2023.11.17.15.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 15:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=asqiPxQI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 913348235768; Fri, 17 Nov 2023 15:31:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbjKQXbE (ORCPT + 99 others); Fri, 17 Nov 2023 18:31:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjKQXbC (ORCPT ); Fri, 17 Nov 2023 18:31:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56FE10C6 for ; Fri, 17 Nov 2023 15:30:59 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49F75C43391 for ; Fri, 17 Nov 2023 23:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700263859; bh=MxCPYy5kUatJTIY6M2Tqvw3A922+W1+I5g1OrUTLUO8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=asqiPxQIPrmTKcFb8pFg6OTUo/VlrKDTv0k4mwF/U38B/Qhz9T+gHOV/rgc9bvZfV FYWt8aFZU7t2oHZuKsFOP0cGW/rfUrPNzpw2ohV9Y6PfRT0iaO1fCm4FIrVO08GiqA G91/wxXARjVSD4D130HSIM7q2ee1yX4IQDLZDgdQwUuwEd9NJnR7uqQ0SgyG714NlG iHR1blO44GTlFcbHIFI0fxTFfCU5yolRNUAzEjLC6MIANX6TInhXj8aD/shzAIPk5W zrt4aBNmIfkf0L4hDYsVgboP31Q2xDBMX8IvBGso2F3Bvt6pN0400j+sp1NxYop40g cz7rfPHBqfHZg== Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-280109daaaaso2006217a91.3 for ; Fri, 17 Nov 2023 15:30:59 -0800 (PST) X-Gm-Message-State: AOJu0Yxxgk1tfSauiFnHsaS8zxdvIxZFMaivkAaShkA3+ABvIZ79hMCn Kp7jToz5bBT6+qOJdD0XpFjR3LF247gq3S2/bE4oXw== X-Received: by 2002:a17:90a:e7c3:b0:280:99f0:4234 with SMTP id kb3-20020a17090ae7c300b0028099f04234mr1017570pjb.7.1700263858601; Fri, 17 Nov 2023 15:30:58 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Chris Li Date: Fri, 17 Nov 2023 15:30:47 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios To: Yosry Ahmed Cc: Zhongkun He , Andrew Morton , Johannes Weiner , Nhat Pham , Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm , LKML , Ying Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 15:31:15 -0800 (PST) On Thu, Nov 16, 2023 at 12:46=E2=80=AFPM Yosry Ahmed wrote: > > On Thu, Nov 16, 2023 at 12:30=E2=80=AFPM Chris Li w= rote: > > > > On Thu, Nov 16, 2023 at 12:19=E2=80=AFPM Yosry Ahmed wrote: > > > > > > Not bypassing the swap slot cache, just make the callbacks to > > > invalidate the zswap entry, do memg uncharging, etc when the slot is > > > no longer used and is entering the swap slot cache (i.e. when > > > free_swap_slot() is called), instead of when draining the swap slot > > > cache (i.e. when swap_range_free() is called). For all parts of MM > > > outside of swap, the swap entry is freed when free_swap_slot() is > > > called. We don't free it immediately because of caching, but this > > > should be transparent to other parts of MM (e.g. zswap, memcg, etc). > > > > That will cancel the batching effect on the swap slot free, making the > > common case for swapping faults take longer to complete, righ? > > If I recall correctly, the uncharge is the expensive part of the swap > > slot free operation. > > I just want to figure out what we are trading off against. This is not > > one side wins all situations. > > Interesting. Maybe we can just move the zswap_invalidate() call to > save memory early, and leave the memcg uncharge call to be batched? > IIUC we already do some version of this internally at Google. I would like to see the patch so I can reason about it better. Do you have the link for the patch you are talking about? I can also look up the Google internal one if you have a commit hash. One thing I would like to find out is whether the behavior of reusing swap slots without page writing has been changed. e.g. Previously if the swap slot can be page out again without writing/compression again, if the page is not dirty. If we change that behavior, I would like to understand the trade off better. Chris