Skip to content

mm: improve large folio readahead for exec memory

Usama Arif linux-arm-kernel linux-fsdevel linux-mm lkml 5 versions – Applied

Status from this message: [merged mm-stable] mm-use-mapping_max_folio_order-for-force_thp_readahead-order.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest2 patches 5 repliesApplied 2/2
  2. v62 patches 13 repliesSuperseded
  3. v52 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v34 patches12 repliesSuperseded
v24 patches16 repliesSuperseded

Patches in v7 All 2 applied

#Subject and filesSizeRepliesApplied
1/2mm: bypass mmap_miss heuristic for VM_EXEC readaheadmm/filemap.c+7 -72 repliesApplied
2/2mm: use mapping_max_folio_order() for force_thp_readahead ordermm/filemap.c+22 -82 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchJan KaraKiryl Shutsemau (Meta)Oscar Salvador (SUSE)Pedro Falcato
1/2R-b R-b R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v7 thread

Cover letter [PATCH v7 0/2] mm: improve large folio readahead for exec memory

Hopefully this is the last revision. The only change from the previous revision is that the logic for deciding THP order was simplified and the max is now capped to 2M. Thanks Pedro and Jan for the suggestion and the dicusssion!

The benchmark results on Neoverse V2 (Grace), arm64 with 64K base pages, 512MB executable file on ext4, averaged over 3 runs:

  Phase      | Baseline     | Patched      | Improvement
  -----------|--------------|--------------|------------------
  Cold fault | 83.4 ms      | 41.3 ms      | 50% faster
  Random     | 76.0 ms      | 58.3 ms      | 23% faster

The patches are on top of mm-unstable from 28 May (8a74e22643189e0ae339afc91110ddb4cab1941b) which include patch [1] that make mmap_miss accounting symmetric for VM_SEQ_READ which was pointed out by sashiko in the previous revision.

[1] https://lore.kernel.org/all/[email protected]/

v6 -> v7: https://lore.kernel.org/all/[email protected]/
- Simplify logic and just cap the max THP order to 2M (Pedro and Jan)

v5 -> v6: https://lore.kernel.org/all/[email protected]/
- Based on top of patch [1] (sashiko)
- Changes to commit message to make it more accurate for patch 1 and skip mmap_miss decrement as well. (sashiko)
- Keep old behaviour if large folio mappings is not enabled (sashiko).
- sashiko pointed to a TOCTOU data race that was pre-existing. My patch could make it worse. Dont make it worse by introducing thp_order local variable.

v3 -> v5: https://lore.kernel.org/all/[email protected]/
- (Looks like I messed up the versioning here and went directly form v3 to v5.)
- Drop patches for elf thp unmapped area alignment and deal with them separately. These patches will just bring folios smaller than PMD
at the same level as PMD. The 2 patches now should be much easier
to merge.
- Tackle size of THP for exec pages at the same point as PMD instead of tackling using exec_folio_order() (Ryan during LSFMM, Thanks!)

v2 -> v3: https://lore.kernel.org/all/[email protected]/
- Take into account READ_ONLY_THP_FOR_FS for elf alignment by aligning to HPAGE_PMD_SIZE limited to 2M (Rui)
- Reviewed-by tags for patch 1 from Kiryl and Jan
- Remove preferred_exec_order() (Jan)
- Change ra->order to HPAGE_PMD_ORDER if vma_pages(vma) >= HPAGE_PMD_NR otherwise use exec_folio_order() with gfp &= ~__GFP_RECLAIM for do_sync_mmap_readahead().
- Change exec_folio_order() to return 2M (cont-pte size) for 64K base page size for arm64.
- remove bprm->file NULL check (Matthew)
- Change filp to file (Matthew)
- Improve checking of p_vaddr and p_vaddr (Rui and Matthew)

v1 -> v2: https://lore.kernel.org/all/[email protected]/
- disable mmap_miss logic for VM_EXEC (Jan Kara)
- Align in elf only when segment VA and file offset are already aligned (Rui)
- preferred_exec_order() for VM_EXEC sync mmap_readahead which takes into account zone high watermarks (as an approximation of memory pressure) (David, or atleast my approach to what David suggested in [1] :))
- Extend max alignment to mapping_max_folio_size() instead of exec_folio_order()

Usama Arif (2):
mm: bypass mmap_miss heuristic for VM_EXEC readahead
mm: use mapping_max_folio_order() for force_thp_readahead order

 mm/filemap.c | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)
Signature · 1 line
2.52.0