From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2A62C47071 for ; Thu, 16 Nov 2023 04:10:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0D5C6B03FE; Wed, 15 Nov 2023 23:10:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BBC626B0400; Wed, 15 Nov 2023 23:10:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A84106B0401; Wed, 15 Nov 2023 23:10:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9A4AB6B03FE for ; Wed, 15 Nov 2023 23:10:30 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6AB69C0B50 for ; Thu, 16 Nov 2023 04:10:30 +0000 (UTC) X-FDA: 81462490620.06.A013483 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by imf28.hostedemail.com (Postfix) with ESMTP id 981ECC0006 for ; Thu, 16 Nov 2023 04:10:28 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WZSsbZlb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700107828; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DMzCj5P9fSwcVXlU8EVUh+tUUR0usCMZQ9ylB0bPUZA=; b=GWpXv0+aWhFCuLhodvqHaFgZimDUMLY7obuylpkPuXaMgkBdWx0vaV2Ep4lL6npaAPa+2R 3/slmQviwMFpO0LYKHX3b39mV2pAd+rzeCBjNtjrSXK+Dor+LqOiwZ0zg13/m49j0ZWZV3 yjjyICQZEzYsRmPh7kk5uEU5Z6NHcjY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WZSsbZlb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700107828; a=rsa-sha256; cv=none; b=snkVZrabfvxZOUoRo/n2SCd5Wfxeui2De2tP0KDtha4ApAu433WSlbVLSTlfAnOpafzmIz PZqSVOBTl99JOZon5IoYLqIIW5AHOD2RwDGg3BzvfT6XtlhgMVpunlbjYuBEY+4GFEHitu YWOLuOqyFrfAg1dybg8PxpC/5f1Lbqs= Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-9f282203d06so54647966b.0 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=kvack.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=WZSsbZlbjEXwnNa2FBo3i+dkHkTQVuON256AtsAWyNYgKrMRCsqxGPJ+Q/pn+oLAvm nAmq0RaEXtGxh8WmsS9fVGEhetZnENto73t4MBC0/FEfPR4g/MC5DlypOAbAxiiE/CeQ gbk81JttRj/RB3dAOlYLxYoiTFWxoviM45OvVQsIDE2U8f/I/744bEL8O76ozh1OvVmL V55T/rjJ7o364N8aNb8cWjlgfZmKI5YZjwam4oDcGSI/bEgUSdCH1ikz9krrFlBQJlYV qSPEm3OjIgrCrzu8RBPJISyAdOFPYrNsfh03eYakBeps7Ip3kO4dInAYUn2XbWlkMEP6 ingA== 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=BrH703/IXNiibzMvLkFtLCtEq1v8mO9C3KwQbimrtFFxcrupXfGiB+udz1UoooQGvI 9DbSuLnpr7DBFvpo7TZiq4CBnMchb4Mp9Em6+FjNwznG74FlOCzQUCeSe4nDVrTa+iu4 YlOoTcPA96HhwYj/fQoLg/95NQ6BlXhCfwLYM+HsRCTp42gZfKauolsktySchWVwKXPF dtlK/vozMXXmI+jfyorrzMWa8UvnjhffBqd46+a6Jml1NwDTIMiCXf9i1Z87aOEru9x2 3PqebWmGplVsd2URRVKSnoWasHxLKnlxcD39J8nAdsDFVb2oCJuWCQ40+rRVqeN2uY3B iavQ== X-Gm-Message-State: AOJu0YymunWXNlATGNvKjsTeWy299STSlkj4PMQhBHhMqqTSsfIve9+z +pfvVt9znYcM8oJ5PpaKkv6Gs5AYImDwI/zsEoOowQ== X-Google-Smtp-Source: AGHT+IGJFFso6GmC8lJdP1PBOxHgcqZtboEIbXbEOVelXERWcSrUeCiqT/9/q2VHeLGt1Dc9I5cx0u8N1C1qsSLTwoo= 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-Rspamd-Queue-Id: 981ECC0006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: a8hfku3drrbp5477otjmn77ec56697gd X-HE-Tag: 1700107828-882632 X-HE-Meta: U2FsdGVkX1+/GCt0iWUL2Y9wNyFtAqmVL/Ne9Wsf/ADyCXEiP+2MWgyuWUrEdkLftu3EEPf+7x+7k8IUKAym1iWO9KG9iw5y/9AIzYk4uQiFyRh+NKmi0zBesdWrZNmE8OKjLKEJ1zC9wNb/G/eN1H5LfJ82CCYVG7NfeNRE309qa78pvLzEGTpivnHH4tPuvD3bAwdsYc/TgIzxUcYcEwAc536/POeIu/emZkL28a1uez5jkY7emO71yDUwRb2Wr2BMfWPbs1w8s7mQ5zGtuewOMhsUgf7P1Ja+ZFrrZQhNXyEW4ZMeyM7qLt1BXNTtsSJQxYlh+8yLybShBqZoWFEMrN+jCwSfJoDr6jSQYp3ZFwORWwy9dFtUw/DpzcqamwFrZVdBfBHT1y5MO3/oXLKnND0pjrbf6r3dZ7UcSHj/noMMd8jLplACOin13KC+RhqL65yghRjfggECwR2dAwWrTTTHj7WPu740HdURDkXoxIhgByzcFKNLpGVaPw+PAlj0QFf1pZ8bxRt3vb+MaHdcvVOHgD8I/zJ6PFGg6kqe13Y/RRE+ummsfhpkHW9H12nFrZedZCnldVzPkT/OebYQrKmFyeL765kpdZpnHkOaRNkCQVctdC0DtKb3A+hRA1sSM+2LtmvQ1EVJHzm+GjKJcqlxzH8EEDt6rkXfnCmUPZ7fYySrHuSNfetfpK2/yKAjlj7CNjCxWHYJZQ4fpscOfBqkC8MjC824C7XGANcprjQCCqx3gEIOom2Rrf8IbeGbNzM+BLMY7hR20KPcoNP+yoNf8UK4miSJwTF7Y1ie44lJ+aAgTycbOKD3f3oDxZAi/nFuZFELQz0yKPbjO3GVusQNthNuoL8fAucggTrbRGDt/aaW4qTzbjErOS8GNYm/iSErmZoGWiU3UO+yPlfl1twCMzBpTU2n4xE+8A6y+BjSdkhRuMaNG/EAMGs96U3HNYNZ3q4YFSNhuFH HL9ecS9+ nam2xJNky4adkYWBWHpo4lssmdG1zYTM5WOxwN7wrO9yp8Uj8mQGtHJERdoWoYrCJfJxUYDfVDFEj4k08Ime+52wFiO6HI77XINv/6CxNXX5CVZwrCgb1K3wjFlLcVBbVKrGEaKdojcIuoquNjLE4FV98In7eiRsvbo701WXFO9yDJOmsBnfh2OaGEA3/rxqhjAxos067ZKFABjeIE1q1aNyTEfdOiknGMizxB5zJ6TCI6bY6ZVpzkwKDctmauQYJNNihzkoHILcbYEr9/8dW06htT/O5mFNl/BgzoTb+uDYN/J+kHcUxAn/cww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.004699, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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.