Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp73476rdb; Thu, 16 Nov 2023 12:12:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6dfOPRs0PfsHT2idvvgduNkwQAmmuPpRh60vmxjF4K2Yqp4c61Tz2OUmjr8MoyDMNi3vQ X-Received: by 2002:a05:6a00:3a2a:b0:6c5:e1f:184a with SMTP id fj42-20020a056a003a2a00b006c50e1f184amr17901839pfb.28.1700165557722; Thu, 16 Nov 2023 12:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700165557; cv=none; d=google.com; s=arc-20160816; b=n2cH1E5q+oZbU5RK8LCuka/oPcvM2TV4BFyGSE9kx7LgyyYuYE2R848/1LV9LEkseS QoPMBa7LofVY92IRbiI9GvDC/CsuxgNSFAatjr9JTICYKVbDhszOdj+OCgqdEQiAeITv Tnrvm3Cr5hnnm+I4AFonr7dhfrcJy06cBmm6sRaN3sl8+0ZVvlKnGfUFO53ea8BjEHa+ d1PGX7LEjlX6X5LazJHW0B1UWet7iWT/C20pE5JHxet+0ojIjVRvNhhZ+gcrz4XMuu5G NxXr+x59/hFoqyI3HNFqdHtWErRQLIcYDGThf+B4JCTOA6iDUSAg7769Pk0bu8QO0J7z 86mQ== 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=xEyEPOduZvXsW6JCW3EvIV8l1fEfOk8Dt8YmxhMEDlg=; fh=m7ChAaP62mefYjgTndas/guZ525O/6R0Mq9l2biEjtk=; b=my8yPJkMdnHDwbsYE9RO2HoyCV3oK/+HPpXFaB0hapVF/AhzcTjLhCf04HyC4/VNix uj5gkL5buuGwzzSEvpRftwcDwjHIFS0XsmMV/BQONohp6aYU4qSUKS/FzdjIxegdKdlG 9yfRTEDGNeCCjDqWyvaH0wy8Cid53rkFee8bADMhn5kmEYEVZkhDfX2PXGf7ITzEqXR7 fUC4cszemoFJwSo4w2t6XVpSCWxY8vV9HaWtOPEm2c0i/J3hUEQN7XPq408qxVIV8i0f Q1p8yPGcuAT7/LC4ygENsYupHltaRTiWLgSFdEX6tXrHbNQFvEj3EG6x/BMDoseKfSFe 04ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G+VhEEeE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fa16-20020a056a002d1000b006be30cdc3d8si246236pfb.163.2023.11.16.12.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 12:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G+VhEEeE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 0B12C8260E7C; Thu, 16 Nov 2023 12:12:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345529AbjKPUMK (ORCPT + 99 others); Thu, 16 Nov 2023 15:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbjKPUMJ (ORCPT ); Thu, 16 Nov 2023 15:12:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94E26131 for ; Thu, 16 Nov 2023 12:12:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 161AFC433D9 for ; Thu, 16 Nov 2023 20:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700165526; bh=C5Ag1NQb4cc7th3TofT7+5tV5THCDr4smloIfN3cIT8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=G+VhEEeEu98nDD/uX+PWythEgk4mnU5QndLxsSN8himE0uc4GEJ3FnzQxjc+Vpv5D ktSPawRpgT91Pr90Ed9n5No+1Ry0O8mjccIgnf8qwZ4AZxv0Bihx9gE01jpSLW8oIM +oO5s/d6f8Ay5qO4Q1MVJvbMXsga+X8AoJipTbdrrmXjOQpnlUp0xLTathTRWiH92J 7IDMLHg/mB+YlrdXHGZ+O1T4yHJMtzOVMacGgKneYzHfofmi9F2XEKQVoqEq40Jbhm YonHu9ghVYABG2A0UPgAVvXHoMJwZPaWw8uz441RaDiz8Dt2YK/5qypu8xu8pk5oWr xExUyv0Mtp2Ew== Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-280351c32afso952141a91.1 for ; Thu, 16 Nov 2023 12:12:06 -0800 (PST) X-Gm-Message-State: AOJu0YwBdvAFdChB7ARff+F1a3ovBMozCK3Wekw8Kd0Q2SMhsLk1Zknb cQgXkBPLdEOxYisA/jbedCw3bYQSVWMtq5NeRkSj4Q== X-Received: by 2002:a17:90b:3b87:b0:280:a69e:45e5 with SMTP id pc7-20020a17090b3b8700b00280a69e45e5mr17271341pjb.44.1700165525441; Thu, 16 Nov 2023 12:12:05 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Chris Li Date: Thu, 16 Nov 2023 12:11:54 -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.3 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 16 Nov 2023 12:12:35 -0800 (PST) Hi Yosry, On Tue, Nov 14, 2023 at 9:16=E2=80=AFAM Yosry Ahmed = wrote: > > 1)The swap entry has been freed, but cached in swap_slots_cache, > > no swap cache and swapcount=3D0. > > 2)When the option zswap_exclusive_loads_enabled disabled and > > zswap_load completed(page in swap_cache and swapcount =3D 0). > > For case (1), I think a cleaner solution would be to move the > zswap_invalidate() call from swap_range_free() (which is called after > the cached slots are freed) to __swap_entry_free_locked() if the usage > goes to 0. I actually think conceptually this makes not just for > zswap_invalidate(), but also for the arch call, memcg uncharging, etc. > Slots caching is a swapfile optimization that should be internal to > swapfile code. Once a swap entry is freed (i.e. swap count is 0 AND Do you mean moving all swap slots free to bypass the swap slot cache, even = it is not from zswap? That might have unwanted side effects. The swap slot cache is not just for swap files on disk. The batching has the effect that on average lower cost of freeing per entry. > not in the swap cache), all the hooks should be called (memcg, zswap, > arch, ..) as the swap entry is effectively freed. The fact that > swapfile code internally batches and caches slots should be > transparent to other parts of MM. I am not sure if the calls can just > be moved or if there are underlying assumptions in the implementation > that would be broken, but it feels like the right thing to do. There is also the behavior that if the page gets swapped in but hasn't changed, when swap out again, it is possible to avoid writing the page again to the disk. For disk there is no overhead keeping the old date on the disk not to touch it. For zpool it might have memory overhead holding the compressed pool. The trade off might be different. Chris