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 B61CDC6FD18 for ; Wed, 29 Mar 2023 01:42:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C1EE6B0072; Tue, 28 Mar 2023 21:42:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34BC06B0074; Tue, 28 Mar 2023 21:42:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C7C36B0075; Tue, 28 Mar 2023 21:42:34 -0400 (EDT) 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 0A1456B0072 for ; Tue, 28 Mar 2023 21:42:34 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C55E740911 for ; Wed, 29 Mar 2023 01:42:33 +0000 (UTC) X-FDA: 80620236186.14.04FDCE1 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf06.hostedemail.com (Postfix) with ESMTP id 0957F180002 for ; Wed, 29 Mar 2023 01:42:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JUi3Ikzu; spf=pass (imf06.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680054152; 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=IcC7C0gbD3zVyHsSFJ8XlYeF45fqlDqMREo3TagJODs=; b=TLyKPg361nNwz23sAjQYLPdGqoSyIdsb2xB1sxp4XlauzlDJissAx17i//MqAya57Uisul cK9GYmc5m+gTvcHHdnqtky/YBpTNbM4e0u06Wqzpm8sk89evDYa7Wzpuou0/55HTwcu9nj +oVbzW4VlUFP4A2H8ZTkcxz2d1mj+Ag= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JUi3Ikzu; spf=pass (imf06.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680054152; a=rsa-sha256; cv=none; b=wnem7Me7kpE2zt7HtQHWWSb18eCdZ1raWW6XSiJBGWs7/YKkuyfJ7PN/q9ZQn44eMbR0f9 J5VXyu+rg1tLBo2puOQibCD/lSSBQnIGZDLII6A+twwpdZi4l/KMbTfl9yf1PpWzU9Pagj 9F34O+oKlQ78kgH9SDAOLw3XJ7F14os= Received: by mail-ed1-f49.google.com with SMTP id ek18so57221017edb.6 for ; Tue, 28 Mar 2023 18:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680054150; 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=IcC7C0gbD3zVyHsSFJ8XlYeF45fqlDqMREo3TagJODs=; b=JUi3IkzuewXY5EpeJDqiaPtWlj83+G1aiNtpL1G/MEXK19WFfNVtbDTJUKZi9MT2+1 6lNAc8hdmNe6mgZaK8ozwJu1owk+VE0bOv9StV4KAs5bXMtCJMJwaVZM7ULUZok8ZCV3 6hRXTVPorytrqColTySfVv/rlkf5NFhtgbvin66dkKYTOTad397V89yoL8CNWJ0HC9AT sX5fFuVqwO/aBUoDPxZQq7mH7pyESykmvVMdLk4mpk/bxhjKFlrK3UUwDyWF2ZuMb9+g CE/pOYkkYV79kEx3RI6eOqHf2+Rs/P1C4ICb2RfQSB7tq0KL5VTypvhxO9Njiba8/nOb SmKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680054150; 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=IcC7C0gbD3zVyHsSFJ8XlYeF45fqlDqMREo3TagJODs=; b=LIlr773u6XPcRnm1UxcZ32Un+koxIJiKeJZ5I4kQda5LFgAwxUqnHqHKFnNYxzd4gs D3bJ9fDTR3VVruu58t44J/V3MXfYr8aF3hLTzUC4tRAy43+xaeYKzq7lLTzmomVz1P4t /x8WJ8Buhr/vygm2UppqLs0bXXTDaPh6pd/GkeqFz7CInrU/MMuEVDTfyF0gFkE9C0KC E/mc6s+CpbNcAMxANKZj7PyyxTlQEAGRyA19ilYKmKT+Y4/Xjf5i13RTeshnyrZL4fw5 dJ8utp2mkjSruKIenT8kYT54e7jvBlEX/sKZ5qQzN6nx/r1pwVSNZm0kGEET7f9a2Z40 THig== X-Gm-Message-State: AAQBX9cCPdvIrEaFclUQWlplqzG7Oc87tq3oIK5cPBvixyKhGvcTdZVa dfYXDXuN86pmzOfR6A+GNLn3yx/a/QvW+LT+GtxoXA== X-Google-Smtp-Source: AKy350YzzaFfEEJq1NUCcqajJjc9KVbHenF86raycCjN0301sUxccm/tDJFnqkPZSV1S77yu4TWbLnPEJtTDtJF6+54= X-Received: by 2002:a50:d581:0:b0:502:1d1c:7d37 with SMTP id v1-20020a50d581000000b005021d1c7d37mr8913391edi.8.1680054150133; Tue, 28 Mar 2023 18:42:30 -0700 (PDT) MIME-Version: 1.0 References: <87edpbq96g.fsf@yhuang6-desk2.ccr.corp.intel.com> <87jzz1pfb3.fsf@yhuang6-desk2.ccr.corp.intel.com> <87fs9ppdhz.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bkkcpckw.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: <87bkkcpckw.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Yosry Ahmed Date: Tue, 28 Mar 2023 18:41:54 -0700 Message-ID: Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap To: "Huang, Ying" Cc: Chris Li , 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 , Aneesh Kumar K V , Michal Hocko , Wei Xu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 0957F180002 X-Stat-Signature: wcppa673xct9pcg4mwcya71qgcgcxfua X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1680054151-536627 X-HE-Meta: U2FsdGVkX19NMvcHF/v0almWzmQYZTzib3noQ7rtoIEbBiWyrS08HQFKEGZCxd0Pv4i0WOakNa0r3mk6FzaJbuKP9pfuqp9nsPS2+pGAGO3j37JCp9BjBVygp6wzcAdOHM+s8S8/RwyEYflL4CQV9EK//uSKlf9tyzK/vfA+1wAT4klvyldPsmSKIn+V4lNXKyUP9MvgKolvLFrwhkK8gvn1dzTnDv37FRC2umS+JCtryE7DMFdgoaFeopYtTM7br50h5gWPg/R0/8fydSGev+j22DjuwsoPBcOIQDIywaOUCh0hx39+ZblkvkBhkQkyPoswSCS6PQaBGBr8LNgWfU0/pZ6w46HgDT0/3MLRntjp94m7105knhzs/VCwcXJbhb1Kf5RAm3BMTzZ/bqtcFRCLz0wkYOEEF4qldUF/CnASEf39/CADL+RC76hn+uABgboJt11r53rPJ+dB7y9wWl9AHavcDMm1hxW+FnfYVS/m0aSt2QwlxdrJgd+KPmmk4RnfPDLAIQLhLoOzB3HRNy2h47E0UVwC4XfVf0XeFCCL3Z7GJU2xkFhdZu3U83fGunT/N5P1S58BSErc04x4zpGqWZmXd4Pst6yyk8D4NYPhkjkWVYfLuY7SnlzMBNqvxteTAksMylAJDSndQhe37jXN82vdHviLnVVIfgQ4SL7GvdkohfKdMlT0cFLiQCmp/l/PVgfekfjZB+T+8M0Hz8PFA6OKljFF6uz1IYxFgdcmATZwCq8n4W2sf6/5EJuK9frhCnSkBIOxurqDBpJ7LA6gjPh3MqzMi58O3mj99X3VmPWRSQmIdQjXRA4mUWss0UP09vXZ+lm/49lOgi+pp7WmkmZTLfTjHfF7o9ygCRKp0CeVGa+Ou/CMuuRx9CvAMyIgVzohrCj4jOiV6Bez0s/Grar76LvItuFupSnvM4rGqc15p2XK9ie9CyLc8ZqlnHHEjEx02FZ/TNjWQZT 4pU60IkC iZ3oJWES7WTDQup6NJI3vkFf6ELkY4JDG8cTS78IMoBrvrMZnVoNzvYJc5T6TeYTOlGCp7UGQjvhOWED5qDh2zuEs4pxrHUtNKaCYnwAtGbQvEf6cpnrJWUdOqrf7b2anJH+MTzMtHZ5y+PLHTb3mePmpX6nWkA2YZASuGPlVsJxoA9EMq4922a+ItWBQvOStD2QPRd9UuCLlL4vFvKLrlaBRpVx+xfgnZx2zDUoYzRuz4K8ihcZeO/mDkong6lhcPgShnsb+Fkf7eopjgKX94UvzWZ3ChhU5E6p7cZS8FIi9bFXi4TFSsLmGv/RDQYt5E3AAmVjvAizGNJfKNVKlwn8qaCPWQ8XPlg0d25tUV4eR1aOOmzME1L5nog== 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 Tue, Mar 28, 2023 at 6:33=E2=80=AFPM Huang, Ying = wrote: > > Yosry Ahmed writes: > > > On Tue, Mar 28, 2023 at 2:32=E2=80=AFPM Chris Li wr= ote: > >> > >> On Tue, Mar 28, 2023 at 02:01:09PM -0700, Yosry Ahmed wrote: > >> > On Tue, Mar 28, 2023 at 1:50=E2=80=AFPM Chris Li = wrote: > >> > > > >> > > On Tue, Mar 28, 2023 at 12:59:31AM -0700, Yosry Ahmed wrote: > >> > > > > > I don't have a problem with this approach, it is not really = clean as > >> > > > > > we still treat zswap as a swapfile and have to deal with a l= ot of > >> > > > > > unnecessary code like swap slots handling and whatnot. > >> > > > > > >> > > > > These are existing code? > >> > > > >> > > Yes. The ghost swap file are existing code used in Google for many= years. > >> > > > >> > > > I was referring to the fact that today with zswap being tied to > >> > > > swapfiles we do some necessary work such as searching for swap s= lots > >> > > > during swapout. The initial swap_desc approach aimed to avoid th= at. > >> > > > With this minimal ghost swapfile approach we retain this unfavor= able > >> > > > behavior. > >> > > > >> > > Can you explain how you can avoid the free swap entry search > >> > > in the swap descriptor world? > >> > > >> > For zswap, in the swap descriptor world, you just need to allocate a > >> > struct zswap_entry and have the swap descriptor point to it. No need > >> > for swap slot management since we are not tied to a swapfile and pag= es > >> > in zswap do not have a specific position. > >> > >> Your swap descriptor will be using one swp_entry_t, which get from the= PTE > >> to lookup, right? That is the swap entry I am talking about. You just > >> substitute zswap swap entry with the swap descriptor swap entry. > >> You still need to allocate from the free swap entry space at least onc= e. > > > > Oh, you mean the swap ID space. We just need to find an unused ID, we > > can simply use an allocating xarray > > (https://docs.kernel.org/core-api/xarray.html#allocating-xarrays). > > This is simpler than keeping track of swap slots in a swapfile. > > If we want to implement the swap entry management inside the zswap > implementation (instead of reusing swap_map[]), then the allocating > xarray can be used too. Some per-entry data (such as swap count, etc.) > can be stored there. I understanding that this isn't perfect (one more > xarray looking up, one more data structure, etc.), but this is a choice > too. My main concern here would be having two separate swap counting implementations -- although it might not be the end of the world. It would be useful to consider all the options. So far, I think we have been discussing 3 alternatives: (a) The initial swap_desc proposal. (b) Add an optional indirection layer that can move swap entries between swap devices and add a virtual swap device for zswap in the kernel. (c) Add an optional indirection layer that can move entries between different swap backends. Swap backends would be zswap & swap devices for now. Zswap needs to implement swap entry management, swap counting, etc. Does this accurately summarize what we have discussed so far? > > Best Regards, > Huang, Ying >