Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3026902rdb; Wed, 15 Nov 2023 19:33:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IF90FClpMkb42vVD4DzmhJHZ12R4QTvQ2J+aRDxg+t3B2LQwP9Vf1bYTogmi3mWLMXYEIE1 X-Received: by 2002:a17:903:494:b0:1ce:1690:2d3b with SMTP id jj20-20020a170903049400b001ce16902d3bmr6426437plb.52.1700105612189; Wed, 15 Nov 2023 19:33:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700105612; cv=none; d=google.com; s=arc-20160816; b=SachFFnQr+Tbtn0EENnGbd0yYJXKFzDbThnEAjB4QhDFeWMA6J5LmMagW6Goo2z1aW 2As8XWDRZXuCjDS2a2unyvsZT/F5Mx3aIV/NGpUYKwj9AD7eMiGQXrtGcJwosi4UfBEU vEUOuK64MIiMDrWowlwUJV7KL6MhbKS1By0F1BTdTcHNoLxgRSbfxoaQj/Hd5+iKDZNy kP3fFBUN0LjTnwxalGce0V0rR7V3Yy8y849vlZPP3uYuazaOc74FBY3RRFhM+0UD2JlH B+ozkwi+qwWtzrOjz3lcUSnn9960T87P+0FSMWy1MaUQVgQdcWpvmb+54/e66bjRsaVi T6EQ== 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=UpqwIukJN4pe5ng/7gTK1zs3f2lJ5+Nh8U6l7DMo/Ls=; fh=Z/slWphgmX6QJKb1htDfNZvLrT1b2fPU4vG8qFrGdBs=; b=dU5V8RUmZOvwDuUPjSLWbUr2oKfTwBeYG+dInXrFoYMgrhZtq2nLgp+B8d80Kjel/V uOBdgN7h87HEifZPcX4wRZJQJZY54qWaJvLroyYMxdrgYhw/zGGSy88EFBhEcrw7spE/ XQOWzJBD6QUVyP5HpujTQVcro2Ik4SODaRyvgPpGJ91pfk+HYbv6Kl2gM1s5icBmFRn6 0ohro1QkfJAVJerc9eNIFlS5YwxNDPgq4QVRnSBLMKBnrLQVlifLjacMWdAFjxhnqgB2 uAYR0uhdSJn5RwSgJsz6AbOejOXXVFRy8TFGE51KgOEvBIeJFXx/XY4/Wg+7xDRDxnkA Pvjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=PfNuS8X9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ix18-20020a170902f81200b001cc51ee5fb1si10950919plb.585.2023.11.15.19.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:33:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=PfNuS8X9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id AC63380EA4FE; Wed, 15 Nov 2023 19:33:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344454AbjKPDdW (ORCPT + 99 others); Wed, 15 Nov 2023 22:33:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKPDdV (ORCPT ); Wed, 15 Nov 2023 22:33:21 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CCFBD5 for ; Wed, 15 Nov 2023 19:33:17 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5079f9ec8d9so395465e87.0 for ; Wed, 15 Nov 2023 19:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700105595; x=1700710395; 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=UpqwIukJN4pe5ng/7gTK1zs3f2lJ5+Nh8U6l7DMo/Ls=; b=PfNuS8X9GvIHbI6c+MqurPcSzltGr+ljl+1NakTd6ccbbrdohyKfzpCrUBz3IZCjAV 3nZiEpHDi1mOGVhZnmmEmRCuN7ZeYnoaP3SjxtfS3M+zJP9O9pVMun5WQVS769fNLijT tvqSI0cyl0QqArAjphhNQ2rqtj6914Sg1TxrMOjNU6fdZtHtNpGIG825l2QUlfQ5BpHQ euUsLU4zry/n3ZJHJodaT3VA5S9omSG+ZbE+OcVUBNkSckXx5W+CbVC6Ru1JiQoiBJ3S eCqGpAg1Epi5AGjsKQaxI9Y8DoqxGhY0UOKv4T7E/Bg3b2DscJeBBcl9jKIiLvi73FaC wbZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700105595; x=1700710395; 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=UpqwIukJN4pe5ng/7gTK1zs3f2lJ5+Nh8U6l7DMo/Ls=; b=io5zF8dGHTE9CZJuXsDnL2qX0otkWBIJ3OjF/3BWcSd6YNLRJD4UR6O5CRrkjqf78g euxYLYwZeY2RSetrdENjfmSjCxXVipuffci8kmUWIr1wER5JIrrBxbjUc+Lf7COrWou+ 5ZAFcfR7aOb7XXNfdx9FMzDr+RjO+L0JLkEw8QloRaEan+q2vbRRrqfdN5P37c4Dtrvr n4pdhSQN+hGBlCNOUjYJEdCZiLkn77P+/+M421LdnJTv+ZsE8eVwDgqKc2rjmPdOT+WG /NAsnpOAJ8IdaWuGImFW7VfkF29AbRuOnbxw+QJKi/EVoqi9xcKH9RUYcbQxf7tZWxSm BfRQ== X-Gm-Message-State: AOJu0YwCTnAP4KwUDd1lRUQY+nI2GItlP7Ma+17eL18CDBYuLiiydwUj AYpxlmq00Y2YJj4Mzit7xjfI+g5ibxYA9WIw5/7w+g== X-Received: by 2002:a05:6512:b0f:b0:506:8b41:7e31 with SMTP id w15-20020a0565120b0f00b005068b417e31mr193547lfu.6.1700105595568; Wed, 15 Nov 2023 19:33:15 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: =?UTF-8?B?6LS65Lit5Z2k?= Date: Thu, 16 Nov 2023 11:33:03 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios 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, Ying Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:33:29 -0800 (PST) On Thu, Nov 16, 2023 at 4:13=E2=80=AFAM Yosry Ahmed = wrote: > > I think we may need to try to lock the folio. Otherwise we may race > with reclaim reading the dirty bit before we set it. > > Taking a step back, this seems like we are going behind exclusive > loads. We "should" keep the page in zswap as exclusive loads are > disabled and the page is not yet invalidated from zswap (the swap > entry is still in use). What you are trying to do here is sneakily > drop the page from zswap as if we wrote it back, but we didn't. If we want to reclaim the cached zswap_entry, Writing back might be the easy way. > We just know that it was already loaded from zswap. We are essentially > making the previous load exclusive retroactively. > > Is there a reason why exclusive loads cannot be enabled to achieve the > same result in the (arguably) correct way? > zswap_exclusive_loads is not enabled by default, so the shrink_worker may fail if there are many cached zswap_entries on the zswap_pool->lru. Is it possible to make zswap_exclusive_loads the only way in zswap_load? It only makes sense when the page is read and no longer dirty. If the page is read frequently, it should stay in cache rather than zswap. The benefit of doing this is very small, two copies of the same page in memory. Thanks.