linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kalesh Singh <kaleshsingh@google.com>
To: Yu Zhao <yuzhao@google.com>
Cc: akpm@linux-foundation.org, surenb@google.com,
	android-mm@google.com,  kernel-team@android.com,
	Charan Teja Kalla <quic_charante@quicinc.com>,
	 Lecopzer Chen <lecopzer.chen@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	 linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 1/3] mm-unstable: Multi-gen LRU: Fix per-zone reclaim
Date: Tue, 1 Aug 2023 20:00:20 -0700	[thread overview]
Message-ID: <CAC_TJveohqQNDT+AuoP-25Bm+=GWTZY=XWV+Q=_t=H5YujNF4g@mail.gmail.com> (raw)
In-Reply-To: <CAOUHufbz-VHZ12b9wrCFxZ9mqVnU=Xstkoo5Ym9_tw72R1-2Gg@mail.gmail.com>

On Tue, Aug 1, 2023 at 7:08 PM Yu Zhao <yuzhao@google.com> wrote:
>
> On Tue, Aug 1, 2023 at 6:19 PM Kalesh Singh <kaleshsingh@google.com> wrote:
> >
> > MGLRU has a LRU list for each zone for each type (anon/file) in each
> > generation:
> >
> >         long nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
> >
> > The min_seq (oldest generation) can progress independently for each
> > type but the max_seq (youngest generation) is shared for both anon and
> > file. This is to maintain a common frame of reference.
> >
> > In order for eviction to advance the min_seq of a type, all the per-zone
> > lists in the oldest generation of that type must be empty.
> >
> > The eviction logic only considers pages from eligible zones for
> > eviction or promotion.
> >
> >     scan_folios() {
> >         ...
> >         for (zone = sc->reclaim_idx; zone >= 0; zone--)  {
> >             ...
> >             sort_folio();       // Promote
> >             ...
> >             isolate_folio();    // Evict
> >         }
> >         ...
> >     }
> >
> > Consider the system has the movable zone configured and default 4
> > generations. The current state of the system is as shown below
> > (only illustrating one type for simplicity):
> >
> > Type: ANON
> >
> >         Zone    DMA32     Normal    Movable    Device
> >
> >         Gen 0       0          0        4GB         0
> >
> >         Gen 1       0        1GB        1MB         0
> >
> >         Gen 2     1MB        4GB        1MB         0
> >
> >         Gen 3     1MB        1MB        1MB         0
> >
> > Now consider there is a GFP_KERNEL allocation request (eligible zone
> > index <= Normal), evict_folios() will return without doing any work
> > since there are no pages to scan in the eligible zones of the oldest
> > generation. Reclaim won't make progress until triggered from a ZONE_MOVABLE
> > allocation request; which may not happen soon if there is a lot of free
> > memory in the movable zone. This can lead to OOM kills, although there
> > is 1GB pages in the Normal zone of Gen 1 that we have not yet tried to
> > reclaim.
> >
> > This issue is not seen in the conventional active/inactive LRU since
> > there are no per-zone lists.
> >
> > If there are no (not enough) folios to scan in the eligible zones, move
> > folios from ineligible zone (zone_index > reclaim_index) to the next
> > generation. This allows for the progression of min_seq and reclaiming
> > from the next generation (Gen 1).
> >
> > Qualcomm, Mediatek and raspberrypi [1] discovered this issue independently.
> >
> > [1] https://github.com/raspberrypi/linux/issues/5395
> >
> > Cc: Yu Zhao <yuzhao@google.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Reported-by: Charan Teja Kalla <quic_charante@quicinc.com>
> > Reported-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
> > Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
>
> LGTM. But I think we need the Fixes tag and Cc stable.

I've reposted the patches with fixes tag and stable cc'ed at:
https://lore.kernel.org/lkml/20230802025606.346758-1-kaleshsingh@google.com/#t

Thanks,
Kalesh


      reply	other threads:[~2023-08-02  3:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02  0:19 Kalesh Singh
2023-08-02  0:19 ` [PATCH 2/3] mm-unstable: Multi-gen LRU: Avoid race in inc_min_seq() Kalesh Singh
2023-08-02  0:19 ` [PATCH 3/3] mm-unstable: Multi-gen LRU: Fix can_swap in lru_gen_look_around() Kalesh Singh
2023-08-02  2:07 ` [PATCH 1/3] mm-unstable: Multi-gen LRU: Fix per-zone reclaim Yu Zhao
2023-08-02  3:00   ` Kalesh Singh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC_TJveohqQNDT+AuoP-25Bm+=GWTZY=XWV+Q=_t=H5YujNF4g@mail.gmail.com' \
    --to=kaleshsingh@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=android-mm@google.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=kernel-team@android.com \
    --cc=lecopzer.chen@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=quic_charante@quicinc.com \
    --cc=surenb@google.com \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox