Re: [PATCH 3/7] mm/migrate: copy the referenced state via folio_migrate_refs()

Kairui Song <[email protected]>
Newsgroups org.kvack.linux-mm,org.kernel.vger.cgroups,org.kernel.vger.linux-kernel
Message-ID <aowmf2OcDnayYaU2@KASONG-MC4>
On Thu, Aug 20, 2026 at 08:20:34PM +0800, David Hildenbrand (Arm) wrote:
> On 8/18/26 07:38, Kairui Song via B4 Relay wrote:
> > From: Kairui Song <[email protected]>
> > 
> > folio_migrate_flags() copies PG_referenced separately, while
> > folio_migrate_refs() copies the rest of the reference state. Make
> > folio_migrate_refs() copy the complete state, i.e., PG_referenced plus
> > the MGLRU refs counter, in both LRU implementations, and drop the
> > open-coded copy so the reference state is transferred in one place.
> > 
> > Signed-off-by: Kairui Song <[email protected]>
> > ---
> >  include/linux/mm_inline.h | 16 +++++++++++++---
> >  mm/migrate.c              |  4 ++--
> >  2 files changed, 15 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> > index 93bf3fa221f8..df62daaa2ee7 100644
> > --- a/include/linux/mm_inline.h
> > +++ b/include/linux/mm_inline.h
> > @@ -366,11 +366,19 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio,
> >  	return true;
> >  }
> >  
> > +/**
> > + * folio_migrate_refs - copy the reference state to a new folio
> > + * @new: the destination folio
> > + * @old: the source folio
> > + *
> 
> Man, that function has a confusing name (refs vs. ref_count). :)
> 
> "ref_state" would be clearer (just what the description says).
> 
> Or better, "folio_migrate_lru_refs", because that's literally the name of the
> function you use: folio_set_lru_refs.
> 
> Can we have a cleanup patch to name that consistently?

Sure, I think I can just rename it here as the code gets consolidated
and kdoc being added
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.