Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios()
@ 2026-11-27  6:03 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
  0 siblings, 2 replies; 3+ messages in thread
From: Ridong Chen @ 2026-11-27  6:03 UTC (permalink / raw)
  To: Andrew Morton, Kairui Song, David Hildenbrand, Johannes Weiner
  Cc: Barry Song, Qi Zheng, Shakeel Butt, Axel Rasmussen, Yuanchu Xie,
	Wei Xu, Baoquan He, Baolin Wang, Liam R. Howlett, Vlastimil Babka,
	Mike Rapoport, Michal Hocko,
	open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU), Ridong Chen,
	Ridong Chen

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27  6:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox