Re: [PATCH RFC 07/15] mm/mglru: move refault workingset activation into lru_gen_refault
Baoquan He <[email protected]>
| Newsgroups | org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <aoPPi1Y0a8umZuEX@MiWiFi-R3L-srv> |
On 08/04/26 at 03:47am, Kairui Song via B4 Relay wrote: > From: Kairui Song <[email protected]> > > Move the folio_set_active() for refaulted workingset folios from > folio_add_lru() into lru_gen_refault(), where the refault detection > already happens. No functional change: the ordering and logic are > preserved in all cases, and no other paths reach the removed branch. It doesn't explain or even mention why it doesn't matter to discarding these two checkings. !folio_test_unevictable(folio) !(current->flags & PF_MEMALLOC) > > This is a preparatory cleanup for MGLRU-FG. > --- > mm/folio.c | 6 +----- > mm/workingset.c | 9 ++++----- > 2 files changed, 5 insertions(+), 10 deletions(-) > > diff --git a/mm/folio.c b/mm/folio.c > index f90b7f86dbe3..fab00cb02970 100644 > --- a/mm/folio.c > +++ b/mm/folio.c > @@ -474,17 +474,13 @@ void folio_add_lru(struct folio *folio) > VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); > > /* > - * For refaulted workingset folios, set PG_active so they > - * can be added to active generations. > * For prefaulted file folios, folio_mark_accessed() sets > * PG_referenced so lru_gen_folio_seq() places them into > * the second oldest generation. > */ > if (lru_gen_enabled() && !folio_test_unevictable(folio) && > lru_gen_in_fault() && !(current->flags & PF_MEMALLOC)) { > - if (folio_test_workingset(folio)) > - folio_set_active(folio); > - else if (!folio_test_referenced(folio)) > + if (!folio_test_referenced(folio) && !folio_test_workingset(folio)) > folio_mark_accessed(folio); > } > > diff --git a/mm/workingset.c b/mm/workingset.c > index 7ac2b88c80ae..5438e9390011 100644 > --- a/mm/workingset.c > +++ b/mm/workingset.c > @@ -320,12 +320,11 @@ static void lru_gen_refault(struct folio *folio, void *shadow) > atomic_long_add(delta, &lrugen->refaulted[hist][type][tier]); > > if (workingset) { > - /* > - * see folio_add_lru(), where folio_set_active() is > - * called for workingset folios > - */ > - if (lru_gen_in_fault()) > + /* Send refaulted workingset folios to active generations. */ > + if (lru_gen_in_fault()) { > + folio_set_active(folio); > mod_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + type, delta); > + } > folio_set_workingset(folio); > mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + type, delta); > } else > > -- > 2.55.0 > >