Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Kairui Song <ryncsn@gmail.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	 Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	David Hildenbrand <david@kernel.org>,
	 Michal Hocko <mhocko@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Barry Song <baohua@kernel.org>,
	 David Stevens <stevensd@google.com>,
	Chen Ridong <chenridong@huaweicloud.com>,
	 Leno Hou <lenohou@gmail.com>, Yafang Shao <laoar.shao@gmail.com>,
	Yu Zhao <yuzhao@google.com>,
	 Zicheng Wang <wangzicheng@honor.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	 Kalesh Singh <kaleshsingh@google.com>,
	Suren Baghdasaryan <surenb@google.com>,
	 Chris Li <chrisl@kernel.org>, Vernon Yang <vernon2gm@gmail.com>,
	linux-kernel@vger.kernel.org,  Qi Zheng <qi.zheng@linux.dev>
Subject: Re: [PATCH v7 03/15] mm/mglru: relocate the LRU scan batch limit to callers
Date: Fri, 29 May 2026 14:29:01 -0700	[thread overview]
Message-ID: <ahncWUAJlPZhNGr8@linux.dev> (raw)
In-Reply-To: <CAMgjq7DYAyu15Fn6k6A7bozonT+hrV6ZrXL3NTmg7T+DWPj7pA@mail.gmail.com>

On Fri, May 29, 2026 at 02:01:43PM +0800, Kairui Song wrote:
> On Fri, May 29, 2026 at 1:40 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > On Tue, Apr 28, 2026 at 02:06:54AM +0800, Kairui Song via B4 Relay wrote:
> > > From: Kairui Song <kasong@tencent.com>
> > >
> > > Same as active / inactive LRU, MGLRU isolates and scans folios in batches.
> > > The batch split is done hidden deep in the helper, which makes the code
> > > harder to follow.  The helper's arguments are also confusing since callers
> > > usually request more folios than the batch size, so the helper almost
> > > never processes the full requested amount.
> > >
> > > Move the batch splitting into the top loop to make it cleaner, there
> > > should be no behavior change.
> > >
> > > Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
> > > Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> > > Reviewed-by: Barry Song <baohua@kernel.org>
> > > Reviewed-by: Chen Ridong <chenridong@huaweicloud.com>
> > > Signed-off-by: Kairui Song <kasong@tencent.com>
> > > ---
> > >  mm/vmscan.c | 16 +++++++++-------
> > >  1 file changed, 9 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > > index 7f011ff4c478..a011733a6392 100644
> > > --- a/mm/vmscan.c
> > > +++ b/mm/vmscan.c
> > > @@ -4695,10 +4695,10 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec,
> > >       int scanned = 0;
> > >       int isolated = 0;
> > >       int skipped = 0;
> > > -     int scan_batch = min(nr_to_scan, MAX_LRU_BATCH);
> > > -     int remaining = scan_batch;
> > > +     unsigned long remaining = nr_to_scan;
> > >       struct lru_gen_folio *lrugen = &lruvec->lrugen;
> > >
> > > +     VM_WARN_ON_ONCE(nr_to_scan > MAX_LRU_BATCH);
> >
> > Do we really need a warning here? Also why are we limiting it to MAX_LRU_BATCH?
> > For memcg/proactive reclaim, we can get larger number. What will break if we
> > remove this limitation?
> 
> Hi,
> Isolating a large chunk of folios off the list is usually a bad idea,
> livelock is one concern, besides, concurrent reclaimer won't see them
> anymore, and LRU operations on them will be skipped (eg. roration).
> Under heavy pressure, this could lead to premature OOM because some
> reclaimers will see the LRU as empty. or accuracy loss.

Oh this is the isolation count/limit. CLRU isolates SWAP_CLUSTER_MAX folios at a
time. Any reason why MGLRU does 4096 (on 64-bit machine)?

Later we should evaluate what would be the right isolation count and use same
for both unless there is some inherent reason behind the difference.

> 
> There is a LRU isolate throttle for CLRU, which is missing for MGLRU,

I am not a fan of that specific (too_many_isolated) throttling. In the long term
we should properly throttle the number of direct reclaimers.



  reply	other threads:[~2026-05-29 21:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 18:06 [PATCH v7 00/15] mm/mglru: improve reclaim loop and dirty folio handling Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 01/15] mm/mglru: consolidate common code for retrieving evictable size Kairui Song via B4 Relay
2026-05-29  5:36   ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 02/15] mm/mglru: rename variables related to aging and rotation Kairui Song via B4 Relay
2026-05-29  5:37   ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 03/15] mm/mglru: relocate the LRU scan batch limit to callers Kairui Song via B4 Relay
2026-05-29  5:40   ` Shakeel Butt
2026-05-29  6:01     ` Kairui Song
2026-05-29 21:29       ` Shakeel Butt [this message]
2026-04-27 18:06 ` [PATCH v7 04/15] mm/mglru: restructure the reclaim loop Kairui Song via B4 Relay
2026-05-30  5:48   ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 05/15] mm/mglru: scan and count the exact number of folios Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 06/15] mm/mglru: avoid reclaim type fall back when isolation makes no progress Kairui Song via B4 Relay
2026-04-28  4:18   ` Kairui Song
2026-04-27 18:06 ` [PATCH v7 07/15] mm/mglru: use a smaller batch for reclaim Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 08/15] mm/mglru: don't abort scan immediately right after aging Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 09/15] mm/mglru: remove redundant swap constrained check upon isolation Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 10/15] mm/mglru: use the common routine for dirty/writeback reactivation Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 11/15] mm/mglru: simplify and improve dirty writeback handling Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 12/15] mm/mglru: remove no longer used reclaim argument for folio protection Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 13/15] mm/vmscan: remove sc->file_taken Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 14/15] mm/vmscan: remove sc->unqueued_dirty Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 15/15] mm/vmscan: unify writeback reclaim statistic and throttling Kairui Song via B4 Relay
2026-04-27 18:22 ` [PATCH v7 00/15] mm/mglru: improve reclaim loop and dirty folio handling Andrew Morton
2026-05-11 18:51 ` Shakeel Butt
2026-05-12  5:08   ` Kairui Song
2026-05-12  5:56     ` Shakeel Butt
2026-05-27  1:35       ` Andrew Morton
2026-05-27  3:25         ` Shakeel Butt
2026-05-27  5:36         ` Kairui Song
2026-05-27 20:40           ` Andrew Morton
2026-05-14 18:50 ` Kairui Song

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=ahncWUAJlPZhNGr8@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chenridong@huaweicloud.com \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kaleshsingh@google.com \
    --cc=laoar.shao@gmail.com \
    --cc=lenohou@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=ryncsn@gmail.com \
    --cc=stevensd@google.com \
    --cc=surenb@google.com \
    --cc=vernon2gm@gmail.com \
    --cc=wangzicheng@honor.com \
    --cc=weixugc@google.com \
    --cc=yuanchu@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