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 89145C761A6 for ; Tue, 28 Mar 2023 21:01:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDF3D6B0074; Tue, 28 Mar 2023 17:01:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C66DE6B0075; Tue, 28 Mar 2023 17:01:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE0306B0078; Tue, 28 Mar 2023 17:01:50 -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 978946B0074 for ; Tue, 28 Mar 2023 17:01:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6471EABD9B for ; Tue, 28 Mar 2023 21:01:50 +0000 (UTC) X-FDA: 80619528780.15.579E37C Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf18.hostedemail.com (Postfix) with ESMTP id 735861C000D for ; Tue, 28 Mar 2023 21:01:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CY9YNUUc; spf=pass (imf18.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.47 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=1680037308; 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=u+DbjLuzkzcet2lUpX49fBP5JnfIaR/oaqcMhwNxN34=; b=Sd1WdlWBxhsWIe1Q4SSwZbm6wC/h9BU/AnK7kZDdXSFJ+nIHxVFGTFs+NDQ4+VrARIcOvg 8priZY+uoNkoBLaXV8eCFS7kForKOUPjUJ07LIslUInT0is+ZlkEbvc09PlOWM7gjFDLeU v7yNuCJVIxmeBqAY34tWFpaclmT+Bc0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CY9YNUUc; spf=pass (imf18.hostedemail.com: domain of yosryahmed@google.com designates 209.85.208.47 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=1680037308; a=rsa-sha256; cv=none; b=y/5P5spY5hS2Cq29XsfqeZctMuUQRUVCFX+Bw2YiSCwCxUFlbTYmPu/5lNDAJfss3Jz1IJ rVF5/q+1q9J2KOZZCAOt9WYrWQIaEaFFAnulrEwgvLNes8neLokDiu+pfj6bDC477ttdG9 5fpGJ32kuy2Z+M1/1elFQjwzNpxe+ts= Received: by mail-ed1-f47.google.com with SMTP id r11so55023982edd.5 for ; Tue, 28 Mar 2023 14:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680037307; 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=u+DbjLuzkzcet2lUpX49fBP5JnfIaR/oaqcMhwNxN34=; b=CY9YNUUcOSKucHH05jU96YxwaRb0XfYGntJFd69niWkLfeYaeK0BZh6WHElzkw6hkF /vAfSMHOYEAiGCmzKz7gGpS6J7BIs8chFq3eoh8hBy2XWgtVF3v5vDsY1NSY2ads2PFu QfJ8yTJ8E4yWMPdPkxTuX8PErAFoLs0vPQfMmFmySoD8azcrLdcos5s7ePCx2Xy6VU9A +7iNfGBZXQI16WhEiidq+QSXGulV+qYZm0rh3mqECIEV0+1JhJkXc8dqbaJTZCKeskBM MOnn3mtH3LPrgHJ2szVAdXtbryPs9nd3o9kwJEmlrOazu9Ipeg+avq4VWk1Vb5MP/rXN CN0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680037307; 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=u+DbjLuzkzcet2lUpX49fBP5JnfIaR/oaqcMhwNxN34=; b=mO7CB8CMn7oke7w57xTLtepF48AnuItu25h8q53XWP/hhTtcPtxnMztUxO/K6Wtaoc fBTUgNKlxZZUsSZmDbVmBxFP8b3xubh0AjzUrK6FfdQtHG+ns3jzhmvkimJdx+T99ZAX h73RSrQCiHv8srsxmAk1z8O62wBaJROcmHy9ymgkmAESEEltv9/ajhoyrk5wq5ApCcQO vkZQ76Ouv+ZNn4DzJ8xi2vYZ89r+DinL6zk6izMcs28XEFdhLW0IxwLBvk5eUeRhsaNb gG/sjrvUPyR1Z6ZIUfRuWHUirZIbUK0Wq1EPmj2I/fRO/BGnEa6GAsF+I97R52qQC2JH 4unA== X-Gm-Message-State: AAQBX9cbaC0N2rnr1WTw594d6+p7Fdm0XhtxwfAZHY2S5NUH4CLY+y5s nhv25+rSKW+Mjp0alds4AnlfVqlFiBXJhVpLhCVexg== X-Google-Smtp-Source: AKy350ZQs6/ypqRXx3CsDKM9UbWL/RIc0qip1cOOwj150MtMsz/lZ6pFA01abOqINfc9Vm1Mdldw+HHMv0+77id0+cI= X-Received: by 2002:a17:906:7846:b0:933:1967:a984 with SMTP id p6-20020a170906784600b009331967a984mr8228762ejm.15.1680037306602; Tue, 28 Mar 2023 14:01:46 -0700 (PDT) MIME-Version: 1.0 References: <87sfduri1j.fsf@yhuang6-desk2.ccr.corp.intel.com> <87edpbq96g.fsf@yhuang6-desk2.ccr.corp.intel.com> <87jzz1pfb3.fsf@yhuang6-desk2.ccr.corp.intel.com> <87fs9ppdhz.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 28 Mar 2023 14:01:09 -0700 Message-ID: Subject: Re: [LSF/MM/BPF TOPIC] Swap Abstraction / Native Zswap To: Chris Li Cc: "Huang, Ying" , 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-Server: rspam07 X-Rspamd-Queue-Id: 735861C000D X-Rspam-User: X-Stat-Signature: 75m5usrq8fsf4ug7xourt9mutpt7uuua X-HE-Tag: 1680037308-791171 X-HE-Meta: U2FsdGVkX1+D8zMS77Ltyrl2gt12Cv2GBw2f/e/KVNxefXhzG+JFwC4hlQ44UbJYcBUTWxroLJVVN9y5JDQeEjqP9WhmPqootaSzQfh1fzT6u7jaKuqKaIg7EJyo7bqFCFFsdttGjuqhRiEQznJ9LNrx2XsKcRPQ/Bp+3yADzl+Ow+vyQbdlUx6X85wRM5HQGJEfShlLk+tRot0XxYew7pWHqkgVcn2aXcv7YWE3U6QLVzBP5N4L6odFUGfxXzNxsaR9nCv0qpfstbepSOJReNmxzihAy+49UVqOZK0UnZHdRZKUCJj3HBEnhJdOf9vrQclJEgdrbNw8pChTCx97BIDlCx4gAf98ujmdH7pts5ZijyfYro03L2mxSc1S1OeEyy5k1bnnQatE+lb1akPaGGR2OEvMKKFuRphHJB/NKoaciTJMvt5+nE45o2TYahYinSSp5iCb7cxIPVDwH51YH68crlzDd1WsssKiu3IuKYSaW0S2kH4nIZTnzOOhJRtc6OK0QEF3sm9Pxj7Z5uZTomwuMTRyzhL0el7GBrvCUhaSr8m55VHhAT82dJ1sP4C3lH7DwZFx2g0eZ2BHB/bQZk3JyrdxJnUbUKxmlN9zVTr4LIuYaSQmOgZGhFats2tlLTAOfmAAkDPqYOU6AWOQogAO49mBL4SeJUMsVvZs4G7cDxyxensv6c9bN5XRjL+cpRZdslkUgPGp+vJza0ZeRqKHWmZdW8d9iPb7LWfhcVSLPqlHKtJrrkd4M4geoe2LNDFjfH1rEfAnqS7S0vKxu+3P1oMbUIn1JgLGjY8uD+wdxTrBlPA5Jki/fdp0nBKdGBedTG7ZCfcP7i5TSCRSEVEofkxTm3AWNG/XXh4GK+SSO31cU0PtjFkja8blsY3yLUgBrGz0ncY1fp7/SR+bOm7NWox9PEuGSTXdcoDQTKCnc3+JZMvgIpph5N/+ICAWv8RGtGBmbeo2ewNszn8 +w6DEQnM HKRXp8pT6KEuIaJPbLB1yWvJKbxlFV92dlzwDwQC8OpN9SGCzKS2D6+//H987CNwCQkaUUvPC23MBKjpfsy+neG+6WTOhIcp5AyLYTn8t1ZRtiasp4jRgdZ6MIig1znvsVbjHL6OTdmuHv1XO6Bn1mskkbouXCU3KVYY99sC62MLRTydofkFxtcF4Dy4njWAerkOGyAsRguppPi8uhpdvmZZUldHN9VbnGiHPnX4hV37cYFnh3y2KtTK9LYnnmKAFwmRLVfUQsLNlykbTAib40T34eorEMsJTP8Cp74oVQD48GjuAsAjtJl1zzvCm057mcJzVJdvGfjHURxk= 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 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 a= s > > > > we still treat zswap as a swapfile and have to deal with a lot 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 slots > > during swapout. The initial swap_desc approach aimed to avoid that. > > With this minimal ghost swapfile approach we retain this unfavorable > > 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 pages in zswap do not have a specific position. > > The swap entry space is smaller than the memory address space and > there are other swapfiles can use the swap entry. You do need to do > some swap entry space management work to get a free entry. That to > me seems unavoidable, am I missing something? > > > > Personally, I have no problem to change the design of swap code to ad= d > > > useful features. Just want to check whether we can do that step by s= tep > > > and show benefit and cost clearly in each step. > > > > Right. I understand and totally agree, even from a development point > > of view it's much better to make big changes incrementally to avoid > > doing a lot of work that ends up going nowhere. I am just trying to > > make sure that whatever we decide is indeed a step in the right > > direction. > > The ghost swap file patch already exists. We might just share it here > for the discussion purpose, list the pros and cons. The ghost swap file patch that we have does not work upstream because: (a) It involves ABI changes (we start supporting swapon on a sparse 0-block-length file). Hence, it cannot be an incremental/intermediate step because once we start supporting it we cannot take it back. (b) It requires modifications to the swapon utility to work. In my response to Johannes [1] I described an alternative that can work upstream and wouldn't have ABI changes or need changes to swapon. [1]https://lore.kernel.org/linux-mm/CAJD7tkbudmPTEumgKJZ5pXy6O79ySbGiCnAZXn= UUuEmfZ6KCtQ@mail.gmail.com/ > > Chris >