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 65E34C6FA8E for ; Thu, 2 Mar 2023 18:23:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C45E66B0074; Thu, 2 Mar 2023 13:23:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF6886B0075; Thu, 2 Mar 2023 13:23:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE4FE6B0078; Thu, 2 Mar 2023 13:23:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9EFD36B0074 for ; Thu, 2 Mar 2023 13:23:42 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 53FF98093E for ; Thu, 2 Mar 2023 18:23:42 +0000 (UTC) X-FDA: 80524781484.05.D9C66C2 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf19.hostedemail.com (Postfix) with ESMTP id B10171A0016 for ; Thu, 2 Mar 2023 18:23:39 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=none (imf19.hostedemail.com: domain of riel@shelob.surriel.com has no SPF policy when checking 96.67.55.147) smtp.mailfrom=riel@shelob.surriel.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677781420; h=from:from:sender: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: in-reply-to:in-reply-to:references:references; bh=LoPxHaAy6D6mL2EsjqHh40hbC8rY/1Ku+k2SEtYDI3g=; b=VDyuPYJIbFY18O+15RdwZMmI6bgiu6iPV7gtLISxPhS2bbL2xQOV+SLc7yzsJNp90fgf10 qBjFcvVgBBMO4ZqMlz0S8+pXn3qdW5+Tr0wfg2KU5rZFOaz0FBAY1BVOhOqCVd8g6zcA+Q dXf6CwRf+vqEiDkG4313SlpJndjeqWw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=none (imf19.hostedemail.com: domain of riel@shelob.surriel.com has no SPF policy when checking 96.67.55.147) smtp.mailfrom=riel@shelob.surriel.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677781420; a=rsa-sha256; cv=none; b=75DFphociEYr8TwDBUIJfZah4QNjFR8AKieSSd2aQzC97D2n8IvO8a9lNmNP6/m0fRibWc +K0HYkj5z0EoeFD74LdMx44y0Tp8pEdYfsKUJ4LBP/JQn97Fu4RXeUmJgyLOza37Mr8Qzo 4etNC4iIXUmuOjB7dM+Rprntra95KyE= Received: from imladris.home.surriel.com ([10.0.13.28] helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pXnaF-0003FL-26; Thu, 02 Mar 2023 13:23:15 -0500 Message-ID: Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap From: Rik van Riel To: Chris Li , Yosry Ahmed Cc: Minchan Kim , Johannes Weiner , Sergey Senozhatsky , lsf-pc@lists.linux-foundation.org, Linux-MM , Michal Hocko , Shakeel Butt , David Rientjes , Hugh Dickins , Seth Jennings , Dan Streetman , Vitaly Wool , Yang Shi , Peter Xu , Andrew Morton Date: Thu, 02 Mar 2023 13:23:14 -0500 In-Reply-To: References: Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-eOn9iZub6kDqQTTklWJu" User-Agent: Evolution 3.42.4 (3.42.4-2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xdH+AvotrxXli6hu+YX5xY/bX3lzrWM75xeI7jHQ 6vkf/T9B BAMqIRoFNOrGEDdzhD8vCtA5U31MpAJDqu8mAMc3AinKopLtJelVpBDKmSZjKbriM///7XQs78oejxAORr+uPLPkAa3CXJHGJwVjVBwcK8amN+mp3M6REGSHbbTcPzDXq7sFzNxJwPCSFwLpAPufMV7z+VOpm3wZoHUaMCsfAcuhQOvD6pw6emlcBMIasMxCYqUfMpsz/75zGxtcK8hU2p2N//rlQ2iUvvV4WzHnWOfi+4Do30yUPHlTh8bmqMjMc4vvkr3uUhQqE0BKrW0LOi8kAQJlJZ7ALa/1w+O2hNpJk/7INGrtP23FWjeK6Kbue7Ssfjf4uys80GTyEk/BYvh4YDiIVkYiVCcczyEDi68i8QmU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --=-eOn9iZub6kDqQTTklWJu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2023-03-02 at 09:47 -0800, Chris Li wrote: > On Wed, Mar 01, 2023 at 04:58:08PM -0800, Yosry Ahmed wrote: > > > The indirection layer would be essential to support it but it > > > would > > > be also great if we don't waste any memory for the user who don't > > > want the feature. > >=20 > > I can't currently think of a way to eliminate overhead for people > > only > > using swapfiles, as a lot of the core implementation changes, > > unless > > we want to maintain considerably more code with a lot of repeated > > functionality implemented differently. Perhaps this will change as > > I > > implement this, maybe things are better (or worse) than what I > > think > > they are, I am actively working on a proof-of-concept right now. > > Maybe > > a discussion in LSF/MM/BPF will help come up with optimizations as > > well :) >=20 > How about we just put the indirection layer into the swap device? The indirection layer needs to be higher up, in order to allow for easy movement of swap entries between different devices. For example, we could initially store something in zswap, and then later decide we want to write it out to disk swap. This could also be used to quickly free up swap space at swapin time, by freeing the backing storage (eg. in zswap, or when disk swap is starting to get full)) when placing an uncompressed copy of the data in the swap cache. We could apply per-device policies on whether or not to free swap space at swapin time, because the tradeoffs are just different between eg disk and zswap. Doing that would also allow us to turn swapoff into a simple "load everything from this device into the swap cache" operation. The pageout code can move that data from the swap cache into another swap device, without ever having to look up page tables. One possible implementation might be to have swap page table entries point to a swap address in this indirection layer, and the indirection layer can be an xarray containing the actual swap entries specifying at which position in which swap device the data can be found. That might be a net reduction in the code over what we have today, because it gets rid of some ugly corner cases. kind regards, Rik van Riel --=20 All Rights Reversed. --=-eOn9iZub6kDqQTTklWJu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAmQA6ZIACgkQznnekoTE 3oM6GggAmfEOTR6Ngn24N0eHNSvMJLKg2eNqo8hyalwQcSe3ongsMQo1OESNp/km OX/ylF5aCj70h+yK2izC1yI+Dbj8eKGm8bmOpBoZeIoaJawVz7tyxn6dPiCndeoE KCtfgsA4B/ebAd7dS4v6QfwmWRiGrssSkQ58xwMRbiMU3mwAVY3UpffchCy3lvt6 17MQoXbXQcgQNdZDrcFFneLsKVX0N9WZQgG9r2TxrZ7CiFVPgmsg39NoivenQiNJ mEVlZ1s9Kj9RqmhYu7tPxd3sSf/0ktABWL2ZVrBesgryi/qTQF6be728s9qHaKcP FbDRdfX3kHf/9B8Bh7FqorKtzjjGUA== =ineX -----END PGP SIGNATURE----- --=-eOn9iZub6kDqQTTklWJu--