Re: [PATCH 2/2] mm/mglru: reset page lru tier bits when activating

From: Wei Xu
Date: Thu Oct 17 2024 - 14:22:09 EST


On Wed, Oct 16, 2024 at 3:55 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, 15 Oct 2024 22:55:23 -0600 Yu Zhao <yuzhao@xxxxxxxxxx> wrote:
>
> > > @@ -257,7 +258,9 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio,
> > > gen = lru_gen_from_seq(seq);
> > > flags = (gen + 1UL) << LRU_GEN_PGOFF;
> > > /* see the comment on MIN_NR_GENS about PG_active */
> > > - set_mask_bits(&folio->flags, LRU_GEN_MASK | BIT(PG_active), flags);
> > > + mask = LRU_GEN_MASK | BIT(PG_active);
> > > + mask |= folio_test_active(folio) ? (LRU_REFS_MASK | LRU_REFS_FLAGS) : 0;
> >
> > We shouldn't clear PG_workingset here because it can affect PSI
> > accounting, if the activation is due to workingset refault.
> >

Good point. I have addressed this in the v2 patch.

> > Also, nit:
> > mask = LRU_GEN_MASK;
> > if (folio_test_active(folio))
> > mask |= LRU_REFS_MASK | BIT(PG_active) | BIT(PG_referenced);
> >
>
> Thanks, I'll drop this version of this patch.
>
> When resending, please include a full description of the userspace-visible
> effects of the original flaw, thanks.

I have sent out a v2 patch, which includes a description as suggested.