Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3039306rdb; Wed, 15 Nov 2023 20:11:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6y4oRdQefec8Y+M9ebXvvj4mM6kMoRun2F1C4LycY9vUu1RpUHzE7Qf3QPoKbq7p27DWq X-Received: by 2002:a25:da91:0:b0:d9c:aa50:2b5a with SMTP id n139-20020a25da91000000b00d9caa502b5amr14464464ybf.53.1700107876787; Wed, 15 Nov 2023 20:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700107876; cv=none; d=google.com; s=arc-20160816; b=QRMx8tsozCDhLFak9N7HAml7DYE9ZnNUD8CV5GN4YxhL8DJxbXdpyZn6wxQb2Ngl8z me2lJQIs/WDW9lSrgxbDrH7VdJBoil6tq0SDilKJKIe996b2S2cHKiQ200XJL4upFmzB 2eJeCinkgFKwQH7J0epZ33XXdZg0jhihsQoCMZs+grCOTo4Icej0c4cmuht0uYHo7f6D DvkarL9mUp63+7hMXHhubPpKi1xwqFpv0RHfEGEOXsUB9DXDTLk6H4q4V1ysOl4MrPt3 BNnKnfowZFf5Bb4lbc1qGbtQbZmv0lM4n2hBwnQ/T4MCcZ2X8XIQ2BsnKAbLfF1EdeBv Wcjw== 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=DMzCj5P9fSwcVXlU8EVUh+tUUR0usCMZQ9ylB0bPUZA=; fh=pqk2R1RZLsBQ70p7jAhErtrSV/ps7OkqUE3XKBCbhh4=; b=uSsikUJw2jpP1LYjaCWPnsvl1bOJQQ1pEVPy3VeP63Oa7QXzM3WzEVrTmLctaxOjiV HY5e2Q36cfcIx2JYvMgTD6lpPg2PJeWkEdGlYPUS64PadXhETSau5m8a3/ZV7IEWIyXe Z+WkHyvaQowPjGWkNZ0Rtvy1a/iwV91Nx9LX7bOo5UsRDo/LZ7VbxNq85hsErFwtp5Z9 bmVgV3VRXJ0EDzV+YyvFK+yR4W18WXPlCtIYmgT9Jnnu5x0P6SkHQtry8ivZo3x+Kx2/ GGc57Aor/15ZoKnN04R12VtLxMzRC3BJDFttUD13aJ43T8z5Qm8Amrth06OEDn39Asgw IH3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=d3D+e3Ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d8-20020a056a00244800b006c33c8497casi11525654pfj.222.2023.11.15.20.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 20:11:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=d3D+e3Ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4E2E580787F2; Wed, 15 Nov 2023 20:10:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344645AbjKPEKf (ORCPT + 99 others); Wed, 15 Nov 2023 23:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbjKPEKd (ORCPT ); Wed, 15 Nov 2023 23:10:33 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DEB4194 for ; Wed, 15 Nov 2023 20:10:28 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9c2a0725825so51794466b.2 for ; Wed, 15 Nov 2023 20:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700107827; x=1700712627; 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=DMzCj5P9fSwcVXlU8EVUh+tUUR0usCMZQ9ylB0bPUZA=; b=d3D+e3ChqnUGtmInsc+rNIkmB/0k1xnEnUWVpOu9+ZlIg4yE0aeRoFbe/Wkr78xud0 Dk0GD8NaPfcXpcI0LK/crIKpx64j2L3qqXDv5Rx5PupRRilfcoMxz23lCjWBGSkalPvR qD0fR8Kun3G+d13o9wDnMBkb9ry5vPYVdcKitOB46iYmrRSI6xyEx2LfDX5mQp9te344 WMicVSeB5PLdZLNy7QJB0NooqEBmgTKl9ypyZjj5/sxCpcEv7Uc3VmgMHQ/WDIEQrjwJ t69bJvMBKCOvRAq7z0+hUGerelD1E8EALMfZS2KEmhB8o+ygtSOdnRbq8UfnnrGMcsAs on9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700107827; x=1700712627; 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=DMzCj5P9fSwcVXlU8EVUh+tUUR0usCMZQ9ylB0bPUZA=; b=N3TwwbzYDSqR17qHJOH96sEr4D+dMqdpU6ens/HejrYgRA1nJB1RO7R6ZiWJ0broiF b42H/BieuGCwSDWCz7ezZxZN1Jozw63kLGCCMWm8urwCeLSovvbW6bJmyUsjubQsKq4b bC4HNpZQxOrjQAvy3B3INzIu9XHJ2D7lUV91lmJZA8I/zyK8n8za/8ngLOqA7vPS/tH6 l6hG6ocO5s4/p0sxYP0NPyGUnMecdrD1qqO8dbuZ3nGmBe+srwV3gAWIkwFEWhmnvUik C4PnUB74qRUGRoP6mHKhQTAF/d4J6ce4jcx4KvAJjIF7FY+/F5zt7ll/1xPUmGPNHy/v uRhQ== X-Gm-Message-State: AOJu0YwcaTvj8ThTNOI1Pg8XJLg+tuRxjsOtRmgdFijHXLmlVndRwhf2 FGdrkaHzaJZ12iwt3yIhYuycsTCnkFGj9hzaZfckzw== X-Received: by 2002:a17:906:b10b:b0:9b2:d554:da0e with SMTP id u11-20020a170906b10b00b009b2d554da0emr871908ejy.69.1700107826785; Wed, 15 Nov 2023 20:10:26 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Wed, 15 Nov 2023 20:09:49 -0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios To: =?UTF-8?B?6LS65Lit5Z2k?= 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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 20:10:42 -0800 (PST) On Wed, Nov 15, 2023 at 7:33=E2=80=AFPM =E8=B4=BA=E4=B8=AD=E5=9D=A4 wrote: > > 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. It can be enabled at runtime, or enabled by default by using CONFIG_ZSWAP_EXCLUSIVE_LOADS_DEFAULT_ON. > > > 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. The reason I added it behind runtime and config knobs is to preserve the existing behavior in case someone depends on it. At Google, we have been using exclusive loads for a long time. If other users of zswap agree to make this the default behavior or make it the only way to do zswap loads I don't have a problem with it. > > > Thanks.