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 58B9FC46CD2 for ; Tue, 9 Jan 2024 16:30:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65EDD6B0098; Tue, 9 Jan 2024 11:30:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60F106B0099; Tue, 9 Jan 2024 11:30:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D6AE6B009A; Tue, 9 Jan 2024 11:30:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3966A6B0098 for ; Tue, 9 Jan 2024 11:30:05 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 00AFC1408FB for ; Tue, 9 Jan 2024 16:30:04 +0000 (UTC) X-FDA: 81660309570.21.5C0D7E2 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf22.hostedemail.com (Postfix) with ESMTP id EE7D4C0015 for ; Tue, 9 Jan 2024 16:30:02 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xCsugZva; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.175 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=1704817803; 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=VMTSVlU7RTdc+zeD484Z8Pn79vBbZJpar+lOeRauq/0=; b=CLT5aW329KUCLqPqMuVIFOXjeHZVpeGUTf5/GVOMfrBL5BobnvG2+RJhO+6cf0kCl6qWnp Yk3ONW7IczPEHoQESasntVGq5Oi+D4mhHfIIkARa4YMdNvLornVH4gX5FEKcA/Bujdle7A kk2VN2Cr4d0QrgHY9HEJsrfN1CZwELs= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xCsugZva; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704817803; a=rsa-sha256; cv=none; b=Uoz7ePPHqzQwoEqQdqrfufXKTIz7OyL041Pnth8H8+2445p+NqQ1SDKYQ3p6ZSQU5lZ5T7 olwe9yOyAkaBtQgjI0fRthE8A0f3p19nW4fSCmoQPkCvs/7cXJRjdFOn/9Y735sULefG46 qJjO/qBscaz5PXcqvzk2o68lVHCA1K4= Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cd0c17e42bso35205521fa.0 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=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=VMTSVlU7RTdc+zeD484Z8Pn79vBbZJpar+lOeRauq/0=; b=xCsugZva5aGWYn4BRHh+iGzQWDfgyqPtSEzXIMvnSeXHVua/7m1nNJCovzfEJrtu26 bMGN2WtnvE/YDBSVtKq7qB0bcOHkErZbER+04ZS1fXS71hTlSl9LPBosJNjJqIk7Eukq ldMguLFhtAmlhaUS4ukKldpnzQNN+47M47rN16YadosdMCH/hI8NCZZBbPNMUDDbF4xR H2gUeeQPiNTFrYBKmZaGFk4/yvByavUIeeVOuKPbJ4zn2WWDvYIyjOpPag7RwL+uJXz0 pjor9v32zlzFtZzUZxq1hvBv0McvLPmVWx9VNVqy3/8nqE0KV3juqNgJJDRg0j690XmA 6yPA== 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=Qdptb2MpVyv+diC6otZWA3rcZa/iGexBQxYzNgMGkXKqXB275vVnuyVy1wGQXyclD+ 9/L5VOTB5lDsIXK5CTxEyJdBtj9ZfM8Cz2mdenoZfsfV5mfyJpBnspcFt/ylEvog7/sL t2ldOj98w4CUkCnNnTRK5cQzzDXJzWfbq2/x9a6I4X9jucSJ+A1aTBgL0FsdBtlKhV4y YV7yJ8N5Ppql2u0+oLlssGiy18q5otsCbrYMehGxYYYTryKm/aWsJ9LspgRBOpp/e7Hu SfJVN6opAV6CaaGvOQYmhgx9YSoljvkpCLpJoUPFBRIk/fZGULMl26sBOvuD2LsGnb+j GWIw== X-Gm-Message-State: AOJu0YyAXiG5MzzNNVJb0CmdbwGwtL2AuRU9+CKH2f7jbOvW7qzOJDul 5JN8ze0rkEQ6zjfoW3ALmkHpfEJZ9Go5BGTrwvYsgQLqXs9k X-Google-Smtp-Source: AGHT+IFz0v1wegOzYxO/7PMwQmiYhnbtWntcR/xxKMtQoIibJ46zD9IsD+2QhGH6yc6aCbud+YeyKBh34Wxbt0ITzW0= 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) 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 X-Rspamd-Queue-Id: EE7D4C0015 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bpk63sf1g96fbjt7xy6c3nr4biz1jkzx X-HE-Tag: 1704817802-758933 X-HE-Meta: U2FsdGVkX18tveunDmTJ8jfs6slVwzuyqiUUSSrEZvNIdrNMdLSGgVCjPjM7vtngUQs8Ki7O9Fu/1nNUqG012VMUHgLBllekyr2xprXjMn4zuhGPWnb3x62bY7MyvZJDLbGcU52jFsnLG90tZg/LJiTLN6oSi5xWbysCh12RNGkE+l83Dda2v8e2AfYbnnBpWHlJTEmudLSCOWQNeA0onSi0yQB0yHyhRFmKsr32PHTyoFS5yqeab0I3bCbC2GIG4l9Q8iJL9TrtwGlKHijASd5lp4z7OnOJ5VkznxGL/UhAOom2ZuOzu3LjDx7DwjaK3s3VmkkHZvNAkKAAYLk1U/SxQDeNWtOtD1csshQIIR6MSh2xxsPW9sbakgy5zzAT1VPK0iU1JPL96ipfv+LxQvb6SEtTIuQyIQbC6sg6ZUDIoYu+ni/BvBA/pJnhixsvRrlxEYUsHFP7biF5peSq/bD1KT6BZYGkh31U/QxoVYHt9roZE6mV9qj9q3WEQCwvhTQX+VS09nCqjhB20A/wNLDXfN4U3ADN6RbJFxAx1jTMAUubu1Buts64xpXKF6Em8QYA1m8eARNSiScTXaxlfzEq8krxd5l3xCnOaRfIphA6UHDsYx4uNronSe8JbYB8E8+I2kKYilia3dSi/nFVe8LitViVq+TSlBXnpLYaesELmjpdP3TcSUjGOGt0s9Ex4BWatL7eesyAr/dFVK0/RFg5bXvnEdR1Zkf+laQP0fguBP+EiurLOKKz8naV3hk79Ac/BwlVeY0Lg+VWnNqXR/oEdRc/VD6fHa3gdSzaKMnHsBXXUMHmBb1KQU/XYlwagumhcRQJa3o+lDDm8gUG7A0BN5BdM7QboCodRpy+OrckYOvxetCG1KJH32WDvBYK+wgtdMKxGTFF2V0CmATaWwzeXx7Q66VFLxQlaE64WZoh+FQGYY1iqo+xsBmAt/8Cf1u+30kx/oO+9yYhhcD Gw5Fhsrz 78pz328S8aOteyitGB40+mRELThv9c+psof6n2ewhgdbUioJaOatYUrMeK1i7mmaK2xuC6SYbXV8a3D7NSWnS8u4awSuSQbTq2cx+B0e7mfOxg/JRGSw2x+Qn64vk7tmMWJ5Bs3BqjyiPjRnBKwJyFZgV808bOl/IJp9Cp6MJO1F6qNas27gGtswt4qSwTsR0wCMnuZJWSm3rEu9/9b3XZDg6wmEe2YyMg1y7ijv7pBiao21MjlGIuxQ5ec/iFFzEfHy/NHh0I+M0Uushe91pIgWsw5z2yZarPCBWkmP/Nm2eoK4QU05VomwMrcCjo5vJHPRMS64cQS7zZlZf8Glc17WqOA/YRya/7I01Xzx8Ca1MZ2Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000811, 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 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.