From: Gregory Price <gourry.memverge@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, willy@infradead.org, david@redhat.com,
vbabka@suse.cz, naoya.horiguchi@linux.dev,
linux-kernel@vger.kernel.org,
Gregory Price <gregory.price@memverge.com>
Subject: [PATCH v2] kpageflags: respect folio head-page flag placement
Date: Mon, 30 Oct 2023 14:00:05 -0400 [thread overview]
Message-ID: <20231030180005.2046-1-gregory.price@memverge.com> (raw)
kpageflags reads page-flags directly from the page, even when the
respective flag is only updated on the headpage of a folio.
Update bitchecks to use PAGEFLAG() interfaces to check folio for the
referenced, dirty, lru, active, and unevictable bits.
Signed-off-by: Gregory Price <gregory.price@memverge.com>
---
fs/proc/page.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 195b077c0fac..1dceecb8018a 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -111,6 +111,7 @@ u64 stable_page_flags(struct page *page)
{
u64 k;
u64 u;
+ struct folio *folio;
/*
* pseudo flag: KPF_NOPAGE
@@ -119,6 +120,8 @@ u64 stable_page_flags(struct page *page)
if (!page)
return 1 << KPF_NOPAGE;
+ folio = page_folio(page);
+
k = page->flags;
u = 0;
@@ -188,20 +191,31 @@ u64 stable_page_flags(struct page *page)
u |= 1 << KPF_SLAB;
u |= kpf_copy_bit(k, KPF_ERROR, PG_error);
- u |= kpf_copy_bit(k, KPF_DIRTY, PG_dirty);
+
+ if (folio_test_dirty(folio))
+ u |= 1 << KPF_DIRTY;
+
u |= kpf_copy_bit(k, KPF_UPTODATE, PG_uptodate);
u |= kpf_copy_bit(k, KPF_WRITEBACK, PG_writeback);
- u |= kpf_copy_bit(k, KPF_LRU, PG_lru);
- u |= kpf_copy_bit(k, KPF_REFERENCED, PG_referenced);
- u |= kpf_copy_bit(k, KPF_ACTIVE, PG_active);
+ if (folio_test_lru(folio))
+ u |= 1 << KPF_LRU;
+
+ if (folio_test_referenced(folio))
+ u |= 1 << KPF_REFERENCED;
+
+ if (folio_test_active(folio))
+ u |= 1 << KPF_ACTIVE;
+
u |= kpf_copy_bit(k, KPF_RECLAIM, PG_reclaim);
if (PageSwapCache(page))
u |= 1 << KPF_SWAPCACHE;
u |= kpf_copy_bit(k, KPF_SWAPBACKED, PG_swapbacked);
- u |= kpf_copy_bit(k, KPF_UNEVICTABLE, PG_unevictable);
+ if (folio_test_unevictable(folio))
+ u |= 1 << KPF_UNEVICTABLE;
+
u |= kpf_copy_bit(k, KPF_MLOCKED, PG_mlocked);
#ifdef CONFIG_MEMORY_FAILURE
--
2.39.1
next reply other threads:[~2023-10-30 18:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 18:00 Gregory Price [this message]
2023-10-30 23:22 ` Matthew Wilcox
2023-10-30 23:41 ` Gregory Price
2023-10-31 9:13 ` Matthew Wilcox
2023-10-31 4:34 ` Gregory Price
2023-11-07 1:03 ` Kefeng Wang
2023-11-07 15:34 ` Gregory Price
2023-11-08 2:01 ` Kefeng Wang
2023-11-08 23:33 ` Gregory Price
2023-11-09 9:05 ` Kefeng Wang
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=20231030180005.2046-1-gregory.price@memverge.com \
--to=gourry.memverge@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=gregory.price@memverge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@linux.dev \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox