Re: [v1 resend 02/12] mm/migrate_device: flags for selecting device private THP pages

From: Matthew Brost
Date: Sat Jul 19 2025 - 16:05:34 EST


On Tue, Jul 08, 2025 at 05:31:49PM +1000, Balbir Singh wrote:
> On 7/7/25 15:31, Alistair Popple wrote:
> > On Fri, Jul 04, 2025 at 09:35:01AM +1000, Balbir Singh wrote:
> >> Add flags to mark zone device migration pages.
> >>
> >> MIGRATE_VMA_SELECT_COMPOUND will be used to select THP pages during
> >> migrate_vma_setup() and MIGRATE_PFN_COMPOUND will make migrating
> >> device pages as compound pages during device pfn migration.
> >>
> >> Cc: Karol Herbst <kherbst@xxxxxxxxxx>
> >> Cc: Lyude Paul <lyude@xxxxxxxxxx>
> >> Cc: Danilo Krummrich <dakr@xxxxxxxxxx>
> >> Cc: David Airlie <airlied@xxxxxxxxx>
> >> Cc: Simona Vetter <simona@xxxxxxxx>
> >> Cc: "Jérôme Glisse" <jglisse@xxxxxxxxxx>
> >> Cc: Shuah Khan <shuah@xxxxxxxxxx>
> >> Cc: David Hildenbrand <david@xxxxxxxxxx>
> >> Cc: Barry Song <baohua@xxxxxxxxxx>
> >> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> >> Cc: Ryan Roberts <ryan.roberts@xxxxxxx>
> >> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> >> Cc: Peter Xu <peterx@xxxxxxxxxx>
> >> Cc: Zi Yan <ziy@xxxxxxxxxx>
> >> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
> >> Cc: Jane Chu <jane.chu@xxxxxxxxxx>
> >> Cc: Alistair Popple <apopple@xxxxxxxxxx>
> >> Cc: Donet Tom <donettom@xxxxxxxxxxxxx>
> >>
> >> Signed-off-by: Balbir Singh <balbirs@xxxxxxxxxx>
> >> ---
> >> include/linux/migrate.h | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> >> index aaa2114498d6..1661e2d5479a 100644
> >> --- a/include/linux/migrate.h
> >> +++ b/include/linux/migrate.h
> >> @@ -167,6 +167,7 @@ static inline int migrate_misplaced_folio(struct folio *folio, int node)
> >> #define MIGRATE_PFN_VALID (1UL << 0)
> >> #define MIGRATE_PFN_MIGRATE (1UL << 1)
> >> #define MIGRATE_PFN_WRITE (1UL << 3)
> >> +#define MIGRATE_PFN_COMPOUND (1UL << 4)
> >
> > Why is this necessary? Couldn't migrate_vma just use folio_order() to figure out
> > if it's a compound page or not?
> >
>
> I can definitely explore that angle. As we move towards mTHP, we'll need additional bits for the various order sizes as well.
>

I agree you probably could get away without having an explict mpfn flag
for compound pages and rely on the folio order everywhere.

Matt

> Balbir Singh