Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp803761lqp; Thu, 21 Mar 2024 16:50:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQQRrHOsdcY/w+OhvclSKd7N6YYWoSD5g/3SaYm9UACaym4uv0DD6/12SWnkk2fVzClpOc4J+InFYaLL++rNcZwlpYih9VnKd6Pt9PSg== X-Google-Smtp-Source: AGHT+IGRITSYFqt7R7gHSTprZzvkjcAqzH8/YOC+aFjIP/dSJ3Rypk3h1Gq5uAhNl9/FxJ4f2Zxx X-Received: by 2002:a05:6808:190c:b0:3c3:7d55:ff53 with SMTP id bf12-20020a056808190c00b003c37d55ff53mr958999oib.32.1711065029146; Thu, 21 Mar 2024 16:50:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711065029; cv=pass; d=google.com; s=arc-20160816; b=PavKct8uYBwg0/Xz/7IEZk+v5LD9/IENv3nVgjuv/vaC3wLrAoIckvjS+K8JD8OsCi YjMAydWXUX7oy1UsINf5ya+TCoD8dNDtlLzie6FhhGkVzgaQz2SIVCeRmwMIJAgxjgKr 66HveHPqA/U+NWWzW3XLr/quHr2WMOT/4Mdi2hvkvh10ABFGEFAD8qubCpWqMTs4Yw/y wBaLqxQDeDbMDPfkuNTkx1RAwYQ28Mne30O8OrY+zd8RJe5cOiQB2YsuH3HRpG7XOtZn fbqiDp+DGlPCc9kt26Sa8pUoPRE5ef2Lx8Mmja6VT9Ni1aKU0UTRI5Aqks3i1XRirofQ HEBQ== 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=AInUnOXLyp8jyRpi/mQ+Hq2H5NzsN1cFn4pjjPB7jgI=; fh=vJmVq80EbmOe+U49q/iuVw6LVW4Pvr9NZK2Eiom6bvI=; b=dFHUo6YPeoSj59bQkqA7WaK4NirpMzs2A3MAs2yI9tn+edz/Zrga0X1l07WUlY2o6T BHPp2cQigIbJ/BoHzyw0vapx/2JY6kFIvt43r6ARF+zNRbxxZb47Vk0AcjgiAvQKN64S OhHwrX4ndkgKG/CelEVKiethFyrkjZ8fmYnxntAimkuSz8Rn1MnHcZNeEx76zYM1I9Fd kUgbUESV+S72N2x80tMU/xIgCYHKaZS0NZEzVS13C1sk0pp99zgGaI769/GpMn0OzKal 4KfXr6C+/xA0iFvwpII/KE6UJNAxZmHCFnmLwTQ2qMpbXcizKL4X2X8haBpxqKTLULKU FQCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bVsAM9By; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-110800-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q28-20020a656a9c000000b005ce08c4bff5si793254pgu.760.2024.03.21.16.50.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 16:50:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110800-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=@gmail.com header.s=20230601 header.b=bVsAM9By; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-110800-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110800-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 C36F028443E for ; Thu, 21 Mar 2024 23:50:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B22724B23; Thu, 21 Mar 2024 23:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVsAM9By" Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (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 E586F1DFCF for ; Thu, 21 Mar 2024 23:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711065023; cv=none; b=qWoaB9Ff5AHvVtg4oTxpnh6qWPPDK+ikGDFUc79+aBqbW6Y8Gq3YTi797tL49KvuW3KjUKtlKvCQ+a30uI6nQ0fNqpg+ihfdnes7PW/CLQBIwP3OtGZHY31Q7SOfhh4aj6avULwsQ5afGdD2wZi9lG88mIgA9SsZ9Rlxn8sei3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711065023; c=relaxed/simple; bh=TZO4+cozYPSKDbCtI28YTEVD/Esl0MisAiIACAehqUY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BBG+dp/gF0PfXSNBOx7XKZ6fdq/AgiKwPCtXzHwM88kxcEZweGk5utvSbPNb39dpy5D8ENt/1Ch4bGnQ7p4vK3ByxKniAkOSQ3Mc+QjyOosvWTvsDUyMbZwjkAHTa6Tx+TsMRDC7gjxrUuzEXWa150gwbkro4a9J/wFO965xvOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bVsAM9By; arc=none smtp.client-ip=209.85.222.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-7dac7cfbea0so270032241.3 for ; Thu, 21 Mar 2024 16:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711065021; x=1711669821; 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=AInUnOXLyp8jyRpi/mQ+Hq2H5NzsN1cFn4pjjPB7jgI=; b=bVsAM9ByqmMj/6Ao1ptzSk+hju033u+p4iVfmQshdPsds9qAR/3GV6y5auXZLBcjCQ fV/w0d9K7wNfhnxWt7Qw7dpimrQoA+YC3bb4yRjtuz+D3SnKfWs2wwI8xWRnbMXorqrR 6L7M8v1ej7pRX8eA+E/CiBxFD87joQkrxOVbJYnXrdohSbZSZ+dYRA61W1CmXnj10j5C mD6nFDaQDdSPUaUg3S1kdRmt9eskoBbBMjfC6FWMi00rxy2nIn0JQ8gmdDsTnHyrE88a PykIC7i4gLC5g/lQ4HGLuNfzrmWYnqhtnfaoe/et8yhCR0p82ce0W9TbTDlYS7vgLbhj Zipw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711065021; x=1711669821; 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=AInUnOXLyp8jyRpi/mQ+Hq2H5NzsN1cFn4pjjPB7jgI=; b=kjVkpQ6yOaWe3kAH9dfkhXDwmSB6CxqV9Bogoqk6cIbPnh41dxneHRdR1/j7dUYyOJ XNcP8bcDU00/tfXFQIezlNTFtthrlIJ5p0l1SKANMtB0UgdaeiU6AXr7aa7t4cFaxdPM DnQzKh8P+zQcs0jCDsG4HCwkpnEAIymesWkM0zyk6GOEx5gAN75Py2Zge4V2I2o3x6ix N+pwzbyjzLWNvF/JJ4zlIL9FPkqOVlf8TdtHP3RuMokAzi7dz5rHpZAIxiTaICdb0LJQ hTVDMmmGa1N/GVn5VqHNA9sd7KGzXlos3id653lnTPUAuUflTW+iJee7CrvlYqe51DnQ 4inw== X-Forwarded-Encrypted: i=1; AJvYcCX3UThLurPZG0DxsKhXJkDXG9gBXDTXYDkeD21w5N9g8xN6oNPL1ehvaeIxeXwQPHYrjh/r+ldsgw3QAZjmUDF9z12fNo7yumSrDVFx X-Gm-Message-State: AOJu0YxIOp+IX2HCUKvebhJfoJNw5QsFw1xuZ7xjWaHKEaxHF42Glb5H TF6P0QAqunsFV0PxIqdpgwfC98no2oYNd0vhY2qHquhvJP/5bOa3W0mL6sdt91/hkMessWOZUgC SJ2LpZE//ungmKbrhRC1bEWKXaYFDsUai7AThNA== X-Received: by 2002:a05:6102:dd4:b0:476:bf60:9556 with SMTP id e20-20020a0561020dd400b00476bf609556mr1467512vst.26.1711065020670; Thu, 21 Mar 2024 16:50:20 -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: Nhat Pham Date: Thu, 21 Mar 2024 16:50:07 -0700 Message-ID: Subject: Re: [PATCH 2/2] mm: zswap: remove nr_zswap_stored atomic To: Yosry Ahmed 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 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 zswap > > that are not same-filled pages. It is used in zswap_shrinker_count() to > > scale the number of freeable compressed pages by the compression ratio. > > 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. 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 things > > 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 compression > > 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! Reviewed-by: Nhat Pham