Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp878037lqp; Thu, 21 Mar 2024 20:21:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2jFEHlN//jALlFfogzc7nv+GTDqHn7o7z/SxbUL6nr6nAXo/PHcEYBeCE47GU6rYvocRFuf1IkbgX6mtQRzfPN/L1qJMpcJcs6er/pQ== X-Google-Smtp-Source: AGHT+IGqBLmNwdE3036B2ZE6moCqI1Np/QCGuhy+sNY7t2gesi16rF8pPH3Ogs2N/DBKdPuUahHw X-Received: by 2002:a50:d65c:0:b0:568:b4b7:3172 with SMTP id c28-20020a50d65c000000b00568b4b73172mr645449edj.6.1711077699095; Thu, 21 Mar 2024 20:21:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711077699; cv=pass; d=google.com; s=arc-20160816; b=DSniEZFF36rhcY72Iy3Xn3AKtp9aSrpJNq0sqi2fJqgD9wC1tvzxr0w+/+dweKq4lV EMYOvEQe3Z3CRa2EL9ZXfLDGWT6ygJWvhWn8ReLeXw7TCY7C3XeSHQJTVfMXi5iobdGE zIKUHe7ACUsL9Muxubd+Ir6yQpOSPOn/HXjiNnY8LoK0Cpw12E1mjSTuuSElFzCi1enR pMeOEphrBAuXIQWg1Aw8vp8NUfqBhu8n0yiXEAcIqZ/FUDqDrz6q7gJ7+L2U8M2vmEzo 9K74GoaM4qBXlzKVN25mIPTlP/6jGXl4LjLT6WnA0NyBHuneABxbVOQdatHWjm7tuup1 JxnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3qK5RPUIDEOrZPbW4+iO0DfmSBKeGfcgd9g52YFXjRo=; fh=JZl7uj6l5hfVKWK7V6MVzNecKG2fVuzfedsBT4i7w8A=; b=nV4XLzbkLQWyUWi/E6HD+EMwPEk/RgPOyCmZEUhHPhFjooDRRGT2lJf2uviRGcab5E OVz+wwkKOeJqGZXS7vJwlt5cIV36yGqiQ2brGR+RCp2ehyY8HuP5Y8d9pJVNdV3EglZv otBY7WTiMSXsmkGCQcYnoPgW++n3bxJlYVnQmqUIHDSLjkSLGON0zqRqCKRHVGVE4j9N fdJrA14+Her7tiDz5ZR5c+hLC9YttuPymPXSqlYixuqeOSxkt4ADsI2Xb2iSz+ZkNkYc Azocx5qhZHlc8xqKRt1cscAjYALWoOO+6+kJn9LZkVBFdCENtp115v0VTWgDwNQdMUaK qZvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=CHKYfBQ9; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-110899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110899-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v24-20020a056402175800b005689f735366si494225edx.551.2024.03.21.20.21.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 20:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=CHKYfBQ9; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-110899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110899-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B58321F247D6 for ; Fri, 22 Mar 2024 03:21:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2E496FAE; Fri, 22 Mar 2024 03:21:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="CHKYfBQ9" Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 29227539A for ; Fri, 22 Mar 2024 03:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711077691; cv=none; b=UkvAm4FuVsuyMUb4an+UZm9gpOLomyvtwIhRNz1+x/SnppXbXcwSF4SD0xhpDm1JJQ7SxotIRn7X2c+RBH8xCxTWe2p9FQ8RxMuBKmFrBKEpasydfkthh4v+AxzGEuc9M5nSzNGYb05J3V/attVxpTqztnmEINHpCCoevJAwoeM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711077691; c=relaxed/simple; bh=tSBphr0xJtrX/LttuD4f/OrNSHZ9qYCmCb2vv1X1h20=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=klk+wWmkEjkVhr7XBpALBBrp448Os+JKwos7fZuM0RYmhleI8nwWoPOVNEiL48XJ2SocjeZBp5OrTeovEwZ8f+HTPrKGAqTLa6r/3CKM2c+0i7rzgiD8D0lx6GRJi9CxVBaslBmA67jlm2mdtJ8XZHA1cPiY+Q7HVciNWsGVQs8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=CHKYfBQ9; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-690de619293so11033796d6.0 for ; Thu, 21 Mar 2024 20:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1711077688; x=1711682488; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3qK5RPUIDEOrZPbW4+iO0DfmSBKeGfcgd9g52YFXjRo=; b=CHKYfBQ9L1hmGI7ktJ0Bi917HsvqKADEnvZzWRKfDaQAqedYy/6bMyE8rcbUQ7MkeT Rs/H+zuRzoW7mSQPUIcZkUVSEjJpBQ1vYcfUwIe/0EAsW3nmsJ+Z6OCx9qHLMo64bKx2 tkwi9zypFczrywkXBf8fuTCGaV3DUz8bAAHukB6r6SXnXwkmzXFNz4xnB4rlIPWEf+Pm /m0ufWt5+IQwH9NZUV1I5lyiNsI2fmCNe4CBwAInQ92XOj1SUFrlnm5Z3mAuuFHbp3yI SK98sPFrmK3cwnUzazl40szBKo/YfA7xVPjdVcn4vi8xNPOuNKMJt767ax+Y1qw9jgsm NfoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711077688; x=1711682488; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3qK5RPUIDEOrZPbW4+iO0DfmSBKeGfcgd9g52YFXjRo=; b=aG4nhzdi4ah6U1ulNIzSV7W7SMm0Bj7wnUIOE3/Ka2OQXwhQWl40iJIv/1Js02+nJu T30KwkuXWt2gKuYzJYntvbde5QfeeCqDxcQyhAPsyKnshdcWChXYnHuTusJcZ+pwA6/J KjJGnFHDoFoS0+doenXdRye5AAaLa19cjM+3yJuc/zY7H5TszDDnZvR8PJH7lCGtN8l2 HWbjwSV9yfDM5eNCI4eSugFQv8aKVbUXElhrE2S27xT4dIQlaGK/oFi3N1Tf2VSx9zL2 KeEnuTyhjBBTx4fd7EEfm4NkLRMOY+robVIMIEYel4GxK4KcCJSOSGzgHTRXRyR2MD5n G8aw== X-Forwarded-Encrypted: i=1; AJvYcCVr34jE/r5XbSoXmz5pfRCwE1w2XJw74DR8wr7EVtvuv7d+Fl0Tmcltf7hptLWj7ffvTc/HsJOZnRGrX2ixYy1rUOfHuD/TN1JpN+R2 X-Gm-Message-State: AOJu0YzxY3qz7F3zhCn2o8Cx2q4KqrLcBCQncf9ceYU6HVHkyaj+v9Rk SbarNYC8lXugh0gA23aVwkacRvSVTVHhLKnRxAN4Vky1wkfso2zN/xMuxNfeQmI= X-Received: by 2002:a05:6214:2aab:b0:690:9629:da5c with SMTP id js11-20020a0562142aab00b006909629da5cmr1022104qvb.24.1711077687834; Thu, 21 Mar 2024 20:21:27 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:16be]) by smtp.gmail.com with ESMTPSA id kc1-20020a056214410100b00695e602d356sm637127qvb.46.2024.03.21.20.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 20:21:27 -0700 (PDT) Date: Thu, 21 Mar 2024 23:21:26 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Andrew Morton , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: zswap: remove nr_zswap_stored atomic Message-ID: <20240322032126.GB237176@cmpxchg.org> References: <20240322001001.1562517-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240322001001.1562517-1-yosryahmed@google.com> On Fri, Mar 22, 2024 at 12:10:01AM +0000, Yosry Ahmed wrote: > nr_stored was introduced by commit b5ba474f3f51 ("zswap: shrink zswap > pool based on memory pressure") as a per zswap_pool counter of the > number of stored pages 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. > > Later on, commit bf9b7df23cb3 ("mm/zswap: global lru and shrinker shared > by all zswap_pools") made the shrinker global (not per zswap_pool), and > replaced nr_stored with nr_zswap_stored (initially introduced as > zswap.nr_stored), which is now a global counter. > > The counter is now awfully close to zswap_stored_pages. The only > difference is that the latter also includes same-filled pages. Also, > 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). > > 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 > Reviewed-by: Nhat Pham Acked-by: Johannes Weiner