Skip to content

RFC folio based filemap_map_pages()

Yin Fengwei linux-mm 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 RFC Latest4 patches 12 repliesIn review
  2. v3 RFC4 patches 16 repliesSuperseded
  3. v2 RFC5 patches 13 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v1 RFC5 patches14 repliesSuperseded

Changes in v4 from the cover letter

Patch 1:
- delete folio_more_pages() as no onc call it as suggested by Matthew
- Make the xas.xa_index point to end_pgoff when loop end as Kirill pointed out
- Style fixing as pointed out by Matthew and Kirill

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4filemap: add function filemap_map_folio_range()mm/filemap.c+54 -440 replies
2/4rmap: add folio_add_file_rmap_range()include/linux/rmap.h mm/rmap.c+54 -140 replies
3/4mm: add do_set_pte_range()include/linux/mm.h mm/filemap.c mm/memory.c+49 -2110 replies
4/4filemap: batched update mm counter,rmap when map file foliomm/filemap.c+25 -102 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [RFC PATCH v4 0/4] folio based filemap_map_pages()

Current filemap_map_pages() uses page granularity even when underneath folio is large folio. Making it use folio based granularity allows batched refcount, rmap and mm counter update. Which brings performance gain.

This series tries to bring batched refcount, rmap and mm counter for filemap_map_pages(). Testing with a micro benchmark like will-it-scale.pagefault on a 48C/96T IceLake box showed:
- batched rmap brings around 15% performance gain
- batched refcount brings around 2% performance gain

Patch 1 update filemap_map_pages() to do map based on folio
granularity and batched refcount update

Patch 2,3,4 enable batched rmap and mm counter

Change from v3:
Patch 1:
- delete folio_more_pages() as no onc call it as suggested by Matthew
- Make the xas.xa_index point to end_pgoff when loop end as Kirill pointed out
- Style fixing as pointed out by Matthew and Kirill

Patch 2:
- Typo fix and better comments as Matthew and Kirill suggested

Patch 3:
- Warn on cow case in do_set_pte_range() and add comment about cow can't handle large folio yet

Change from v2:
- Drop patch 1 because it misses ->page_mkwrite() as Kirill pointed out.

Patch 2:
- Change page_add_file_rmap_range() to folio_add_file_rmap_range() as Matthew suggested
- Remove "sub" as Matthew suggested

Patch 3:
- Only handle !cow case in do_set_pte_range() as David pointed out
- Add a parameter of pte and avoid change vmf->pte in do_set_pte_range()
- Drop do_set_pte_entry()

Patch 4:
- adopt the suggestion from Matthew to avoid subtracted/add vmf->pte. filemap_map_folio_range() doesn't update vmf->pte now. Make it easy to fit the filemap_map_pages() and no possible point to wrong page table.

Change from v1:
- Update the struct page * parameter of *_range() to index in the folio as Matthew suggested
- Fix indentations problem as Matthew pointed out
- Add back the function comment as Matthew pointed out
- Use nr_pages than len as Matthew pointed out
- Add do_set_pte_range() as Matthew suggested
- Add function comment as Ying suggested
- Add performance test result to patch 1/2/5 commit message

Patch 1:
- Adapt commit message as Matthew suggested
- Add Reviweed-by from Matthew
Patch 3:
- Restore general logic of page_add_file_rmap_range() to make patch review easier as Matthew suggested
Patch 5:
- Add perf data collected to understand the reason of performance gain

Yin Fengwei (4):
filemap: add function filemap_map_folio_range()
rmap: add folio_add_file_rmap_range()
mm: add do_set_pte_range()
filemap: batched update mm counter,rmap when map file folio

 include/linux/mm.h   |   3 ++
 include/linux/rmap.h |   2 +
 mm/filemap.c         | 112 ++++++++++++++++++++++++++-----------------
 mm/memory.c          |  66 +++++++++++++++++--------
 mm/rmap.c            |  66 +++++++++++++++++++------
 5 files changed, 171 insertions(+), 78 deletions(-)
Signature · 1 line
2.30.2