From: Ye Liu <ye.liu@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Lorenzo Stoakes <ljs@kernel.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>
Cc: Ye Liu <liuye@kylinos.cn>, Jann Horn <jannh@google.com>,
Pedro Falcato <pfalcato@suse.de>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/4] mm/vmstat: use zone_stat_add_folio/sub_folio for folio_nr_pages operations
Date: Tue, 14 Apr 2026 17:15:19 +0800 [thread overview]
Message-ID: <20260414091527.2970844-3-ye.liu@linux.dev> (raw)
In-Reply-To: <20260414091527.2970844-1-ye.liu@linux.dev>
From: Ye Liu <liuye@kylinos.cn>
Replace zone_stat_mod_folio() calls that pass folio_nr_pages(folio) or
-folio_nr_pages(folio) as the third argument with the more concise
zone_stat_add_folio() and zone_stat_sub_folio() functions respectively.
This makes the code more readable and reduces the number of arguments
passed to these functions.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
mm/mlock.c | 4 ++--
mm/page-writeback.c | 8 ++++----
mm/page_alloc.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/mm/mlock.c b/mm/mlock.c
index 8c227fefa2df..0cafcb2f4e8d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -249,7 +249,7 @@ void mlock_folio(struct folio *folio)
if (!folio_test_set_mlocked(folio)) {
int nr_pages = folio_nr_pages(folio);
- zone_stat_mod_folio(folio, NR_MLOCK, nr_pages);
+ zone_stat_add_folio(folio, NR_MLOCK);
__count_vm_events(UNEVICTABLE_PGMLOCKED, nr_pages);
}
@@ -273,7 +273,7 @@ void mlock_new_folio(struct folio *folio)
fbatch = this_cpu_ptr(&mlock_fbatch.fbatch);
folio_set_mlocked(folio);
- zone_stat_mod_folio(folio, NR_MLOCK, nr_pages);
+ zone_stat_add_folio(folio, NR_MLOCK);
__count_vm_events(UNEVICTABLE_PGMLOCKED, nr_pages);
folio_get(folio);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 87e9ea41313a..6f9b7b081ab7 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2647,7 +2647,7 @@ void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb)
long nr = folio_nr_pages(folio);
lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr);
- zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr);
+ zone_stat_sub_folio(folio, NR_ZONE_WRITE_PENDING);
wb_stat_mod(wb, WB_RECLAIMABLE, -nr);
task_io_account_cancelled_write(nr * PAGE_SIZE);
}
@@ -2916,7 +2916,7 @@ bool folio_clear_dirty_for_io(struct folio *folio)
if (folio_test_clear_dirty(folio)) {
long nr = folio_nr_pages(folio);
lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr);
- zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr);
+ zone_stat_sub_folio(folio, NR_ZONE_WRITE_PENDING);
wb_stat_mod(wb, WB_RECLAIMABLE, -nr);
ret = true;
}
@@ -2980,7 +2980,7 @@ bool __folio_end_writeback(struct folio *folio)
}
lruvec_stat_mod_folio(folio, NR_WRITEBACK, -nr);
- zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr);
+ zone_stat_sub_folio(folio, NR_ZONE_WRITE_PENDING);
node_stat_add_folio(folio, NR_WRITTEN);
return ret;
@@ -3032,7 +3032,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
}
lruvec_stat_mod_folio(folio, NR_WRITEBACK, nr);
- zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, nr);
+ zone_stat_add_folio(folio, NR_ZONE_WRITE_PENDING);
access_ret = arch_make_folio_accessible(folio);
/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 65e205111553..a81ceb4181ea 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1327,7 +1327,7 @@ __always_inline bool __free_pages_prepare(struct page *page,
long nr_pages = folio_nr_pages(folio);
__folio_clear_mlocked(folio);
- zone_stat_mod_folio(folio, NR_MLOCK, -nr_pages);
+ zone_stat_sub_folio(folio, NR_MLOCK);
count_vm_events(UNEVICTABLE_PGCLEARED, nr_pages);
}
--
2.43.0
next prev parent reply other threads:[~2026-04-14 9:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 9:15 [PATCH 0/4] mm/vmstat: simplify folio stat APIs Ye Liu
2026-04-14 9:15 ` [PATCH 1/4] mm/vmstat: use node_stat_add_folio/sub_folio for folio_nr_pages operations Ye Liu
2026-04-14 17:52 ` David Hildenbrand (Arm)
2026-04-15 0:48 ` Ye Liu
2026-04-14 9:15 ` Ye Liu [this message]
2026-04-14 9:15 ` [PATCH 3/4] mm/vmstat: remove unused __node_stat_* wrappers Ye Liu
2026-04-14 14:59 ` Joshua Hahn
2026-04-15 0:50 ` Ye Liu
2026-04-15 2:29 ` Joshua Hahn
2026-04-15 5:51 ` Ye Liu
2026-04-14 9:15 ` [PATCH 4/4] mm/vmstat: remove unused __zone_stat_* wrappers Ye Liu
2026-04-14 13:18 ` [PATCH 0/4] mm/vmstat: simplify folio stat APIs Matthew Wilcox
2026-04-15 0:47 ` Ye Liu
2026-04-15 3:59 ` Matthew Wilcox
2026-04-15 5:54 ` Ye Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260414091527.2970844-3-ye.liu@linux.dev \
--to=ye.liu@linux.dev \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=jannh@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.