v1
2026-08-19
优化匿名swapbacked大folio解除映射 · v1
通过批量清除PTE并设置swap PTE,加速匿名大页的swapout,性能提升超2倍。
原始补丁链接
子 Patch(8)
1/8
mm/swapfile: add batched version of folio_dup_swap
Add folio_dup_swap_pages to handle a batch of consecutive pages. Note that folio_dup_swap already can handle a subset of this: nr_pages == 1 and nr_pages == folio_nr_pages(folio). Generalize this to a
2/8
mm/swapfile: add batched version of folio_put_swap
Add folio_put_swap_pages to handle a batch of consecutive pages. Note that folio_put_swap already can handle a subset of this: nr_pages == 1 and nr_pages == folio_nr_pages(folio). Generalize this to a
3/8
mm/rmap: mm/rmap: Add batched version of folio_try_share_anon_rmap_pte
To enable batched unmapping of anonymous folios, we need to handle the sharing of exclusive pages. Hence, a batched version of folio_try_share_anon_rmap_pte is required. Currently, the sole purpose o
4/8
mm/internal: rename swap offset helpers to softleaf offset
In preparation for adding a helper to set softleaf ptes in one go, generalize the swap entry helpers shifting the swap offset by delta, for softleaves. Note that the soft-dirty bit, exclusive bit and
5/8
mm/internal: add set_softleaf_ptes
Currently we have a helper called set_ptes() which is used to set consecutive present ptes in the pgtables. To do the same operation but to set “consecutive” nonpresent (softleaf) ptes, add set_softle
6/8
mm/memory: use set_softleaf_ptes for uffd-wp markers
Use set_softleaf_ptes() to store multiple uffd-wp marker entries instead of open coding the batched setting. Signed-off-by: Dev Jain dev.jain@arm.com — mm/memory.c | 10 ++——– 1 file change
7/8
mm: move anon-exclusive batch helper to internal.h
In preparation for optimizing large folio unmapping, we need to reuse the page_anon_exclusive_batch helper in rmap.c. Therefore, move it from mprotect.c to internal.h. Signed-off-by: Dev Jain <dev.ja
8/8
mm/rmap: batch unmap anonymous swap-backed large folios
Enable batch clearing of ptes, and batch swap setting of ptes for anon swap-backed folio unmapping. Processing all ptes of a large folio in one go helps us batch across atomics (add_mm_counter etc),