From patchwork Tue Mar 12 15:34:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13590150 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 72153C54E58 for ; Tue, 12 Mar 2024 15:39:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08DCE8D0058; Tue, 12 Mar 2024 11:39:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0A968D0057; Tue, 12 Mar 2024 11:39:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC04B8D0058; Tue, 12 Mar 2024 11:39:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B0B958D0057 for ; Tue, 12 Mar 2024 11:39:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 90E66120637 for ; Tue, 12 Mar 2024 15:39:11 +0000 (UTC) X-FDA: 81888795702.11.4926499 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf03.hostedemail.com (Postfix) with ESMTP id A090A2001C for ; Tue, 12 Mar 2024 15:39:09 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=wqHUf3zR; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf03.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.42 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710257949; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=h2DM6mlGPAKI7DFYoFnNzPHH8HCk3l+GsFGDVmzzhKA=; b=xBthlPLWOAPVmU1xf6V9o+tpsZmIEoCwPaS6OTSnvm24yka2Tf1gvHVUP71oNpdJoW0M9D ILE4CVG90pKqDGZYZm9ouXYXik0O6C5zQfbl060zo8GgdxNcHIeBmI2AC0pddIqj9t7lq3 bfKeC/UJ3EcNRXtHJn9/IV4yacpa5HU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=wqHUf3zR; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf03.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.42 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710257949; a=rsa-sha256; cv=none; b=rS913ezlI0kc9JDZd6CSiOAy4ZqnhZK7/mLv4HGqBPErlIq4VImRyv3IKUyD2x1i6MxR9P E5LsfsxYeNUgNivpqLqhfaK4KZzlEIF73b8Pb3Aaw0Q3Dl4y7ST839k6ZGjXgRfx0Hj2n0 c/0QlRex5JaF2pXMRCekjgiImG+zsFI= Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-690b5063cdfso31226336d6.0 for ; Tue, 12 Mar 2024 08:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1710257949; x=1710862749; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h2DM6mlGPAKI7DFYoFnNzPHH8HCk3l+GsFGDVmzzhKA=; b=wqHUf3zRUxtr1VfMoscOQeaiHBTHAkuB9AnhIjPJ/MPZ09HQeenqk+da+5j86wx+aU 1eNrb5n5b8q2txHH+Cfak2okDC5spodog7yqGUTlkhxemF1C91BfigmKEamLgEgBF4K9 XW/pfMXc4SpJaUt6iFCB3A1N+A11Ehqzu8DM2SdpAyeY+Obi+eTf1vTtTTRW/KLEI9M8 gmLaAkW9hVr2bihuUfKc8ejCrj0AGSDhN2KpiIO14eKZa/RdI7nmbl7+5wxToKzJ+15Y aoP59BeYhg2BiDLtLrDTwtsee+sVJYLjdIMDz3AFNDkkziDROBpagGhDSJ5KFgCAo7JD iTPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710257949; x=1710862749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h2DM6mlGPAKI7DFYoFnNzPHH8HCk3l+GsFGDVmzzhKA=; b=jbsdepr49R8fUfzNNRcqqQqh4uMT0lOijtYtY9iJGaRqWYwbbVc16DMPfvPkAdyJYD z+ge3kuUG+SxLoR5x0Nqq/sbP1BIsXjP4T/gzXhRjeeubFXs0xZX46GB3/xC/1mlJfUC EhjBrq0SX6cviYpHZ8JCgt9/0Gb78bbMTeMAGZWzdTXulQc8NZ0vqIGV2/AznqSdL/WO LCSfiHDDs9Dct6E9CUOra8fssML6XM9qMZVkpXOBnCEkOvXbnGMuwr637cyHf5jW/Llk LauMOHc1qtoPPDCgb+DUtyzY2+h1POmlS55DCI6DOmcGFxqdAXZY2dCikEOvfnmrsQBP SEAg== X-Forwarded-Encrypted: i=1; AJvYcCXetjnmTfLH5/c7ncUa2zWUSizJFnbbJ1dkUqFcaMFNKeATZGZemo/YgVZXXF8SqlYoTBaappuDMXx78eoRQCaalyM= X-Gm-Message-State: AOJu0Yyr5x/5eYN3vE1PtEMOe8hHVtqKxUtOo7/fNN6ylco8H8yZj+QU V6sstiC+D5/5PqBAdbKPobwKx+Ni5PnXGDb4AnApVyUMoBgCm0ybxldz/em9ABc= X-Google-Smtp-Source: AGHT+IFvfFC0MRbzB9GCLWGfG7mxScyDWBb8PTINTgkiZ/tKO5tky2aU1Y2xSEq5vl5hHo4IheWAyQ== X-Received: by 2002:a0c:aadd:0:b0:690:bb9c:f0d6 with SMTP id g29-20020a0caadd000000b00690bb9cf0d6mr9207069qvb.18.1710257948669; Tue, 12 Mar 2024 08:39:08 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id ek19-20020ad45993000000b006907e34d029sm3783535qvb.2.2024.03.12.08.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 08:39:08 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Yosry Ahmed , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH 2/2] mm: zpool: return pool size in pages Date: Tue, 12 Mar 2024 11:34:12 -0400 Message-ID: <20240312153901.3441-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240312153901.3441-1-hannes@cmpxchg.org> References: <20240312153901.3441-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A090A2001C X-Stat-Signature: p3r6qgwta1gceomn7dfnexqkbkt6j846 X-HE-Tag: 1710257949-522284 X-HE-Meta: U2FsdGVkX1+5/Su8yTsPXfRxolKxqbg//JI/WiKtvBH3MVqws8gXqaRYoNKKynvFaaFLWEbGPMGhUzBMZusIZK5IwcGc1axime487LnMVPnqKqeXvssu97xz548wRIv9xK1g22WLhUU3/5UUbCAsGL1jRAhLTlayvr/Gf5wMXSpKn7iJDI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Y7smd+NUmTCQEmqfUGk8O2NFZ1YTtq5E0c3+BNBPtkMdhyAbMZ//L3Ira89ae05BDMPvm5aGu28K7OAswj98b08qrNwc4k4Jr7XOIH7sDNwl93+a51A1x/DNjMMJyr2outiS+5HOxxZtC5sXlEXMbQcgBo7Vsedraz3tzyccw+/1sMX0+jeVpkufRiwiMMnl1GUYSMVnjDKiN+JEWegXpWiNiz4= 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: List-Subscribe: List-Unsubscribe: All zswap backends track their pool sizes in pages. Currently they multiply by PAGE_SIZE for zswap, only for zswap to divide again in order to do limit math. Report pages directly. Signed-off-by: Johannes Weiner Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou Reviewed-by: Nhat Pham --- include/linux/zpool.h | 4 ++-- mm/z3fold.c | 10 +++++----- mm/zbud.c | 10 +++++----- mm/zpool.c | 10 +++++----- mm/zsmalloc.c | 6 +++--- mm/zswap.c | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/linux/zpool.h b/include/linux/zpool.h index 3296438eec06..a67d62b79698 100644 --- a/include/linux/zpool.h +++ b/include/linux/zpool.h @@ -53,7 +53,7 @@ void *zpool_map_handle(struct zpool *pool, unsigned long handle, void zpool_unmap_handle(struct zpool *pool, unsigned long handle); -u64 zpool_get_total_size(struct zpool *pool); +u64 zpool_get_total_pages(struct zpool *pool); /** @@ -91,7 +91,7 @@ struct zpool_driver { enum zpool_mapmode mm); void (*unmap)(void *pool, unsigned long handle); - u64 (*total_size)(void *pool); + u64 (*total_pages)(void *pool); }; void zpool_register_driver(struct zpool_driver *driver); diff --git a/mm/z3fold.c b/mm/z3fold.c index 7ab05621052d..2ebfed32871b 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -1237,12 +1237,12 @@ static void z3fold_unmap(struct z3fold_pool *pool, unsigned long handle) } /** - * z3fold_get_pool_size() - gets the z3fold pool size in pages + * z3fold_get_pool_pages() - gets the z3fold pool size in pages * @pool: pool whose size is being queried * * Returns: size in pages of the given pool. */ -static u64 z3fold_get_pool_size(struct z3fold_pool *pool) +static u64 z3fold_get_pool_pages(struct z3fold_pool *pool) { return atomic64_read(&pool->pages_nr); } @@ -1402,9 +1402,9 @@ static void z3fold_zpool_unmap(void *pool, unsigned long handle) z3fold_unmap(pool, handle); } -static u64 z3fold_zpool_total_size(void *pool) +static u64 z3fold_zpool_total_pages(void *pool) { - return z3fold_get_pool_size(pool) * PAGE_SIZE; + return z3fold_get_pool_pages(pool); } static struct zpool_driver z3fold_zpool_driver = { @@ -1417,7 +1417,7 @@ static struct zpool_driver z3fold_zpool_driver = { .free = z3fold_zpool_free, .map = z3fold_zpool_map, .unmap = z3fold_zpool_unmap, - .total_size = z3fold_zpool_total_size, + .total_pages = z3fold_zpool_total_pages, }; MODULE_ALIAS("zpool-z3fold"); diff --git a/mm/zbud.c b/mm/zbud.c index 2190cc1f37b3..e9836fff9438 100644 --- a/mm/zbud.c +++ b/mm/zbud.c @@ -365,13 +365,13 @@ static void zbud_unmap(struct zbud_pool *pool, unsigned long handle) } /** - * zbud_get_pool_size() - gets the zbud pool size in pages + * zbud_get_pool_pages() - gets the zbud pool size in pages * @pool: pool whose size is being queried * * Returns: size in pages of the given pool. The pool lock need not be * taken to access pages_nr. */ -static u64 zbud_get_pool_size(struct zbud_pool *pool) +static u64 zbud_get_pool_pages(struct zbud_pool *pool) { return pool->pages_nr; } @@ -410,9 +410,9 @@ static void zbud_zpool_unmap(void *pool, unsigned long handle) zbud_unmap(pool, handle); } -static u64 zbud_zpool_total_size(void *pool) +static u64 zbud_zpool_total_pages(void *pool) { - return zbud_get_pool_size(pool) * PAGE_SIZE; + return zbud_get_pool_pages(pool); } static struct zpool_driver zbud_zpool_driver = { @@ -425,7 +425,7 @@ static struct zpool_driver zbud_zpool_driver = { .free = zbud_zpool_free, .map = zbud_zpool_map, .unmap = zbud_zpool_unmap, - .total_size = zbud_zpool_total_size, + .total_pages = zbud_zpool_total_pages, }; MODULE_ALIAS("zpool-zbud"); diff --git a/mm/zpool.c b/mm/zpool.c index 846410479c2f..b9fda1fa857d 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -321,16 +321,16 @@ void zpool_unmap_handle(struct zpool *zpool, unsigned long handle) } /** - * zpool_get_total_size() - The total size of the pool + * zpool_get_total_pages() - The total size of the pool * @zpool: The zpool to check * - * This returns the total size in bytes of the pool. + * This returns the total size in pages of the pool. * - * Returns: Total size of the zpool in bytes. + * Returns: Total size of the zpool in pages. */ -u64 zpool_get_total_size(struct zpool *zpool) +u64 zpool_get_total_pages(struct zpool *zpool) { - return zpool->driver->total_size(zpool->pool); + return zpool->driver->total_pages(zpool->pool); } /** diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7d7cb3eaabe0..b42d3545ca85 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -399,9 +399,9 @@ static void zs_zpool_unmap(void *pool, unsigned long handle) zs_unmap_object(pool, handle); } -static u64 zs_zpool_total_size(void *pool) +static u64 zs_zpool_total_pages(void *pool) { - return zs_get_total_pages(pool) << PAGE_SHIFT; + return zs_get_total_pages(pool); } static struct zpool_driver zs_zpool_driver = { @@ -414,7 +414,7 @@ static struct zpool_driver zs_zpool_driver = { .free = zs_zpool_free, .map = zs_zpool_map, .unmap = zs_zpool_unmap, - .total_size = zs_zpool_total_size, + .total_pages = zs_zpool_total_pages, }; MODULE_ALIAS("zpool-zsmalloc"); diff --git a/mm/zswap.c b/mm/zswap.c index 1a5cc7298306..9fdf4c76d5ea 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -512,18 +512,18 @@ static unsigned long zswap_accept_thr_pages(void) unsigned long zswap_total_pages(void) { struct zswap_pool *pool; - u64 total = 0; + unsigned long total = 0; rcu_read_lock(); list_for_each_entry_rcu(pool, &zswap_pools, list) { int i; for (i = 0; i < ZSWAP_NR_ZPOOLS; i++) - total += zpool_get_total_size(pool->zpools[i]); + total += zpool_get_total_pages(pool->zpools[i]); } rcu_read_unlock(); - return total >> PAGE_SHIFT; + return total; } /*********************************