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

From: Byungchul Park
Date: Mon Jan 15 2024 - 03:48:46 EST


On Mon, Jan 15, 2024 at 11:08:18AM +0900, Byungchul Park wrote:
> On Thu, Jan 11, 2024 at 03:42:55PM +0000, Matthew Wilcox wrote:
> > 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);

JFYI, in the v4 patch set, I hadn't changed the original code that I
refactored. I just copied and pasted this part from the original code.

> >
> > 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

I didn't apply what you suggested me here to the next version yet
because I was not sure if it'd make the code more readable.

Thanks anyway!

Byungchul

> Cool. Thanks.
>
> Byungchul
>
> > perhaps