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 3522EC64EC7 for ; Tue, 28 Feb 2023 04:54:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3D426B007B; Mon, 27 Feb 2023 23:54:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BEDE66B007D; Mon, 27 Feb 2023 23:54:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADC3C6B007E; Mon, 27 Feb 2023 23:54:14 -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 9F5C76B007B for ; Mon, 27 Feb 2023 23:54:14 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F8E5AB85B for ; Tue, 28 Feb 2023 04:54:14 +0000 (UTC) X-FDA: 80515484028.30.2F96FF6 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf13.hostedemail.com (Postfix) with ESMTP id 998382000B for ; Tue, 28 Feb 2023 04:54:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JkrRNXXF; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf13.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677560052; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CZ65cbPDa5GzeTNhJh4nmGg5ADpCRJUbHTz4g0s7AUE=; b=xUqDe/dCs1Ors1UotiIEIlQ6zHEnuRNna7Q2Pon4PcF6rTjDXV2vEzIf97iftywbS3TY4X QNQn+zHYb3OlkMxTR8y5drnvcdZqC8spOKecx3ptACg2KUj+Kaf+Z5ott1a9eGbm67Mvtz VveG36Xgs0DK+haSjzIM3qP0EgLcKQY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JkrRNXXF; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf13.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677560052; a=rsa-sha256; cv=none; b=NHHuL+yz8l4MLbPT+PXR4mJxT5qUylYGyo05aF14lLmwRdF2H8dECg9OODgFxi7erZbO6E 2aH+lHjAAXLQbe5F6+Pums36kKiqk3aZsCqjuIHIc/538fnxgouAQ21x0e30hPLJgMjQHQ bEKRnRIauxAnfpQAmtvQv15R2ExvWic= Received: by mail-pg1-f173.google.com with SMTP id d10so4890002pgt.12 for ; Mon, 27 Feb 2023 20:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CZ65cbPDa5GzeTNhJh4nmGg5ADpCRJUbHTz4g0s7AUE=; b=JkrRNXXFVWtYUuJOsleMQGmoPxmWifWXvuewctwtwZOAE3UWc+M1JcV9NWc7ts10mL edPk/UlpR9nZKXvMjFm8FxlIWafU5Y753bK5Qs7WO5Zs7HRvL5StBjvB+AXj6aiFYAj4 wG3aBFC5oWfAW/7MuRnhpq0Qlurtu6E1Ij3cY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CZ65cbPDa5GzeTNhJh4nmGg5ADpCRJUbHTz4g0s7AUE=; b=TtDaqiKcYvEfs2CYNxWXaGzbxRuWghMa5RRcbNTE1eX0snw8I5IKm+r/0WqWVvb4Zt PRLOLqMp5wzdlpgwAp8Vfco/Vx3Gy99nRTIEtrMDQH83yNAVzvWMdpflmRiDn+i/wKtR qr+aginEW5Alyc2H9c/uoMbJkdKHtRTpez9LmrXels2Ds7sxBZckRfghKLzZbl7L8AOp skK3G0PqAjFyVfFRgvy8rxQWg+a54HpJOnyy2Y8imzCHFNZkXgkwT/1nOSLYllM+Uzqi HfVfWQdw3amymCHtbNke0KgKdS6bZdo2mD6FdorLJtT+Y7t8/RzMLZ/cVzUKHpgzXzXr ETPA== X-Gm-Message-State: AO0yUKVK3ntyCjCmYLMHwI7JYnOXJn5g2v+0r7KJ6ntIDCPUzFsUn9Kk SUinFo25fEekhK3KCPBTi0K7gg== X-Google-Smtp-Source: AK7set/3vcO/JOzf+xW91w/BO1GfvPXNeZY77zvBv+TjWwobNHR7zQa/ty1vIJ41LoQosDnCizs45w== X-Received: by 2002:aa7:999a:0:b0:5e0:fb42:7360 with SMTP id k26-20020aa7999a000000b005e0fb427360mr1435739pfh.11.1677560051224; Mon, 27 Feb 2023 20:54:11 -0800 (PST) Received: from google.com (KD124209188001.ppp-bb.dion.ne.jp. [124.209.188.1]) by smtp.gmail.com with ESMTPSA id u23-20020aa78397000000b0058bca264253sm4990415pfm.126.2023.02.27.20.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 20:54:10 -0800 (PST) Date: Tue, 28 Feb 2023 13:54:04 +0900 From: Sergey Senozhatsky To: Yosry Ahmed Cc: lsf-pc@lists.linux-foundation.org, Johannes Weiner , Linux-MM , Michal Hocko , Shakeel Butt , David Rientjes , Hugh Dickins , Seth Jennings , Dan Streetman , Vitaly Wool , Yang Shi , Peter Xu , Minchan Kim , Andrew Morton Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 998382000B X-Stat-Signature: a9qw6pqonpewmyk4hg4jeag61pafeqhz X-HE-Tag: 1677560052-72345 X-HE-Meta: U2FsdGVkX19qCthn+JBaAHwP3iLUD6B5zdFCE1oGZHeW9TVuQ+0mqIxaOL8HPmmvukO5S0pwtoSS2DiS7XFHMeWnwdRX1MX1Y9WvC2mZ80zT1dvqIgDSe1zGoNe2bsGATB1hEE0G88OojT0DfhXygHy+gtkILz4smi36tjFna1EadUfypRcciS2J5Qz+/KiYT6X+k/H1O25IAFccSfufmoUvre+Teitk9g/r0IYl+fgvnTlZn0ONvPXh7oau97NZk+rtcApwFFxgUstqHKjI0hRZHFQy3r1MuerEfiTGj0M1UAKUiF7DwMCUIk7/bUYVjuenButNfiGy5k2GElqZxrWFjZqBCTLITsDj9s1aiFzkslDYMC5+R5Kin4dyynAcbU9wZrcMb67MrKgBcF0BNRB1JqyInTO2rKu0u+qhjSxHoJyKUd/Oe1saYgFirc0KiV/XQwp5wehIE7EkLB2+GoDHQQ1PaQzL2h5yk2ZYyNNb9MTq84Oheoe65pazXQD+uQzH2IOH+lOrnkPbjmQqTvAZjMw1sbMcdPHKN7LwPUkv/+GWOUkHk9mJka8R+udK7Tz0bDddDR2ZRbBYcsBexUn3qdVhF/1vIo3Sm5NR3BLrgEiDcYN4AQhq2G2B5zqlfHm/2iZPZ/ZJebenw2+l5yoHFOzUO51GFp5EjxX+YNsDIe58YEJDHBaXyCaXLeaKUfRTHE5XJsZbZ7btAGbmjlQ2JGuhRTSRQ6OH3TG+kAAgTL3k54de6w7c2XVpE4kreYLgD0Xn/yCIvsreiHDc5G28m8YH8plB0aGdZaC5QauJTivoPZD3EXT7RCsbJ5a6JZJ+5/rSRQzKP0wNM9AQoDHpu6C6riigrnbm6SVAF+9GlsGDPQLt+ri/zy2xWkgbv0TDeDpTe7T7YDiKo1Dt1u/vE7TymQZvMSEk3RMWgG3AciJH3RmxHuH9fdNBOV31gICHphhfDrs5dxei9oc 0pOuy2Jc 0wfcIqZn/b1fLj0VeDO8GxBDkhXbNpEqbmlpbQPtKhdIKdcK+GQEgmsbhJBPk20xDtcaYvZ2d3GrR8Skzt5hXiv+VWGrOPjIXT3rzlVxNmkbqIcvF/pMfKXOsmCWLqF4GiwO7lNDnoO4me4XyZqs//l8LmcO43MGc7syjynpuZwqiy8yx84IuIYeVasazQZmZdO3Dw9sV81D3znWjZA6kb9C51WOtR1OnjtZwtXFywgi6rTzCPk7dpyIAFRyKR3hTjDuWSxc0OoDWbAx/+eQsrlq+IBnYZIZklMWoUuZoLGrEZRMSFqbRSobBiSxnhqxAv/Ry4CDHX3qlBhH3oCE37QH2lF5/jSacnLY6jDd4vYA4sjKIXG4X3aEZzQ== 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: On (23/02/18 14:38), Yosry Ahmed wrote: [..] > ==================== Idea ==================== > Introduce a data structure, which I currently call a swap_desc, as an > abstraction layer between swapping implementation and the rest of MM > code. Page tables & page caches would store a swap id (encoded as a > swp_entry_t) instead of directly storing the swap entry associated > with the swapfile. This swap id maps to a struct swap_desc, which acts > as our abstraction layer. All MM code not concerned with swapping > details would operate in terms of swap descs. The swap_desc can point > to either a normal swap entry (associated with a swapfile) or a zswap > entry. It can also include all non-backend specific operations, such > as the swapcache (which would be a simple pointer in swap_desc), swap > counting, etc. It creates a clear, nice abstraction layer between MM > code and the actual swapping implementation. > > ==================== Benefits ==================== > This work enables using zswap without a backing swapfile and increases > the swap capacity when zswap is used with a swapfile. It also creates > a separation that allows us to skip code paths that don't make sense > in the zswap path (e.g. readahead). We get to drop zswap's rbtree > which might result in better performance (less lookups, less lock > contention). > > The abstraction layer also opens the door for multiple cleanups (e.g. > removing swapper address spaces, removing swap count continuation > code, etc). Another nice cleanup that this work enables would be > separating the overloaded swp_entry_t into two distinct types: one for > things that are stored in page tables / caches, and for actual swap > entries. In the future, we can potentially further optimize how we use > the bits in the page tables instead of sticking everything into the > current type/offset format. > > Another potential win here can be swapoff, which can be more practical > by directly scanning all swap_desc's instead of going through page > tables and shmem page caches. > > Overall zswap becomes more accessible and available to a wider range > of use cases. I assume this also brings us closer to a proper writeback LRU handling?