[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGsJ_4zf6W7EPvWfJ19GkT59vKC6exfqcRp6MDD3_a2opwf50A@mail.gmail.com>
Date: Tue, 22 Mar 2022 00:47:25 +1300
From: Barry Song <21cnbao@...il.com>
To: Yu Zhao <yuzhao@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andi Kleen <ak@...ux.intel.com>,
Aneesh Kumar <aneesh.kumar@...ux.ibm.com>,
Catalin Marinas <catalin.marinas@....com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Hillf Danton <hdanton@...a.com>, Jens Axboe <axboe@...nel.dk>,
Jesse Barnes <jsbarnes@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Jonathan Corbet <corbet@....net>,
Matthew Wilcox <willy@...radead.org>,
Mel Gorman <mgorman@...e.de>,
Michael Larabel <Michael@...haellarabel.com>,
Michal Hocko <mhocko@...nel.org>,
Mike Rapoport <rppt@...nel.org>,
Rik van Riel <riel@...riel.com>,
Vlastimil Babka <vbabka@...e.cz>,
Will Deacon <will@...nel.org>,
Ying Huang <ying.huang@...el.com>,
LAK <linux-arm-kernel@...ts.infradead.org>,
Linux Doc Mailing List <linux-doc@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>,
Kernel Page Reclaim v2 <page-reclaim@...gle.com>,
x86 <x86@...nel.org>, Brian Geffon <bgeffon@...gle.com>,
Jan Alexander Steffens <heftig@...hlinux.org>,
Oleksandr Natalenko <oleksandr@...alenko.name>,
Steven Barrett <steven@...uorix.net>,
Suleiman Souhlal <suleiman@...gle.com>,
Daniel Byrne <djbyrne@....edu>,
Donald Carr <d@...os-reins.com>,
Holger Hoffstätte <holger@...lied-asynchrony.com>,
Konstantin Kharlamov <Hi-Angel@...dex.ru>,
Shuang Zhai <szhai2@...rochester.edu>,
Sofia Trinh <sofia.trinh@....works>,
Vaibhav Jain <vaibhav@...ux.ibm.com>
Subject: Re: [PATCH v9 05/14] mm: multi-gen LRU: groundwork
On Mon, Mar 21, 2022 at 10:04 PM Yu Zhao <yuzhao@...gle.com> wrote:
>
> On Wed, Mar 16, 2022 at 5:25 PM Barry Song <21cnbao@...il.com> wrote:
> >
> ...
> > > +static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio, bool reclaiming)
> > > +{
> > > + int gen;
> > > + unsigned long old_flags, new_flags;
> > > + int type = folio_is_file_lru(folio);
> > > + int zone = folio_zonenum(folio);
> > > + struct lru_gen_struct *lrugen = &lruvec->lrugen;
> > > +
> > > + if (folio_test_unevictable(folio))
> > > + return false;
> > > + /*
> > > + * There are three common cases for this page:
> > > + * 1. If it's hot, e.g., freshly faulted in or previously hot and
> > > + * migrated, add it to the youngest generation.
> >
> > usually, one page is not active when it is faulted in. till its second
> > access is detected, it can be active.
>
> The active/inactive LRU *assumes* this; MGLRU *assumes* the opposite,
> and there is no "active" in MGLRU -- we call it hot to avoid confusion
> :)
yep.
>
> > > + * 2. If it's cold but can't be evicted immediately, i.e., an anon page
> > > + * not in swapcache or a dirty page pending writeback, add it to the
> > > + * second oldest generation.
> > > + * 3. Everything else (clean, cold) is added to the oldest generation.
> > > + */
> ...
> > > +#define LRU_GEN_MASK ((BIT(LRU_GEN_WIDTH) - 1) << LRU_GEN_PGOFF)
> > > +#define LRU_REFS_MASK ((BIT(LRU_REFS_WIDTH) - 1) << LRU_REFS_PGOFF)
> >
> > The commit log said nothing about REFS flags and tiers.
> > but the code is here. either the commit log lacks something
> > or the code should belong to the next patch?
>
> It did:
> A few macros, i.e., LRU_REFS_*, used later are added in this patch
> to make the patchset less diffy.
sorry for missing that.
>
> > > @@ -462,6 +462,11 @@ void folio_add_lru(struct folio *folio)
> > > VM_BUG_ON_FOLIO(folio_test_active(folio) && folio_test_unevictable(folio), folio);
> > > VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
> > >
> > > + /* see the comment in lru_gen_add_folio() */
> > > + if (lru_gen_enabled() && !folio_test_unevictable(folio) &&
> > > + lru_gen_in_fault() && !(current->flags & PF_MEMALLOC))
> > > + folio_set_active(folio);
> >
> > So here is our magic to make folio active as long as it is
> > faulted in? i really don't think the below comment is good,
> > could we say our purpose directly and explicitly?
> >
> > /* see the comment in lru_gen_add_folio() */
>
> I generally keep comments in a few major locations and reference them
> from many other minior locations so that it's easier to manage in the
> long run. It is a hassle for reviews but once in the tree you can jump
> to lru_gen_add_folio() with ctags/cscope or find all places that
> reference it by grepping. Assuming we state the purpose, which is to
> make lru_gen_add_folio() add the page to the youngest generation, you
> still want to go to lru_gen_add_folio() to check if this is really the
> case. So why bother :)
well understood though my pain was that I needed to email you to get
confirmed this is really the case.
Thanks
Barry
Powered by blists - more mailing lists