Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp435149rdd; Tue, 9 Jan 2024 08:30:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFn/nYdeyNYXN3PtxhTTGREpv4iLIfr3l+wJ263WOPazb2GbebU7tL1Z+oN3WTTDP2MV+q X-Received: by 2002:aa7:d993:0:b0:557:7e5:1c46 with SMTP id u19-20020aa7d993000000b0055707e51c46mr2873354eds.65.1704817821347; Tue, 09 Jan 2024 08:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704817821; cv=none; d=google.com; s=arc-20160816; b=SZn7TGjR8nkg7WoCnTli66TRt8nm7g7gW2b8Rat1RWC1RuJvQyAHES8mFNhxCOeOEq c25Qh2nPufWlE8gCydp+2EAj1s+SnQsFmc70v2ZUOKl92hw8hq5+Vj9iZu43NT/nyjqZ Shcg/UXsmerBnvn59eSJDdjdfIDW3fbqYUEBvbNpMp9HVPUzmo6jdDaSdm6UQhKJxQYj XDPkl0a8PB6OX4v2TcSXVaF2xQr9l327PZviYaHmJjf87UG9i8EhFfTJY+d84zh6aoJG W2xyiHJAREJTxo7BSp+1+wkMkdK7DbT4vanETpExLsB6ozi8RSkjr3fqjfu3OQKStjyX KZkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VMTSVlU7RTdc+zeD484Z8Pn79vBbZJpar+lOeRauq/0=; fh=cTOFRdi2zQSKtmntGARFrJwlvF+pTPHUR4OVgFDYp8A=; b=RaPGv9HRmbWQU4T3gnwsDaEFmtwbdb6YTdrd0UZil2g2HHdO0e0NeNei2DfMmFHhQe rpILbKblanFdcyETYIejUfm8GKPJOOP8bUoFTaGplCuoaPA1jYp1VApf7D8Vzhwk/AzD hcRnyQiOJV9gp/Cws/p0qg4jivxm5oK0SRUAgULCijJDBVBKxalHyG4dCQECogkwV8LG dsJP11sT3zjqpS4wLoansOg6gdWDmdovCpF+X2PfW9AxQcGfoPyD4CgYkImBZgLk5uBG saDhcDUyAF4psFw71ps66z9ggl7RgKI0xPcAcqyIcE59BhUniCZmBUSFtSHHGORpKNvD UgYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ita5Ke6W; spf=pass (google.com: domain of linux-kernel+bounces-21110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w4-20020a056402268400b0055480454c46si874912edd.267.2024.01.09.08.30.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 08:30:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ita5Ke6W; spf=pass (google.com: domain of linux-kernel+bounces-21110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21110-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CE0471F25BAF for ; Tue, 9 Jan 2024 16:30:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B2CB3A267; Tue, 9 Jan 2024 16:30:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ita5Ke6W" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D96613A8C6 for ; Tue, 9 Jan 2024 16:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2cce6c719caso35181691fa.2 for ; Tue, 09 Jan 2024 08:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704817801; x=1705422601; 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=VMTSVlU7RTdc+zeD484Z8Pn79vBbZJpar+lOeRauq/0=; b=Ita5Ke6WzrjTrF7OMGYoWmQkLZ/2QOxFu6/bcuOHR6ZOXhPmpLgpmiMeZqPT8ZLY+Y 4tkgpUM/ve88lejNicBrcTX6ym5lE6b5Ni+20oFMcTceOBzAAfeHctH9NseUvf7PVez/ 8uiA6KwT1TGVl4Gz/5RZAUOKwThpweanjddQyomTaY0SnhhiyTR5kvQ/t4XggbH8eBri t4pmMOv+NG0+XYNrsd2XOqpYLB5UTeElcbgGE/9JOOUJpcD0B5eZFfRMV/urUnAslhBF nUahejgq3QfaxFjEZXELaan6End5CtbqE0P2m7iRZU2DjlzPCURD5+3iqwhCYFIWdw9G oFSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704817801; x=1705422601; 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=VMTSVlU7RTdc+zeD484Z8Pn79vBbZJpar+lOeRauq/0=; b=A0pOSk0fpT2thcOok63Cg97c3EsU9xN8ygN6GS5PWCmZVnn+fkHYscDJ2R4qvuiCKC mRJRB3/ZJcAXX4SFAbjH+YujnO2cFBMjINSFlJrvMtv13pv3JvR3QOGGsK01FOgxdEzc CordryyUV/0h3HViuZONGU98u1O0+sO3duY5IO3zLcAKs2uOr1/uhIkB+8ru0HusAJAX 69jOKcp9C9S+4Qzeq4dphDPV+ivVtFArLLTHpXpyn+w/tUddOLVekM9t3kB7K32gh7pi V77KdZkl+obq6w+i3s4Ykr8xCDOdJI0QESqwX+st1WgeHApbM4YxaY8/PoXIXpy/Fdzw l5pg== X-Gm-Message-State: AOJu0Yxy699gWRy7jjDcvnbHdwjV+Ob6KFfH6nrf0IRuSUSCM0Vu0VyV CciVP07QAH+higUJEgZ+GcUK8xZcxplk2zHMoG0av2ECw+Y0 X-Received: by 2002:ac2:53b7:0:b0:50e:3c6f:9207 with SMTP id j23-20020ac253b7000000b0050e3c6f9207mr2131377lfh.60.1704817800623; Tue, 09 Jan 2024 08:30:00 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231024142706.195517-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 9 Jan 2024 08:29:24 -0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry To: Zhongkun He Cc: Nhat Pham , akpm@linux-foundation.org, hannes@cmpxchg.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Li , weijie.yang@samsung.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 8, 2024 at 7:13=E2=80=AFPM Zhongkun He wrote: > > Hi Yosry, glad to hear from you and happy new year! > > > Sorry for being late to the party. It seems to me that all of this > > hassle can be avoided if lru_add_fn() did the right thing in this case > > and added the folio to the tail of the lru directly. I am no expert in > > how the page flags work here, but it seems like we can do something > > like this in lru_add_fn(): > > > > if (folio_test_reclaim(folio)) > > lruvec_add_folio_tail(lruvec, folio); > > else > > lruvec_add_folio(lruvec, folio); > > > > I think the main problem with this is that PG_reclaim is an alias to > > PG_readahead, so readahead pages will also go to the tail of the lru, > > which is probably not good. > > Agree with you=EF=BC=8C I will try it. +Matthew Wilcox I think we need to figure out if it's okay to do this first, because it will affect pages with PG_readahead as well. > > > > > A more intrusive alternative is to introduce a folio_lru_add_tail() > > variant that always adds pages to the tail, and optionally call that > > from __read_swap_cache_async() instead of folio_lru_add() based on a > > new boolean argument. The zswap code can set that boolean argument > > during writeback to make sure newly allocated folios are always added > > to the tail of the lru. > > I have the same idea and also find it intrusive. I think the first soluti= on > is very good and I will try it. If it works, I will send the next version= . One way to avoid introducing folio_lru_add_tail() and blumping a boolean from zswap is to have a per-task context (similar to memalloc_nofs_save()), that makes folio_add_lru() automatically add folios to the tail of the LRU. I am not sure if this is an acceptable approach though in terms of per-task flags and such.