From: Muchun Song <muchun.song@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: Muchun Song <muchun.song@linux.dev>,
Muchun Song <songmuchun@bytedance.com>,
Oscar Salvador <osalvador@suse.de>,
David Hildenbrand <david@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Michal Hocko <mhocko@suse.com>, Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Lance Yang <lance.yang@linux.dev>, Qi Zheng <qi.zheng@linux.dev>,
linux-mm@kvack.org, Huacai Chen <chenhuacai@kernel.org>
Subject: Re: [PATCH v2 2/3] mm/vmemmap-optimization: track optimization state in shared vmemmap pages
Date: Sun, 6 Dec 2026 17:17:09 +0800 [thread overview]
Message-ID: <15E72DA7-F9BB-4A23-BB73-C8E4D799AB43@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-252287@kernel.org>
> On Dec 6, 2026, at 16:35, sashiko-bot@kernel.org wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] mm: PAGEFLAG(VmemmapOptimized) exposes broken
> folio_*_vmemmap_optimized()
> --
>
> commit c7681d6be3397bd678ceb2f8b16aa0dc4585ed33
> Author: Muchun Song <muchun.song@linux.dev>
>
> mm/vmemmap-optimization: track optimization state in shared vmemmap pages
>
> This commit records vmemmap optimization state in PG_owner_priv_1 on the
> first struct page of each shared tail vmemmap backing page and adds
> folio_vmemmap_optimized() to query it.
>
>> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
>> index 2b8582838a4e2..377329a85151f 100644
>> --- a/include/linux/page-flags.h
>> +++ b/include/linux/page-flags.h
>
> [ ... ]
>
>> @@ -692,6 +695,9 @@ PAGEFLAG(VmemmapSelfHosted, vmemmap_self_hosted, PF_ANY)
>> PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted)
>> #endif
>>
>> +/* Only test this flag through folio_vmemmap_optimized(). */
>> +PAGEFLAG(VmemmapOptimized, vmemmap_optimized, PF_ANY)
>
> [Severity: Low]
> Should PAGEFLAG() be avoided here so folio_test_vmemmap_optimized(),
> folio_set_vmemmap_optimized(), and folio_clear_vmemmap_optimized() are not
> exposed?
I had considered this as well. Initially, I looked for a macro that could define
only the page helpers, but all the available macros also generate folio helpers,
so I ended up using PAGEFLAG(). Nevertheless, I agree that PAGEFLAG() should be
avoided here to prevent the automatically generated folio_* helpers from being
misused in the future. I will replace it with page-only accessors in the next
revision.
Thanks.
>
> PAGEFLAG() with PF_ANY generates those folio_* helpers targeting page index 0
> (the head page), where PG_vmemmap_optimized aliases PG_owner_priv_1 and is
> never set for vmemmap optimization.
>
> Any caller using folio_test_vmemmap_optimized() will silently get wrong
> results (false on optimized folios and true on swapcache or checked folios),
> and the set/clear helpers will corrupt PG_owner_priv_1 on the head page.
>
> Defining page-only inline helpers (like PageAnonExclusive()) or keeping the
> bit manipulation internal to the vmemmap-optimization helpers would avoid
> exposing these broken folio_* helpers.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261206081324.8274-1-songmuchun@bytedance.com?part=2
next prev parent reply other threads:[~2026-12-06 9:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 8:13 [PATCH v2 0/3] mm: Track vmemmap optimization state in shared backing pages Muchun Song
2026-12-06 8:13 ` [PATCH v2 1/3] mm: move MAX_FOLIO_VMEMMAP_ALIGN to mmzone.h Muchun Song
2026-12-06 8:35 ` sashiko-bot
2026-12-06 8:40 ` Muchun Song
2026-12-06 8:13 ` [PATCH v2 2/3] mm/vmemmap-optimization: track optimization state in shared vmemmap pages Muchun Song
2026-12-06 8:35 ` sashiko-bot
2026-12-06 9:17 ` Muchun Song [this message]
2026-12-06 17:30 ` Andrew Morton
2026-12-06 8:13 ` [PATCH v2 3/3] mm/hugetlb_vmemmap: remove HPG_vmemmap_optimized Muchun Song
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=15E72DA7-F9BB-4A23-BB73-C8E4D799AB43@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=david@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=songmuchun@bytedance.com \
--cc=vbabka@kernel.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