Re: [v5 4/7] mm: Separate move/undo doing on folio list from migrate_pages_batch()

From: Matthew Wilcox
Date: Thu Jan 11 2024 - 10:43:20 EST


On Thu, Jan 11, 2024 at 03:07:54PM +0900, Byungchul Park wrote:
> +static void migrate_folios_move(struct list_head *src_folios,
> + struct list_head *dst_folios,
> + free_folio_t put_new_folio, unsigned long private,
> + enum migrate_mode mode, int reason,
> + struct list_head *ret_folios,
> + struct migrate_pages_stats *stats,
> + int *retry, int *thp_retry, int *nr_failed,
> + int *nr_retry_pages)
> +{
> + struct folio *folio, *folio2, *dst, *dst2;
> + bool is_thp;
> + int nr_pages;
> + int rc;
> +
> + dst = list_first_entry(dst_folios, struct folio, lru);
> + dst2 = list_next_entry(dst, lru);
> + list_for_each_entry_safe(folio, folio2, src_folios, lru) {
> + is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio);

You don't need to call folio_test_large() first. folio_order() includes
a call to test_large() so it can return 0.

> + nr_pages = folio_nr_pages(folio);

.. or since you're calculating this anyway,

is_thp = nr_pages >= HPAGE_PMD_NR
perhaps