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 246A7C25B78 for ; Tue, 28 May 2024 19:08:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D1396B0098; Tue, 28 May 2024 15:08:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65B506B009A; Tue, 28 May 2024 15:08:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCF66B009B; Tue, 28 May 2024 15:08:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2B5DB6B0098 for ; Tue, 28 May 2024 15:08:57 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D15351C0E62 for ; Tue, 28 May 2024 19:08:56 +0000 (UTC) X-FDA: 82168741872.30.67C12A4 Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by imf02.hostedemail.com (Postfix) with ESMTP id 1639E80015 for ; Tue, 28 May 2024 19:08:54 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fqNErezP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.217.49 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716923335; 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=2puTWOFR02t9GANatBeEi0mPqoxXCcVIPKBqGJyHdVU=; b=6ymIeWksPQYH3Onyx1W+7B4UHPXN3Cr7QZiZwc+M4TLzsr2EePLV5zhU+JumUVRKS1q32D SRkvTSUU9ExHTUI3zRIF7y7+lSU9JKh8GdlZBz64rfsQ65UrSDDiHY9JHH6Gk0Ok9Mqx7s WfTxqjrgQbvfmpC91JcTPfB8p0Fj3BM= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fqNErezP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.217.49 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716923335; a=rsa-sha256; cv=none; b=Kb+Pnd2eSp3WwzNvdmZjGTvxt6OPc6UJNlju4sLuU28wd61WsJZF8hpmJiSWdhg/quqLlK pp5bZruqtoHeG2IcJKqieF70lYkd7lHFDHY2AVAHIslAkFXmkBDPhPx1Ww3D7ACSxq3a8A RBzx34gJatg7cYoTKihybxPiTGw3LeE= Received: by mail-vs1-f49.google.com with SMTP id ada2fe7eead31-48a39896682so337137137.1 for ; Tue, 28 May 2024 12:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716923334; x=1717528134; 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=2puTWOFR02t9GANatBeEi0mPqoxXCcVIPKBqGJyHdVU=; b=fqNErezPeDqoNRBNKxZFzY0+LAjgkT07KNIaEFdE/mIbEEpVHiwx+EEOKjHoGMIGFi H2cmoEgRqdleWogjwSYeaSqCRmWiLe84EYzk9LFZoZpfjGJMpezHzhQteysP4wjF5weq L6LdnKXmaZ8W0FUgoyVR3wK9JLzQXG4BrU5e+pzd1QvgYNgt+6dIcHP5R/2KOjFildIb 6qBRUYZ61B+XFJDxC23KTK3N3ynGHjs1C1jZlzkmus3k3eVho/1B6H6ct+uyjfi+Y6cp amSDeNSX61lu2hhg2ftv0F5x/O0aG7JbPU/Fnu0IpKClN8q3C33zn8+BjvxTpCfoibJW GF2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716923334; x=1717528134; 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=2puTWOFR02t9GANatBeEi0mPqoxXCcVIPKBqGJyHdVU=; b=fNpVj7qdYjzp53fQ+5G0Cp22D7MtbhjvYrteNnWbvZRMxA774I8dwFF4VpmVkmKfHe QMY7wa07brKK7Gfr+mIyXV+YBpjVWaQJ5WfAys7l/f/2rlLjKQHER0Gq7WyddSB521Ay S4bQIFzt6xYEM4zZ1z7Shlnu+1G0CwBjinLRLANjcp6fpNiFieFfAiBA6J6CFgubHkD0 wawHuE+aF1+yQxNifttTfd/7y6OU1zlA/CPdvEF5Zpw/CKrxqajWwmAliFFpfYdbQYcD XADXVCH8M/RLXBXrVwzc0jltFIaiA88DmnemFQhcMI6y54EcvYh+9XlNa0VX7DkBa59c Xm6w== X-Forwarded-Encrypted: i=1; AJvYcCWw8Zy93SSGDr26slAiqy0uNaVk4STWm+T4amjdZVhB4KQprqDC5F1ndpTSABdMO4o73yhufUwgPU0aDm2CKt95grs= X-Gm-Message-State: AOJu0YxHrcbWD/PPw3TTNfoQyChqte3KqLxvP/9xhaVnWbQn3JMlrQ/U cgOo499D7pInzARYW/FJJ2iaSidAMai0UqkiPIROLah/qXB3Kit6ItUp2nkvEfXRbSNivhfnm9g bKFU5HHBPiSbSnK5ozLXgatnz4KM= X-Google-Smtp-Source: AGHT+IFXwhrLaG4z51INBmphQW4cBoyTz028xIBeiZ5b0lQTKmcxCKOCR6N1+uG2fG0S3j+O8u/xckZgpN8fyNff+zI= X-Received: by 2002:a05:6122:c91:b0:4e4:e9db:6b10 with SMTP id 71dfb90a1353d-4e4f021c79fmr12673028e0c.2.1716923333865; Tue, 28 May 2024 12:08:53 -0700 (PDT) MIME-Version: 1.0 References: <20240524033819.1953587-1-yosryahmed@google.com> In-Reply-To: From: Nhat Pham Date: Tue, 28 May 2024 12:08:42 -0700 Message-ID: Subject: Re: [PATCH 0/3] mm: zswap: trivial folio conversions To: Yosry Ahmed Cc: Matthew Wilcox , Andrew Morton , Johannes Weiner , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand , Barry Song <21cnbao@gmail.com>, Chris Li , Ryan Roberts , Kairui Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1639E80015 X-Stat-Signature: jxrk5yu6zqy9jttipjdgxtxnx59e7baj X-HE-Tag: 1716923334-790972 X-HE-Meta: U2FsdGVkX1/IVwukqzCLuXDu6zGMxyQvdh4+yb4Ax30uAAQoI2w2TFw+frCoSTa5avJij5HrQgJjCAbxWtx+/qE/5p7saP3q2zBN+5hupUnbgqQfj1SQPD+8L73w4XdUxnPmKhn/Pa5PxGXNgX06Sn+V/Him/1+t/hHzG52Rivt1SlFwhJ4JJtd8QRdP3RX+SBJnOY2KUnl4WOvgCfbvZGPANTadDRu/hx9+AH58k1mQdkzLNnxz2WYKGGbi0fLa6MiSqN5rFLSWwOTP+EeSWLjWuEYhj9nrdlZbbQGQF0OVa8cjPHGp5lNlsnzBjI8X/3CD2VeE2rpu1mo68RV9Khvb1CRinoZ9AptnBkVVzm41ElH2zcwWbVhy0WCySUzVh3dw28esFJdEEhG433pZi12MNgPLG8AKvj0zJKs+BmOEWRrhOpn8oQi2OqUkJTx3jQ1ljw8EgMF/iKjKYXhY/Apw+Ch2XTL3PJKnqHJzmN1P4kPvcCsV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: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, May 24, 2024 at 4:13=E2=80=AFPM Yosry Ahmed = wrote: > > On Fri, May 24, 2024 at 12:53=E2=80=AFPM Yosry Ahmed wrote: > > > > On Thu, May 23, 2024 at 8:59=E2=80=AFPM Matthew Wilcox wrote: > > > > > > On Fri, May 24, 2024 at 03:38:15AM +0000, Yosry Ahmed wrote: > > > > Some trivial folio conversions in zswap code. > > > > > > The three patches themselves look good. > > > > > > > The mean reason I included a cover letter is that I wanted to get > > > > feedback on what other trivial conversions can/should be done in > > > > mm/zswap.c (keeping in mind that only order-0 folios are supported > > > > anyway). These are the things I came across while searching for 'p= age' > > > > in mm/zswap.c, and chose not to do anything about for now: > > > > > > I think there's a deeper question to answer before answering these > > > questions, which is what we intend to do with large folios and zswap = in > > > the future. Do we intend to split them? Compress them as a large > > > folio? Compress each page in a large folio separately? I can see an > > > argument for choices 2 and 3, but I think choice 1 is going to be > > > increasingly untenable. > > > > Yeah I was kinda getting the small things out of the way so that zswap > > is fully folio-ized, before we think about large folios. I haven't > > given it a lot of thought, but here's what I have in mind. > > > > Right now, I think most configs enable zswap will disable > > CONFIG_THP_SWAP (otherwise all THPs will go straight to disk), so > > let's assume that today we are splitting large folios before they go > > to zswap (i.e. choice 1). > > > > What we do next depends on how the core swap intends to deal with > > large folios. My understanding based on recent developments is that we > > intend to swapout large folios as a whole, but I saw some discussions > > about splitting all large folios before swapping them out, or leaving > > them whole but swapping them out in order-0 chunks. > > > > I assume the rationale is that there is little benefit to keeping the > > folios whole because they will most likely be freed soon anyway, but I > > understand not wanting to spend time on splitting them, so swapping > > them out in order-0 chunks makes some sense to me. It also dodges the > > whole fragmentation issue. > > > > If we do either of these things in the core swap code, then I think > > zswap doesn't need to do anything to support large folios. If not, > > then we need to make a choice between 2 (compress large folios) & > > choice 3 (compress each page separately) as you mentioned. > > > > Compressing large folios as a whole means that we need to decompress > > them as a whole to read a single page, which I think could be very > > inefficient in some cases or force us to swapin large folios. Unless > > of course we end up in a world where we mostly swapin the same large > > folios that we swapped out. Although there can be additional > > compression savings from compressing large folios as a whole. > > > > Hence, I think choice 3 is the most reasonable one, at least for the > > short-term. I also think this is what zram does, but I haven't > > checked. Even if we all agree on this, there are still questions that > > we need to answer. For example, do we allocate zswap_entry's for each > > order-0 chunk right away, or do we allocate a single zswap_entry for > > the entire folio, and then "split" it during swapin if we only need to > > read part of the folio? > > > > Wondering what others think here. > > More thoughts that came to mind here: > > - Whether we go with choice 2 or 3, we may face a latency issue. Zswap > compression happens synchronously in the context of reclaim, so if we > start handling large folios in zswap, it may be more efficient to do > it asynchronously like swap to disk. We've been discussing this in private as well :) It doesn't have to be these two extremes right? I'm perfectly happy with starting with compressing each subpage separately, but perhaps we can consider managing larger folios in bigger chunks (say 64KB). That way, on swap-in, we just have to bring a whole chunk in, not the entire folio, and still take advantage of compression efficiencies on bigger-than-one-page chunks. I'd also check with other filesystems that leverage compression, to see what's their unit of compression is. I believe this is the approach Barry is suggesting for zram: https://lore.kernel.org/linux-block/20240327214816.31191-2-21cnbao@gmail.co= m/T/ Once the zsmalloc infrastructure is there, we can play with this :) Barry - what's the progress regarding this front? > > - Supporting compression of large folios depends on zsmalloc (and > maybe other allocators) supporting it. There have been patches from > Barry to add this support to some extent, but I didn't take a close > look at those. > > Adding other folks from the mTHP swap discussions here in case they > have other thoughts about zswap.