Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp863549rba; Thu, 21 Mar 2024 16:58:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7nZSkB5o8AFB4NhoeTuFr2ffTp4qvhLUph8CnICVZ/wtqMLTdcuJcJNaG3S4vMim+dxW3kiUWlBUFqiMaW7zpB7vV8dYODTSwxZmjwQ== X-Google-Smtp-Source: AGHT+IH6KLEI9nasXwKHsQxpcI3q2s2YjjZG3iEhS8RpH6T9mJtrvA70otlhH1Hatr7Pr7Dc7gst X-Received: by 2002:a05:6a20:a795:b0:1a3:3e30:a7e6 with SMTP id bx21-20020a056a20a79500b001a33e30a7e6mr873721pzb.59.1711065493406; Thu, 21 Mar 2024 16:58:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711065493; cv=pass; d=google.com; s=arc-20160816; b=O11CwXpTsyK3dxglBX/9UCimVtxTeL133ZyltS/dKEjIprLOU6kIeTBSHDrYK5pX/k tNLQj3KTpkbbNT601C63NzosloDuUtp39rG+twbLA6NUyHj2vyqhvhjbe3tW9ti+s17d aHBaX8xbcmBqk5c0ndjFDILRg0wV3RGqWYQyR+kNE0eZdPVhNJb5g8Sfw96uLVJRCSSj hamXgOaljXUTFariupUp+vn7rx3xuhDybAGpNPeH5VilBa7p1b/2/837HHssg88R0+C5 b841GLurRBzC0PlVlFRMCXJzjBBYqf7d7WImqitsJaF8SG5IzDC1+bLMMohnX1Pwkdep FXUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ul906RHRjtTt9ICgM5G5gAfi1fYFVLGfZkDm8s9ACk0=; fh=sTsvx47UliH+2mRpFi6wgWskiCn7Z5jLIA73Xj/CpgY=; b=tohou04hlTnHfnjGnHeiSN2up2A5yGmufgnyQqFhoCTA7XSAJTFy8wFmNpqb9dP4tw 0YINmusOg3X4dPFzYFFh6X58NlG0iZUQ6bFKzyY86DAVugNWtE+65+WkbRxfXkmXZxXl JISL2j/dmA+dr3f0iB6mQ+NinwVo4W+DduWOxPg0te+/W7sAAqE3CrRhr/grYUNvun5S WpEny2qXLtjia8Q2cvLymAfWkzQUsVmECMQGZooyym+47gY01kvx1FyiihSpjIPJyr/s cKiKFtzbPwKL38bRqdK7F8Ow2M/mmvrhtuZ+flZc072lwtNMojYDz45UFHGMZet79mON V8yQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="E/AIWHy2"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110807-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110807-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z37-20020a630a65000000b005dc892e61d3si760728pgk.657.2024.03.21.16.58.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 16:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110807-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="E/AIWHy2"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110807-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110807-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 10A472844CF for ; Thu, 21 Mar 2024 23:58:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BBA431758; Thu, 21 Mar 2024 23:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="E/AIWHy2" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 797DD3232 for ; Thu, 21 Mar 2024 23:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711065487; cv=none; b=ddrJhs36rrTmLeEShBIZydTbNhqFIj2OK3EfeK8r8/Pw5Dr0V1OnmybRgsvJQrUD0sq9olSAUCRfc8RUXjFkU1EtoU0zsIQ2OV/RZdEKnmMEBAEE4jBsgAarEHLbxyRNOrpXrcbm87ehM3sQb9PL9GLmFDFfUoIJipNAetgo/ko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711065487; c=relaxed/simple; bh=D3spBzrZCMW5GEaWKfvQ7BuGSOqDGgSKDmzylSP5FUc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bzVIeLI5zJgRswevPLlyZBlx5qhgmJthffHTzXZ+jcMW7O7nxxYxxRTywt+Kr9BBwXgnbXHp5u3i1SgCbP5TEZUeH1cu27Dn1dtA/GYIRlKT0CKzwISX8d6rpU1ftH3XHIAye+3m2HwPGj9naj0aOe1jwUX3/oVx8r+pSaJBxtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=E/AIWHy2; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a46cc947929so220711766b.1 for ; Thu, 21 Mar 2024 16:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711065484; x=1711670284; darn=vger.kernel.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=ul906RHRjtTt9ICgM5G5gAfi1fYFVLGfZkDm8s9ACk0=; b=E/AIWHy2kUhdi3ylQFwNaEfElX3VmpAR4a9kUwzaxVNiuluLP3TrySnZXHQRISIEkK PlrG13hwwupceFSkA1X6DYNxR5Zo648FEXaah+Ogo7MlPyVMsot0bmpv1nBEMxP02tIb zsR1P+oCeRQj3ZrxFb4N5FY+c+uTeC1Ogi0mr0BCrYsc0PBGg0tN7oEX6eENMnnZXY3w jUV8FQ119UNddvbH8rgla9iUkgZtooxVR1MK9QJMkt1334GQSgR+gyxPfxBlhmEPsjJk g7ZODYY7W3OJOG4agd13whrEmq0z4St5mn1E6bQ3xSqjXf9dpGpUxbDcxApwuvhJt8UJ SnMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711065484; x=1711670284; 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=ul906RHRjtTt9ICgM5G5gAfi1fYFVLGfZkDm8s9ACk0=; b=c0/+UJmL7MJws2JmlXzfCJcHAy5yOTIiwZ8PnmTCdulm+z5z6eFE+J8QQQ2LV4nJyf PAVqTFiLpoEgwyKoIfs43W8R7IFNpp8zxT46YjA5UVuOucgOknxE2tRH1bA+aZKIJkxM Uf4H/v4bDGMBLU/QENfxoUmFH3QeYUoXQghncbhhpfp/w2fg0fQs9uPBm6kAOGveEXRz SIoGh1uxpPNBRKO0r/WF8XBPYCIgezFDtSH7AnidCJRv6ncxiDVBjtmipRSAWG1LJC81 2cFZD2Syvj6F6aUP2h+a7qjzrmcr0hy6laJN+/Ig7pSJvWKKa3q1BthHJYT1Nux648Bx v0Fg== X-Forwarded-Encrypted: i=1; AJvYcCWh/MUAtWlwWXMWPwtTRSBrARD2KzT42HFbVnhunLiRBnTQjsdGSUWpjRn5imZXzgm+bN/BtfLyDaF9aja5aLr0i2u1VnIHFy/fu1LN X-Gm-Message-State: AOJu0YwNd8yfH0F8tCKoh5VROSpAGjI3c4C53y+lyxy8pDI6Emf67bCv 6UpVkHtbYCj4Mc1UnlgjjlZA0c4kxaNk9NrB/zOqxeBUPSPZxgrwiT5+zBVkS5Zlh90tcdb98xT tQuiq912Br2EW4DZiiuMm69z4F3eSKVKFzLKjmoLtHESu+cj2IA== X-Received: by 2002:a17:906:c349:b0:a47:876:28b9 with SMTP id ci9-20020a170906c34900b00a47087628b9mr532234ejb.42.1711065483601; Thu, 21 Mar 2024 16:58:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240320020823.337644-1-yosryahmed@google.com> <20240320020823.337644-2-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 21 Mar 2024 16:57:27 -0700 Message-ID: Subject: Re: [PATCH 2/2] mm: zswap: remove nr_zswap_stored atomic To: Nhat Pham Cc: Andrew Morton , Johannes Weiner , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 21, 2024 at 4:50=E2=80=AFPM Nhat Pham wrote= : > > On Thu, Mar 21, 2024 at 2:09=E2=80=AFPM Yosry Ahmed wrote: > > > > On Tue, Mar 19, 2024 at 7:08=E2=80=AFPM Yosry Ahmed wrote: > > > > > > zswap_nr_stored is used to maintain the number of stored pages in zsw= ap > > > that are not same-filled pages. It is used in zswap_shrinker_count() = to > > > scale the number of freeable compressed pages by the compression rati= o. > > > That is, to reduce the amount of writeback from zswap with higher > > > compression ratios as the ROI from IO diminishes. > > > > > > However, the need for this counter is questionable due to two reasons= : > > > - It is redundant. The value can be inferred from (zswap_stored_pages= - > > > zswap_same_filled_pages). > > Ah, I forgot about this. For context, nr_stored was originally a > zswap_pool-specific stat, but I think Chengming has pulled it out and > converted it into a global pool stat in an earlier patch - yet, > globally, we already have zswap_stored_pages that is (mostly) the same > counter. Thanks for the context. > > Might as well use existing counters (zswap_stored_pages) then, rather > than a newly introduced counter. Probably will shave off a couple > cycles here and there for the atomic increment/decrement :) > > > > - When memcgs are enabled, we use memcg_page_state(memcg, > > > MEMCG_ZSWAPPED), which includes same-filled pages anyway (i.e. > > > equivalent to zswap_stored_pages). > > This is fine I suppose. I was aware of this weird inaccuracy. However, > for the CONFIG_MEMCG case, it was kinda silly to introduce the counter > for per-cgroup same filled zswap pages, just for this one purpose, so > I decided to accept the inaccuracy. > > > > > > > Use zswap_stored_pages instead in zswap_shrinker_count() to keep thin= gs > > > consistent whether memcgs are enabled or not, and add a comment about > > > the number of freeable pages possibly being scaled down more than it > > > should if we have lots of same-filled pages (i.e. inflated compressio= n > > > ratio). > > > > > > Remove nr_zswap_stored and one atomic operation in the store and free > > > paths. > > > > > > Signed-off-by: Yosry Ahmed > > > > Any thoughts on this patch? Should I resend it separately? > > Might be worth resending it separately, but up to you and Andrew! I will resend to add some context and include your R-b, thanks. > > Reviewed-by: Nhat Pham