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 A0F0FC74A5B for ; Fri, 17 Mar 2023 18:23:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14ACD6B007B; Fri, 17 Mar 2023 14:23:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F8A86B007D; Fri, 17 Mar 2023 14:23:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F02116B007E; Fri, 17 Mar 2023 14:23:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E1DDA6B007B for ; Fri, 17 Mar 2023 14:23:50 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AA36780A3E for ; Fri, 17 Mar 2023 18:23:50 +0000 (UTC) X-FDA: 80579213820.22.3D6FFD2 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf14.hostedemail.com (Postfix) with ESMTP id B50F210001C for ; Fri, 17 Mar 2023 18:23:48 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RQRA7dQ0; spf=pass (imf14.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=1679077428; 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=Zv5rkC0jqLuZ68VVvUiTAUcjIftt7hVR8G6ZiD26rss=; b=RXlzi+pZ47r7NzxUtTiD8NLpAn/S0apyPpQJl6XgD2L91f3iy5c2zCVQ1Fj1pjKO3wXL9h B9jq2fy/RSB6vLkfYWvnNvIXI90klCGjl95RPf+4lMohwssfLgZ6yeAha84PjCFY8iv/+u SqId/PlvpBpo8/98pJxzWkAzF1hiiw8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=RQRA7dQ0; spf=pass (imf14.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=1679077428; a=rsa-sha256; cv=none; b=zwhN1dXCV6pqJ9BVhVIx9JLgBw6mvckyS24nHAQ05jUrY01P5u3fPWrcRZImLTDwY1dgvb XGfmS9ZbQXE08+SXmQkSu3OMfWeFrSlRcde75YSKOI6SkAImKHCcJe3v3/I9koiMiDubyt 4d6rkig7nzW/aTqil/DG+UbS5BvSHT4= Received: by mail-ed1-f49.google.com with SMTP id h8so23748682ede.8 for ; Fri, 17 Mar 2023 11:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679077427; 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=Zv5rkC0jqLuZ68VVvUiTAUcjIftt7hVR8G6ZiD26rss=; b=RQRA7dQ0r+cXUFE/kU0/n1ImjxjPTxpQ1HTdtO/Grfg1XhW8dtABZjIRfIRJe/odXZ nXzR+PJgDFmNAwN0MeloIyiC8PIu7raFk17kra+/WbIzk6EJqJfxofbhgxJaxZ5pSTTX r8tqoODmiCWIxOCz3+Pgl6fLfcnuA1OGMEizUqAqEqNIJAinsD1Y5IIqism0kWFjNk84 aPrNa9YQ7lpDUjJZjSC/0kTGD5QiXtMfmOOzYbe45WiClH6ytCPwSmQ3sQkloRwaRB8I Q5Sv0CixcdQkf0p7KcG8A5f/IqUpVvqW2Z+bTlIX8Ypn1KNA5O9eXB7eLUX96oRy+EOk N2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679077427; 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=Zv5rkC0jqLuZ68VVvUiTAUcjIftt7hVR8G6ZiD26rss=; b=WFL8fr6bALj9B5ka3lmhhPRZGC1GCj+Kzj6QXAJPSdFQrnojt/KA+B4GlSZFFAwfVi avRUog/2bn+Fx1h6Z9vEOytAjP0D8VxPraebCyscpViLrKvoNqjnp2BiB8e8XbfQ1V9L EvhmPhH0GnipaWusQtcz14t9MvdPnndKM+naoV5QRH0eHnEG96OVybyPkO8GNj8JW3eG 21aKV7zSYUl2swUaDjKUT+5G9Vh8Jb1YghfdIhU+abVDTTu/DaVlOsJKtBq5w/nedN7E rdF+jFlaFJ+ptVb2/7xwOFfYkx5YVu41FRnlcmIuDYfIt0wcCM1BydtH0en4gxl6TPPu Invw== X-Gm-Message-State: AO0yUKVsLXUanQBmziag1tlhuxaQYPnhTVuvnHVKSIFlVF0xvDaKPCfA YSSsWt0NW+EP4Nb1RqqhsGxH2KURGd80Ajqc2n59mA== X-Google-Smtp-Source: AK7set9dUuCXLvcs+R3FoOR4C6Hgbo2clCrSwmgn1sJxs6z5DrKMi+zAIhOK4PV/IkeYovnR7IYbrmTyhB5xZYtR3KY= X-Received: by 2002:a50:ce14:0:b0:4fb:9735:f915 with SMTP id y20-20020a50ce14000000b004fb9735f915mr2186099edi.8.1679077427037; Fri, 17 Mar 2023 11:23:47 -0700 (PDT) MIME-Version: 1.0 References: <87356e850j.fsf@yhuang6-desk2.ccr.corp.intel.com> <87y1o571aa.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o7ox762m.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bkkt5e4o.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 17 Mar 2023 11:23:08 -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-Queue-Id: B50F210001C X-Stat-Signature: e7qr6c6mto83pwwqs8zuq1igdo84wfro X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1679077428-240295 X-HE-Meta: U2FsdGVkX19FUkkS7tLEfk9/fDl45qliJ79JP2SvVLLmQXhrAYN3W5IbmXe/sRvw0XxtHCxa4VIV3FC9gzkOrVQAUtzDKz/ECBf6H45iQqWSA+zAgBy19h0ow5DbqQqBRBCDS6xLu41OKkT+Gn71RUV9wN2qhumFgOB63MGxYM+sJeQzLx2wUCHNWbY71tCN9E6ubfpkzBo6vBMkygflAol9H7y67qc2jjpzPzig68hUGeQ/oJmQR2Mg0YSHf5bAO8HxOvXEaZNYkLYomeuQPjxXklORu/ieJbToKnRK+1gTG8GrKfZTBAqjzB80Lpt25NK5mc2HiK9YtOIZuEjB4gpJHmWfhvVJvUi5wNvOOyG67DKL3UlozhaRcoskH4Q9bxWKtb9iIneFh+IlbWjm50MV6/Z2DbqJthPKFNo0YOC/uIBfag+ywq9b4oXocaFuoyay+J5dd8s7CwVXwD4Ale7uxuun9aIF/3NUOLygsyPAAmzVN/qlCLpLl1p/LaoTbP5XqsiD29NE36Q5gAHAr6Md3M/ZkuyKNVBepSl0D32ivJ5pDAm4m14s+NBe+Zqds1faoBbjReTdBwedZj0bIkAr4h1GpMyN1Bjm+7a5kkY/8PqoqGiQhu0nYDmYD/OosBLxeyX3b/xZsUmOfRUwdYiONFtPXSY6Gg0kQcduPnTx1dBPKGNlq4a3/bZrdyON66IOektHbnEgSxQZGDkAAnqGu9sJdu9hwz4Ege7tEb8br7Gtf1Md5LDaxrY6zPPPXu19odsZDmT7yysOU1U91kyKpVozqLq4+y9RHly5SUuuOGEN23s1Vq99Y+yZPj7sGb7GduSGrnH8WQyKgdFMTB7DSEzoSZZQQKLENZxv/czsrGTJpqFOPHRyRX0oFGIjs9Tl4aKBAxAzSF/RggxP5bk33p/aPMJPE/Br6tXcxYRXlyV0W5qRw9mjyure01CtvZVCo/9IuX2ZEYKSmbJ uKY6Xunq OLTckPlFsCpVKB6YuzANOsDP1spp6RwH7NtQi1udf+dsP9bCN30NSyT1WKf4ZDQGh744B4Q4QcffjsFIkxsgUWllQqkDlHL6DAdX5nzU6NP6O/2EkFBS55OcJOBR9VnVgIPq+fRKELS/C+bMz+3NtyxKfzvNgq9Uatx+chq+vOKpqNK4+y7Wwc4VFHmP1OKJ8YgYGQVO3V5CuIQnR2pIlD/bepAKC7HJynUMqeKSzuuQOOb9+iZreMCjSvj2GI8g0B6NoaTOY/YpG+RVZVpY5IkpqKFWSIqxFEVfFP++C4aZk2EjRUwJbApCgGA== 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 Fri, Mar 17, 2023 at 11:19=E2=80=AFAM Chris Li wrote= : > > On Fri, Mar 17, 2023 at 03:19:09AM -0700, Yosry Ahmed wrote: > > > Now, we will not drop the swap cache even if the swap count becomes 0= if > > > swap space utility < 50%. Per my understanding, this avoid swap page > > > writing for read accesses. So I don't think we can change this direc= tly > > > without necessary discussion firstly. > > > > > > Right. I am not sure I understand why we do this today, is it to save > > the overhead of allocating a new swap entry if the page is swapped out > > again soon? I am not sure I understand this statement "this avoid swap > > page > > writing for read accesses". > > When the page is swapped out again soon. If the swap slot has been recycl= ed, > then the page need to assign to a new swap slot, most likely different th= an > the previous slot. Then the page write out would need to write that page > to the swap device, even though that swap device might already has the > same page data in the previous slot. > > If keeping the previous swap slot cache when swap space utility < 50%, > then the swap code can avoid writing out to the same slot with the same > data, if the page is not dirty (read only access). > > The saving is in 1) avoid allocating a new slot. 2) For read access, > avoid page io write the same data to the same slot. I see. Makes sense. Thanks, Chris. I guess in this case we shouldn't just unconditionally free the swap entry once the page is swapped in without giving it some thought. > > Chris