Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
	Kairui Song <kasong@tencent.com>,
	David Hildenbrand <david@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>
Cc: 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>,
	linux-mm@kvack.org (open list:MEMORY MANAGEMENT - MGLRU
	(MULTI-GEN LRU)), Ridong Chen <ridong.chen@linux.dev>,
	Ridong Chen <chenridong@xiaomi.com>
Subject: [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios()
Date: Fri, 27 Nov 2026 14:03:13 +0800	[thread overview]
Message-ID: <20261127060315.1119672-1-ridong.chen@linux.dev> (raw)

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(-)


base-commit: 3d27e49eb905a5119e78fbe3d3890f376d15c728
-- 
2.34.1



             reply	other threads:[~2026-11-27  6:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:03 Ridong Chen [this message]
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

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=20261127060315.1119672-1-ridong.chen@linux.dev \
    --to=ridong.chen@linux.dev \
    --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=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