Re: [PATCH v14 061/138] mm/migrate: Add folio_migrate_flags()

From: Vlastimil Babka
Date: Wed Aug 11 2021 - 11:16:38 EST


On 7/15/21 5:35 AM, Matthew Wilcox (Oracle) wrote:
> Turn migrate_page_states() into a wrapper around folio_migrate_flags().
> Also convert two functions only called from folio_migrate_flags() to
> be folio-based. ksm_migrate_page() becomes folio_migrate_ksm() and
> copy_page_owner() becomes folio_copy_owner(). folio_migrate_flags()
> alone shrinks by two thirds -- 1967 bytes down to 642 bytes.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>

After fixing the bug below,
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>


> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h

...

> @@ -36,10 +36,10 @@ static inline void split_page_owner(struct page *page, unsigned int nr)
> if (static_branch_unlikely(&page_owner_inited))
> __split_page_owner(page, nr);
> }
> -static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
> +static inline void folio_copy_owner(struct folio *newfolio, struct folio *old)

This changed order so that new is first.

...

> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -538,82 +538,80 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
> }
>
> /*
> - * Copy the page to its new location
> + * Copy the flags and some other ancillary information
> */
> -void migrate_page_states(struct page *newpage, struct page *page)
> +void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
> {

...

> - copy_page_owner(page, newpage);
> + folio_copy_owner(folio, newfolio);

This passes old first.

>
> - if (!PageHuge(page))
> + if (!folio_test_hugetlb(folio))
> mem_cgroup_migrate(folio, newfolio);
> }
> -EXPORT_SYMBOL(migrate_page_states);
> +EXPORT_SYMBOL(folio_migrate_flags);