[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c429a7d-cc12-49b6-bc71-4b219683743c@lucifer.local>
Date: Fri, 21 Nov 2025 19:22:41 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>,
David Hildenbrand <david@...hat.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>, Vasily Gorbik <gor@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>, Peter Xu <peterx@...hat.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Arnd Bergmann <arnd@...db.de>, Zi Yan <ziy@...dia.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Nico Pache <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
Dev Jain <dev.jain@....com>, Barry Song <baohua@...nel.org>,
Lance Yang <lance.yang@...ux.dev>, Muchun Song <muchun.song@...ux.dev>,
Oscar Salvador <osalvador@...e.de>, Mike Rapoport <rppt@...nel.org>,
Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
Matthew Brost <matthew.brost@...el.com>,
Joshua Hahn <joshua.hahnjy@...il.com>, Rakie Kim <rakie.kim@...com>,
Byungchul Park <byungchul@...com>, Gregory Price <gourry@...rry.net>,
Ying Huang <ying.huang@...ux.alibaba.com>,
Alistair Popple <apopple@...dia.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Yuanchu Xie <yuanchu@...gle.com>, Wei Xu <weixugc@...gle.com>,
Kemeng Shi <shikemeng@...weicloud.com>,
Kairui Song <kasong@...cent.com>, Nhat Pham <nphamcs@...il.com>,
Baoquan He <bhe@...hat.com>, Chris Li <chrisl@...nel.org>,
SeongJae Park <sj@...nel.org>, Matthew Wilcox <willy@...radead.org>,
Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>,
Xu Xin <xu.xin16@....com.cn>,
Chengming Zhou <chengming.zhou@...ux.dev>,
Jann Horn <jannh@...gle.com>, Miaohe Lin <linmiaohe@...wei.com>,
Naoya Horiguchi <nao.horiguchi@...il.com>,
Pedro Falcato <pfalcato@...e.de>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Rik van Riel <riel@...riel.com>, Harry Yoo <harry.yoo@...cle.com>,
Hugh Dickins <hughd@...gle.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, linux-s390@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-arch@...r.kernel.org, damon@...ts.linux.dev
Subject: Re: [PATCH v3 10/16] mm: replace pmd_to_swp_entry() with
softleaf_from_pmd()
On Fri, Nov 21, 2025 at 07:42:50PM +0100, Vlastimil Babka wrote:
> On 11/10/25 23:21, Lorenzo Stoakes wrote:
> > Introduce softleaf_from_pmd() to do the equivalent operation for PMDs that
> > softleaf_from_pte() fulfils, and cascade changes through code base
> > accordingly, introducing helpers as necessary.
>
> Some of that is adding new pte stuff too, so it could have been separate
> patch, but it's not a big deal.
Yeah is always tricky to figure out how to separate things so tried to get
a reasonable balance :)
>
> > We are then able to eliminate pmd_to_swp_entry(), is_pmd_migration_entry(),
> > is_pmd_device_private_entry() and is_pmd_non_present_folio_entry().
> >
> > This further establishes the use of leaf operations throughout the code
> > base and further establishes the foundations for eliminating is_swap_pmd().
> >
> > No functional change intended.
> >
> > Reviewed-by: SeongJae Park <sj@...nel.org>
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
>
> Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
Thanks!
>
> Assuming the below is fixed. Glad I could demonstrate I'm not just rubber
> stamping all this ;P
> (probably missed stuff anyway, as usual)
:)
>
> > --- a/mm/page_table_check.c
> > +++ b/mm/page_table_check.c
> > @@ -8,7 +8,7 @@
> > #include <linux/mm.h>
> > #include <linux/page_table_check.h>
> > #include <linux/swap.h>
> > -#include <linux/swapops.h>
> > +#include <linux/leafops.h>
> >
> > #undef pr_fmt
> > #define pr_fmt(fmt) "page_table_check: " fmt
> > @@ -179,10 +179,10 @@ void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud)
> > EXPORT_SYMBOL(__page_table_check_pud_clear);
> >
> > /* Whether the swap entry cached writable information */
> > -static inline bool swap_cached_writable(swp_entry_t entry)
> > +static inline bool softleaf_cached_writable(softleaf_t entry)
> > {
> > - return is_writable_device_private_entry(entry) ||
> > - is_writable_migration_entry(entry);
> > + return softleaf_is_device_private(entry) ||
>
> Shouldn't there be softleaf_is_device_private_write(entry) ?
Ah yeah you're right. I don't think this probably matters here in practice
(as in, it'd probably be a bug if pmd_swp_uffd_wp() was true but also read
device private entry).
But it's incorrect obviously and a mistake, will send fix-patch! Thanks! :)
>
> > + softleaf_is_migration_write(entry);
> > }
> >
> > static void page_table_check_pte_flags(pte_t pte)
> > @@ -190,9 +190,9 @@ static void page_table_check_pte_flags(pte_t pte)
> > if (pte_present(pte)) {
> > WARN_ON_ONCE(pte_uffd_wp(pte) && pte_write(pte));
> > } else if (pte_swp_uffd_wp(pte)) {
> > - const swp_entry_t entry = pte_to_swp_entry(pte);
> > + const softleaf_t entry = softleaf_from_pte(pte);
> >
> > - WARN_ON_ONCE(swap_cached_writable(entry));
> > + WARN_ON_ONCE(softleaf_cached_writable(entry));
> > }
> > }
> >
> > @@ -219,9 +219,9 @@ static inline void page_table_check_pmd_flags(pmd_t pmd)
> > if (pmd_uffd_wp(pmd))
> > WARN_ON_ONCE(pmd_write(pmd));
> > } else if (pmd_swp_uffd_wp(pmd)) {
> > - swp_entry_t entry = pmd_to_swp_entry(pmd);
> > + const softleaf_t entry = softleaf_from_pmd(pmd);
> >
> > - WARN_ON_ONCE(swap_cached_writable(entry));
> > + WARN_ON_ONCE(softleaf_cached_writable(entry));
> > }
> > }
> >
Powered by blists - more mailing lists