All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kairui Song <ryncsn@gmail.com>
To: Barry Song <baohua@kernel.org>
Cc: kasong@tencent.com, 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>,
	Qi Zheng <zhengqi.arch@bytedance.com>,
	 Shakeel Butt <shakeel.butt@linux.dev>,
	Lorenzo Stoakes <ljs@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>,
	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>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>
Subject: Re: [PATCH v3 06/14] mm/mglru: use a smaller batch for reclaim
Date: Fri, 3 Apr 2026 17:09:40 +0800	[thread overview]
Message-ID: <ac9xnv1Opj6cVS2R@KASONG-MC4> (raw)
In-Reply-To: <CAGsJ_4z2=Wrm0NAfpE_98rKqEgncBceVscqFRGDPeuR0eCxQCA@mail.gmail.com>

On Fri, Apr 03, 2026 at 03:50:37PM +0800, Barry Song wrote:
> On Fri, Apr 3, 2026 at 2:53 AM Kairui Song via B4 Relay
> <devnull+kasong.tencent.com@kernel.org> wrote:
> >
> > From: Kairui Song <kasong@tencent.com>
> >
> > With a fixed number to reclaim calculated at the beginning, making each
> > following step smaller should reduce the lock contention and avoid
> > over-aggressive reclaim of folios, as it will abort earlier when the
> > number of folios to be reclaimed is reached.
> >
> > Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
> > Reviewed-by: Chen Ridong <chenridong@huaweicloud.com>
> > Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Signed-off-by: Kairui Song <kasong@tencent.com>
> > ---
> >  mm/vmscan.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index 643f9fc10214..9c28afb0219c 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -5008,7 +5008,7 @@ static bool try_to_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
> >                         break;
> >                 }
> >
> > -               nr_batch = min(nr_to_scan, MAX_LRU_BATCH);
> > +               nr_batch = min(nr_to_scan, MIN_LRU_BATCH);
> 
> I’m fine with the smaller batch size, but I wonder if
> MIN_LRU_BATCH is too small.

Thanks for the review, Barry!

It's quite reasonable value I think, for comparison classical LRU's
batch size is SWAP_CLUSTER_MAX (32), even smaller than
MIN_LRU_BATCH (64).

I ran many different benchmarks on this which can be found in
V2 / V1's cover letter (it getting too long so I didn't include these
results in V3 but I did retest). The new value looked good from large
server to small VMs.

It's also a much more reasonable value for batch throttling and dirty
writeback IMO.

> 
> Just curious if we are calling get_nr_to_scan() more frequently
> before we can abort the while (true) loop if reclamation
> is not making good progress.
> 
> Assume get_nr_to_scan() also has a cost. Not sure if a
> value between MIN_LRU_BATCH and MAX_LRU_BATCH
> would be better.

We are calling that less frequently actually, in a previous
commit it was moved out of the loop to act like a budget
control. That's also where using a smaller batch start
to makes more sense.

The overhead of other function calls also seems trivial.

I also wonder if we can unify or remove some
SWAP_CLUSTER_MAX usage, that value might be no longer
suitable in many places.


  reply	other threads:[~2026-04-03  9:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 18:53 [PATCH v3 00/14] mm/mglru: improve reclaim loop and dirty folio handling Kairui Song
2026-04-02 18:53 ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 01/14] mm/mglru: consolidate common code for retrieving evictable size Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-03  3:16   ` Kairui Song
2026-04-02 18:53 ` [PATCH v3 02/14] mm/mglru: rename variables related to aging and rotation Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 03/14] mm/mglru: relocate the LRU scan batch limit to callers Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 04/14] mm/mglru: restructure the reclaim loop Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-03  4:44   ` Kairui Song
2026-04-02 18:53 ` [PATCH v3 05/14] mm/mglru: scan and count the exact number of folios Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 06/14] mm/mglru: use a smaller batch for reclaim Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-03  7:50   ` Barry Song
2026-04-03  9:09     ` Kairui Song [this message]
2026-04-03  9:25       ` Barry Song
2026-04-02 18:53 ` [PATCH v3 07/14] mm/mglru: don't abort scan immediately right after aging Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 08/14] mm/mglru: remove redundant swap constrained check upon isolation Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 09/14] mm/mglru: use the common routine for dirty/writeback reactivation Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-03  5:00   ` Kairui Song
2026-04-02 18:53 ` [PATCH v3 10/14] mm/mglru: simplify and improve dirty writeback handling Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 11/14] mm/mglru: remove no longer used reclaim argument for folio protection Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 12/14] mm/vmscan: remove sc->file_taken Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 13/14] mm/vmscan: remove sc->unqueued_dirty Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-02 18:53 ` [PATCH v3 14/14] mm/vmscan: unify writeback reclaim statistic and throttling Kairui Song
2026-04-02 18:53   ` Kairui Song via B4 Relay
2026-04-03 21:15   ` Axel Rasmussen
2026-04-04 18:36     ` Kairui Song
2026-04-07  6:27   ` Baolin Wang
2026-04-03 21:26 ` [PATCH v3 00/14] mm/mglru: improve reclaim loop and dirty folio handling Axel Rasmussen

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=ac9xnv1Opj6cVS2R@KASONG-MC4 \
    --to=ryncsn@gmail.com \
    --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=kasong@tencent.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=shakeel.butt@linux.dev \
    --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 \
    --cc=zhengqi.arch@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.