mm/memory: align alloc_swap_folio() logic with alloc_anon_folio()
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest0 of 3 patches 0 repliesNew
Patches in v1 No applies recorded yet
None of the 3 patches the cover letter announces are in this archive.
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] mm/memory: align alloc_swap_folio() logic with alloc_anon_folio()
This series cleans up the logic used when swapping in large folios to bring it in line with the established patterns in alloc_anon_folio().
Context:
When swapping in a large folio, the kernel performs a process similar to alloc_anon_folio(): it scans the PTE range to determine the highest suitable order for a large folio and then attempts allocation. However, two key discrepancies currently exist in alloc_swap_folio():
1. Improper Fallback: It currently falls back to an order-0 folio if pte_offset_map_lock() returns NULL.
2. Unnecessary Locking: It locks the page table during the initial scanning phase.
Improvements:
Based on an analysis of the alloc_anon_folio() implementation, this series applies the following corrections to the swap-in path:
1. Bail out on NULL PTE: If pte_offset_map_lock() returns NULL, it indicates the page table has changed under us. In this scenario, the operation is likely to fail later anyway; continuing the process is inefficient and unnecessary.
2. Lockless Initial Scan: The initial scan only reads PTEs to determine the appropriate folio order. Since no modifications are made at this stage, and the table is re-verified and locked before the actual write, the initial lock is redundant. Removing it reduces lock contention and system load.
Wei Yang (2):
mm: bail out do_swap_page() when no PTE table exist
mm: avoid unnecessary PTE table lock during initial swap folio scan
mm/memory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1