From: David Hildenbrand <david@redhat.com>
To: Harry Yoo <harry.yoo@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
David Rientjes <rientjes@google.com>,
Christoph Lameter <cl@gentwo.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH v3 mm-new] fs/proc/page: avoid anon folio checks on typed pages except hugetlb
Date: Tue, 15 Jul 2025 15:36:13 +0200 [thread overview]
Message-ID: <f80902b0-97ba-4dde-938b-3acd95a5e378@redhat.com> (raw)
In-Reply-To: <aHZX9vxrGFqNffDV@hyeyoo>
On 15.07.25 15:30, Harry Yoo wrote:
> On Tue, Jul 15, 2025 at 02:31:45PM +0200, David Hildenbrand wrote:
>> On 15.07.25 14:07, Harry Yoo wrote:
>>> folio_test_anon() and folio_test_ksm() may return false positives when
>>> invoked on typed pages (except hugetlb folios), because lower bits of
>>> folio->mapping may be set even when they do not indicate
>>> FOLIO_MAPPING_* flags.
>>>
>>> This leads to tools/mm/page-types reporting pages with
>>> KPF_SLAB, KPF_ANON and KPF_KSM (with flags, page-counts, MB omitted):
>>> $ sudo ./page-types | grep slab
>>> _______S___________________________________ slab
>>> _______S____a________x_____________________ slab,anonymous,ksm
>>>
>>> Currently, and going forward (The New York interpretation),
>>> typed pages except hugetlb do not have FOLIO_MAPPING_* flags.
>>> In the future, they won't even cast to folios.
>>>
>>> For now, avoid checking FOLIO_MAPPING_* flags on pages if they are
>>> typed pages that are not hugetlb folios.
>>>
>>> Update the comment in FOLIO_MAPPING_* flags accordingly.
>>>
>>> Fixes: 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to allow larger rcu_head")
>>> Suggested-by: Vlastimil Babka <vbabka@suse.cz>
>>> Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
>>> ---
>>>
>>> v2->v3: Did not introduce folio_has_mapcount() per David's suggestion
>>> v2: https://lore.kernel.org/linux-mm/20250707120740.4413-1-harry.yoo@oracle.com
>>>
>>> fs/proc/page.c | 19 +++++++++++--------
>>> include/linux/page-flags.h | 15 +++++++++------
>>> 2 files changed, 20 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/fs/proc/page.c b/fs/proc/page.c
>>> index 0cdc78c0d23f..07582dbdef45 100644
>>> --- a/fs/proc/page.c
>>> +++ b/fs/proc/page.c
>>> @@ -148,18 +148,21 @@ u64 stable_page_flags(const struct page *page)
>>> folio = page_folio(page);
>>> k = folio->flags;
>>> - mapping = (unsigned long)folio->mapping;
>>> - is_anon = mapping & FOLIO_MAPPING_ANON;
>>> /*
>>> * pseudo flags for the well known (anonymous) memory mapped pages
>>> */
>>> - if (page_mapped(page))
>>> - u |= 1 << KPF_MMAP;
>>> - if (is_anon) {
>>> - u |= 1 << KPF_ANON;
>>> - if (mapping & FOLIO_MAPPING_KSM)
>>> - u |= 1 << KPF_KSM;
>>> + if (!page_has_type(&folio->page) || folio_test_hugetlb(folio)) {
>>> + mapping = (unsigned long)folio->mapping;
>>> + is_anon = mapping & FOLIO_MAPPING_ANON;
>>> +
>>> + if (page_mapped(page))
>>> + u |= 1 << KPF_MMAP;
>>
>> Note: Luiz switches to folio_mapped() in his patch that is in mm-new.
>
> Right, but in mm-new Luiz's patch already depends on my v2 patch,
> which still leaves me confused about what I should do... :)
Haha, right. Yes, just send it as a replacement to you current patch
then. The conflict should be easy to resolve.
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2025-07-15 13:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 12:07 Harry Yoo
2025-07-15 12:31 ` David Hildenbrand
2025-07-15 13:30 ` Harry Yoo
2025-07-15 13:36 ` David Hildenbrand [this message]
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=f80902b0-97ba-4dde-938b-3acd95a5e378@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=harry.yoo@oracle.com \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@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