RFC mm/mglru: shorten the lru_lock hold time in scan_folios()
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | mm/mglru: update LRU sizes once per zone when isolating foliosinclude/ mm/ | +37 | 0 replies | |
| 2/2 | mm/mglru: prefetch the previous folio in scan_folios()mm/ | +2 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios()
From: Ridong Chen <[email protected]>
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
Signature · 1 line
2.34.1