Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kairui Song <ryncsn@gmail.com>
To: Ridong Chen <ridong.chen@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Kairui Song <kasong@tencent.com>,
	David Hildenbrand <david@kernel.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Barry Song <baohua@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
	 Shakeel Butt <shakeel.butt@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	 Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Baoquan He <baoquan.he@linux.dev>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	 "open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)"
	<linux-mm@kvack.org>, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios()
Date: Sat, 28 Nov 2026 03:34:35 +0800	[thread overview]
Message-ID: <awnYv_mxag0b6Dny@KASONG-MC4> (raw)
In-Reply-To: <20261127060315.1119672-1-ridong.chen@linux.dev>

On Fri, Nov 27, 2026 at 02:03:13PM +0800, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
> 
> When many CPUs reclaim from the same lruvec, they spend most of their
> time spinning on lru_lock, and the time scan_folios() holds the lock
> limits reclaim throughput. With 24 threads refaulting file pages in one
> memcg, about 40% of all cycles went to waiting for lru_lock here.
> 
> This series takes per-folio work out of that critical section, along
> the lines of what isolate_lru_folios() already does for the classical
> LRU:
> 
> 1. Update the node, memcg and zone LRU sizes once per zone instead of
>    once per isolated folio.
> 
> 2. Prefetch the previous folio, so the cache miss on its flags and list
>    pointers is not taken while holding the lock.
> 
> Tested on an i7-13700HX (8P+8E, 24 threads), turbo off and the
> performance governor. 24 files of 128MiB on ext4 on brd, all threads
> in one memcg with memory.max=1G, random 4K pread(), so nearly every
> read refaults and every thread ends up in direct reclaim. Reads per
> second per CPU, mean of 2 runs, with and without each patch in one
> kernel and the runs interleaved:
> 
>   CPUs      base    patch 1   patch 2   both
>      1    426681     -0.4%     -0.2%    +0.3%
>      2    387442     +0.7%     +1.2%    +1.4%
>      4    360312     +1.0%     +1.5%    +2.1%
>      8    314549     +2.5%     +2.5%    +3.3%
>     12    235058     +3.2%     +4.3%    +5.6%
>     16    184086     +9.4%     +9.2%   +11.2%
>     24    124478    +15.5%    +16.5%   +21.6%
> 
> The gain grows with the number of CPUs reclaiming from one lruvec;
> with a few CPUs there is little contention and no measurable change.
> 
> Ridong Chen (2):
>   mm/mglru: update LRU sizes once per zone when isolating folios
>   mm/mglru: prefetch the previous folio in scan_folios()
> 
>  include/linux/mm_inline.h | 26 ++++++++++++++++++++++++--
>  mm/vmscan.c               | 18 +++++++++++++++---
>  2 files changed, 39 insertions(+), 5 deletions(-)

Hi Ridong

I have a different approach proposed about two years ago:

https://lore.kernel.org/all/20240123184552.59758-1-ryncsn@gmail.com/

I hesitated to push that as the end to end gain was not
that large (5-10%) fio and it makes the code too complex.
But I think that one may work very well for microbench.

I tried to resurrect that 2 weeks ago, but realized it's not
the best time at the moment, there are too many things in flight
for MGLRU:

https://github.com/ryncsn/linux/commits/b4/mglru-isolation/

Perhaps we can discuss and see if using a "batch struct" could
fit better later? It should also unify the aging batch too.


      parent reply	other threads:[~2026-11-27 19:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:03 [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios() Ridong Chen
2026-11-27  6:03 ` [RFC PATCH 1/2] mm/mglru: update LRU sizes once per zone when isolating folios Ridong Chen
2026-11-27  6:03 ` [RFC PATCH 2/2] mm/mglru: prefetch the previous folio in scan_folios() Ridong Chen
2026-11-27 19:34 ` Kairui Song [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=awnYv_mxag0b6Dny@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=baoquan.he@linux.dev \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=ridong.chen@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=yuanchu@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