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 9CBACC27C4F for ; Thu, 13 Jun 2024 23:00:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B20876B00A5; Thu, 13 Jun 2024 19:00:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ACEFC6B00A6; Thu, 13 Jun 2024 19:00:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 970676B00A8; Thu, 13 Jun 2024 19:00:36 -0400 (EDT) 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 76B226B00A5 for ; Thu, 13 Jun 2024 19:00:36 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1B00A160383 for ; Thu, 13 Jun 2024 23:00:36 +0000 (UTC) X-FDA: 82227386472.07.8117766 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf11.hostedemail.com (Postfix) with ESMTP id 4110B40009 for ; Thu, 13 Jun 2024 23:00:34 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=zpf0PL62; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.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=1718319632; 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=in7bSM65Hqq2fx5cz/q8ttOiOGDO4K8TaJEiNCokU7s=; b=POVOpQD2oY/0v+4z2hXnif6gArhDvxvUyz99fwCw+glzxqu/PW+MPXJvHm3Rw6NWeNUQkC RBOc8zpLb1SDnWIRJ3uskfJSBR37yRK1p0exBwiupeifHrC2bZl8qcUFncTiUPNhk0IF2u oz9kVssAmi6GXfOmhk2EKx118odAykQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=zpf0PL62; spf=pass (imf11.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.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=1718319632; a=rsa-sha256; cv=none; b=BifmlRSGrjOdbeY74DiYfYGp5hoqC63J1UwTsh1XN/3DWFFJuctWa6qr8AKl9+m2ZQ0LaA c7eE6jQ2PFYyPFcscYgZ/NCh9uo8cFw7db1bktJMutnPcgR2D15fUlb6+y/EII+PhDm3sh uWZB/pSISmpZK5AMylFieorbBCvlGok= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a62ef52e837so208230566b.3 for ; Thu, 13 Jun 2024 16:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718319632; x=1718924432; darn=kvack.org; 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=in7bSM65Hqq2fx5cz/q8ttOiOGDO4K8TaJEiNCokU7s=; b=zpf0PL62BrlI+9gRQw2+8UBlVhQeTCLSG6r6qq30vnpZbC/hk/qEBlTbTFjQmGCAq2 PEXS1y5uIynbhaK5LE7PXTDocZbpaWaExP7+jOFBQsEJipGeI3z0KPVOTFliDD3PEoMv sE0SWPk+sBt4j71jPeKcEFGgvcE7bgdIsyRc/EjzRizLgw9sUOn4fXbobhty3Z4OP2dS 8tQbzGtS3YC7Kf3p50eGBps7gICY0wQA5+Qz5IkUzhLo234qKZkGLYXxBA3D6B5RkTvZ bflVIK0K1ZUzVwRNyur+Rswx7qJBSDawNI5e1fQZz/DA89fZqO+yPpohETSR5RJkUGMT vD6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718319632; x=1718924432; 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=in7bSM65Hqq2fx5cz/q8ttOiOGDO4K8TaJEiNCokU7s=; b=YapW4tyLHoti2OTa208Oj1nkuQLk/CjtnoruFNbGw8PVjKqxmkwZn5ipVKRvQFO7hX euQLF2sQPJ5KqgQEr9h1H3U4RL7AFVPLmuevVE48rr2gMDDK7fEu0mtVyK9kNHFPcvpO a1TLcu2uGgSmN/IRf5aIyhg2D4+r+woFNspXSDIiCXLHFEx+rHac4Dw7kVt0Sm7+LAk0 4ueDjzbWwGr0Wz55vIiKCpRC7Tq0Kwi4xu82IChniamReb3F70hIt9KegjoMe1f75RyH OZ5uplBrssY5ZJWXeuo9OkpdtIelRFMsgjC3yZFF/BcFf5r73hzHHWNPqnu61AsSvawf O29w== X-Forwarded-Encrypted: i=1; AJvYcCXIK9jF9B6SoviJlUrTy8QH/65YYtOlCglUxtVxVSTQsbAwGJHFJwz6roTYsv/lj76/eleSGkDNpMdQ/FQHALN5Ptk= X-Gm-Message-State: AOJu0YyxkMxSgijFDR7MQd6i2ZrwPIjjGCGqLSimGLjxFH9Kz8qrc9/9 aK3ztq9YB/1lsrkePMaBVz755YCvUpMAeUHdZuSvIcTT+T47uZQO2n+smiG5g9dIEzUttJUWzJc WOT3c2x6wFUfNYULZIpawxNBAXcoteZhG4ZQ2 X-Google-Smtp-Source: AGHT+IHv7YL+HgKxexUNIHykjwDr8ejWioEP6isoX94I1D3v366vVcM8A1dCYbCSKG9kzplS+yckur5HwAksdvVaPoo= X-Received: by 2002:a17:906:d8b2:b0:a6f:11f8:c21e with SMTP id a640c23a62f3a-a6f60dc2017mr69033566b.58.1718319632180; Thu, 13 Jun 2024 16:00:32 -0700 (PDT) MIME-Version: 1.0 References: <20240610121820.328876-1-usamaarif642@gmail.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 13 Jun 2024 15:59:53 -0700 Message-ID: Subject: Re: [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap To: Shakeel Butt Cc: Usama Arif , akpm@linux-foundation.org, hannes@cmpxchg.org, david@redhat.com, ying.huang@intel.com, hughd@google.com, willy@infradead.org, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Minchan Kim , Sergey Senozhatsky Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4110B40009 X-Stat-Signature: z831nfpzuhped3aa1mrzbg5h8cr8b9ha X-Rspam-User: X-HE-Tag: 1718319634-486676 X-HE-Meta: U2FsdGVkX1/Xb9aLdukk9tSBPABjyM736GgAL54YcjhQb8tN+ANdN87x73toPA9h+bBFpmeqFxdFJ46wegdMF4ldclVrsPzVmZB6qQnzQV9fWskNaZ9z4aALkWNEtu/TVr+PVSBXCYpLrNJthTeCPmVurkdXhBBbIjB/zo+Hv69cW+EWE0gwWYs8qyA4TdtWSlLjUEDymgcicRlSN4NxYNIdH/fLUVjj6/wApSdChEPmXjq1gfp1otU3ZFIxxIFTRA3jQNN6XGuXu9ARn+KqxSVPPTUiCWkwcK+nsphU3ohXqAU6YKPijumEn6wBuinc+tLmNBrm6mglliOjL2ktDkE/5ZYWeyPwZVbtxtQzPiZ7uvYU+sfvGDK/bGZ/B8uzwUAJ6W0m75AJj7/xwsy6mseMwqtwU5ioVZvZzQNzldv5f023pVFBjg1SEm2e4u+IEGDRDOgXi/0fwEEBZqMZ8XWf+3whzAAOkgUCPi01b60G7yUKufL6Wy3cvIKWFQ1ujch/dO7mO0rZbOHK/NH3dx9tRLhd3BfTTmxK6d6vXysuN+So9yS+ADfIl0MahRxjg91q84tdL8NOyFb+tUhVvASGxCjsbuY3spF6n1V187ciFuobS0bfprC1YDl7ufvPf4s60t0fA/lBM518lYxRW9URMxHvhJ4vp8SX8ifL5vlOaec00Y9YC3LSz8RYTigSR3biZyBNahaJFmKeiGqgftUjyvJIfolYRujmMnEEqlaKccC1blSmAh17iRhtBNDRKAyawIrJyfD8QpnCAOs1h+3wsNLyoCRiq8GTK3Di4xMFsuickntWGAL/IIt6URe8VI0tW+R56AYLbVp3SYdokLM8+O60gv5n7p5ebxRrwrNUPMqHLSOXzp9y3A2PsbLAAeditnXzzY+paX+eNDdX2eOBVD2TB2211wBW7/AYiDPXVecdkVxj8SaMTytigpsVeIYwBH8KAN2zsfnWUaT qvk/nQAz /A5CtEvFn8LmNCVg6hDwnkvZ8GrL+HSJx5NiFnR8JoKEVMWgCZquG7OCTxMOtt2Snkqur2zevve/NC94VPLj5/DT61GE8patr45tNqC2bvkWIVFAs156Ekz2BPwTmLpFgWtytRMpW3GG3HA+WmwQ6upXqaLDDMbUbL5GQTA3LVarkswRENRUQRSs1GF7vHgaZOsBc X-Bogosity: Ham, tests=bogofilter, spamicity=0.005490, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jun 13, 2024 at 3:41=E2=80=AFPM Shakeel Butt wrote: > > On Thu, Jun 13, 2024 at 02:50:31PM GMT, Yosry Ahmed wrote: > > On Mon, Jun 10, 2024 at 5:18=E2=80=AFAM Usama Arif wrote: > > > > > > Going back to the v1 implementation of the patchseries. The main reas= on > > > is that a correct version of v2 implementation requires another rmap > > > walk in shrink_folio_list to change the ptes from swap entry to zero = pages to > > > work (i.e. more CPU used) [1], is more complex to implement compared = to v1 > > > and is harder to verify correctness compared to v1, where everything = is > > > handled by swap. > > > > > > --- > > > As shown in the patchseries that introduced the zswap same-filled > > > optimization [2], 10-20% of the pages stored in zswap are same-filled= . > > > This is also observed across Meta's server fleet. > > > By using VM counters in swap_writepage (not included in this > > > patchseries) it was found that less than 1% of the same-filled > > > pages to be swapped out are non-zero pages. > > > > > > For conventional swap setup (without zswap), rather than reading/writ= ing > > > these pages to flash resulting in increased I/O and flash wear, a bit= map > > > can be used to mark these pages as zero at write time, and the pages = can > > > be filled at read time if the bit corresponding to the page is set. > > > > > > When using zswap with swap, this also means that a zswap_entry does n= ot > > > need to be allocated for zero filled pages resulting in memory saving= s > > > which would offset the memory used for the bitmap. > > > > > > A similar attempt was made earlier in [3] where zswap would only trac= k > > > zero-filled pages instead of same-filled. > > > This patchseries adds zero-filled pages optimization to swap > > > (hence it can be used even if zswap is disabled) and removes the > > > same-filled code from zswap (as only 1% of the same-filled pages are > > > non-zero), simplifying code. > > > > There is also code to handle same-filled pages in zram, should we > > remove this as well? It is worth noting that the handling in zram was > > initially for zero-filled pages only, but it was extended to cover > > same-filled pages as well by commit 8e19d540d107 ("zram: extend zero > > pages to same element pages"). Apparently in a test on Android, about > > 2.5% of the swapped out pages were non-zero same-filled pages. > > > > However, the leap from handling zero-filled pages to handling all > > same-filled pages in zram wasn't a stretch. But now that zero-filled > > pages handling in zram is redundant with this series, I wonder if it's > > still worth keeping the same-filled pages handling. > > Please correct me if I am wrong but zram same-filled page handling is > not just limited to swap-on-zram use-case and any zram as block device > user can benefit from it. Also zram might not see any simplification > similar to zswap in this patch series. I would say motivation behind > zswap changes seems quite different from possible zram changes. I would > recommed to evaluate these cases independently. Uh yes. I keep forgetting that zram is used for other use cases than swap. Please dismiss my comments then (unless it's uncommon to have zero-filled / same-filled pages in other use cases).