Re: [PATCH v3 3/6] mm/migrate: copy all referenced state via folio_migrate_lru_refs
From: Barry Song
Date: Sat Aug 29 2026 - 05:57:25 EST
On Wed, Aug 26, 2026 at 1:53 AM Kairui Song via B4 Relay
<devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
>
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> folio_migrate_flags() copies PG_referenced separately from the MGLRU
> refs counter, which folio_migrate_refs() transfers. Yet under MGLRU,
> PG_referenced and the refs counter bits together describe the
> referenced status of a folio.
>
> Consolidate the two: rename folio_migrate_refs() to
> folio_migrate_lru_refs() and let it copy the complete referenced
> status, i.e., the MGLRU refs count including PG_referenced, or just
> PG_referenced for the active/inactive LRU. Drop the open-coded
> PG_referenced copy so the referenced status is transferred in one
> place. No behavior change is intended: under the active/inactive LRU
> the extra bits are unused, so operating on them is a noop.
>
> Transfer the reference state first, before the destination folio is
> marked uptodate, so a concurrent lockless reader cannot have its
> reference update overwritten by the copy.
>
> Reviewed-by: Baoquan He <baoquan.he@xxxxxxxxx>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
Yep. We now have some unified code for both MGLRU and
active/inactive LRU in `folio_migrate_flags()`.
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>