linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/readahead: batch folio insertion to improve performance
@ 2026-01-19  6:50 Zhiguo Zhou
  2026-01-19  6:50 ` [PATCH 1/2] mm/filemap: refactor __filemap_add_folio to separate critical section Zhiguo Zhou
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Zhiguo Zhou @ 2026-01-19  6:50 UTC (permalink / raw)
  To: linux-mm, linux-fsdevel
  Cc: willy, akpm, david, lorenzo.stoakes, Liam.Howlett, vbabka, rppt,
	surenb, mhocko, muchun.song, osalvador, linux-kernel, tianyou.li,
	tim.c.chen, gang.deng, Zhiguo Zhou

This patch series improves readahead performance by batching folio
insertions into the page cache's xarray, reducing the cacheline transfers,
and optimizing the execution efficiency in the critical section.

PROBLEM
=======
When the `readahead` syscall is invoked, `page_cache_ra_unbounded`
currently inserts folios into the page cache individually. Each insertion
requires acquiring and releasing the `xa_lock`, which can lead to:
1. Significant lock contention when running on multi-core systems
2. Cross-core cacheline transfers for the lock and associated data
3. Increased execution time due to frequent lock operations

These overheads become particularly noticeable in high-throughput storage
workloads where readahead is frequently used.

SOLUTION
========
This series introduces batched folio insertion for contiguous ranges in
the page cache. The key changes are:

Patch 1/2: Refactor __filemap_add_folio to separate critical section
- Extract the core xarray insertion logic into
  __filemap_add_folio_xa_locked()
- Allow callers to control locking granularity via a 'xa_locked' parameter
- Maintain existing functionality while preparing for batch insertion

Patch 2/2: Batch folio insertion in page_cache_ra_unbounded
- Introduce filemap_add_folio_range() for batch insertion of folios
- Pre-allocate folios before entering the critical section
- Insert multiple folios while holding the xa_lock only once
- Update page_cache_ra_unbounded to use the new batching interface
- Insert folios individually when memory is under pressure

PERFORMANCE RESULTS
===================
Testing was performed using RocksDB's `db_bench` (readseq workload) on a
32-vCPU Intel Ice Lake server with 256GB memory:

1. Throughput improved by 1.51x (ops/sec)
2. Latency:
   - P50: 63.9% reduction (6.15 usec → 2.22 usec)
   - P75: 42.1% reduction (13.38 usec → 7.75 usec)
   - P99: 31.4% reduction (507.95 usec → 348.54 usec)
3. IPC of page_cache_ra_unbounded (excluding lock overhead) improved by
   2.18x

TESTING DETAILS
===============
- Kernel: v6.19-rc5 (0f61b1, tip of mm.git:mm-stable on Jan 14, 2026)
- Hardware: Intel Ice Lake server, 32 vCPUs, 256GB RAM
- Workload: RocksDB db_bench readseq
- Command: ./db_bench --benchmarks=readseq,stats --use_existing_db=1
           --num_multi_db=32 --threads=32 --num=1600000 --value_size=8192
           --cache_size=16GB

IMPLEMENTATION NOTES
====================
- The existing single-folio insertion API remains unchanged for
  compatibility
- Hugetlb folio handling is preserved through the refactoring
- Error injection (BPF) support is maintained for __filemap_add_folio

Zhiguo Zhou (2):
  mm/filemap: refactor __filemap_add_folio to separate critical section
  mm/readahead: batch folio insertion to improve performance

 include/linux/pagemap.h |   4 +-
 mm/filemap.c            | 238 ++++++++++++++++++++++++++++------------
 mm/hugetlb.c            |   3 +-
 mm/readahead.c          | 196 ++++++++++++++++++++++++++-------
 4 files changed, 325 insertions(+), 116 deletions(-)

-- 
2.43.0



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

end of thread, other threads:[~2026-01-19 14:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-19  6:50 [PATCH 0/2] mm/readahead: batch folio insertion to improve performance Zhiguo Zhou
2026-01-19  6:50 ` [PATCH 1/2] mm/filemap: refactor __filemap_add_folio to separate critical section Zhiguo Zhou
2026-01-19  8:34   ` kernel test robot
2026-01-19  9:16   ` kernel test robot
2026-01-19  6:50 ` [PATCH 2/2] mm/readahead: batch folio insertion to improve performance Zhiguo Zhou
2026-01-19 10:02 ` [PATCH v2 0/2] " Zhiguo Zhou
2026-01-19 10:02   ` [PATCH v2 1/2] mm/filemap: refactor __filemap_add_folio to separate critical section Zhiguo Zhou
2026-01-19 10:02   ` [PATCH v2 2/2] mm/readahead: batch folio insertion to improve performance Zhiguo Zhou
2026-01-19 10:38   ` [PATCH v2 0/2] mm/readahead: Changes since v1 Zhiguo Zhou
2026-01-19 14:15   ` [PATCH v2 0/2] mm/readahead: batch folio insertion to improve performance Matthew Wilcox

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