Skip to content

RFC mm: vm_normal_page*() + CoW PFNMAP improvements

David Hildenbrand linux-fsdevel linux-mm lkml nvdimm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest14 patches 50 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14mm/memory: drop highest_memmap_pfn sanity check in vm_normal_page()mm/memory.c+3 -1215 replies
2/14mm: drop highest_memmap_pfnmm/internal.h mm/memory.c mm/mm_init.c +1 more+0 -82 replies
3/14mm: compare pfns only if the entry is present when inserting pfns/pagesmm/huge_memory.c mm/memory.c+4 -44 replies
4/14mm/huge_memory: move more common code into insert_pmd()mm/huge_memory.c+24 -482 replies
5/14mm/huge_memory: move more common code into insert_pud()mm/huge_memory.c+13 -232 replies
6/14mm/huge_memory: support huge zero folio in vmf_insert_folio_pmd()mm/huge_memory.c+5 -34 replies
7/14fs/dax: use vmf_insert_folio_pmd() to insert the huge zero foliofs/dax.c+10 -374 replies
8/14mm/huge_memory: mark PMD mappings of the huge zero folio specialmm/huge_memory.c mm/memory.c+13 -52 replies
9/14mm/memory: introduce is_huge_zero_pfn() and use it in vm_normal_page_pmd()include/linux/huge_mm.h mm/memory.c+12 -21 reply
10/14mm/memory: factor out common code from vm_normal_page_*()mm/memory.c+46 -584 replies
11/14mm: remove "horrible special case to handle copy-on-write behaviour"include/linux/mm.h mm/huge_memory.c mm/memory.c+96 -543 replies
12/14mm: drop addr parameter from vm_normal_*_pmd()fs/proc/task_mmu.c include/linux/mm.h mm/huge_memory.c +2 more+11 -150 replies
13/14mm: introduce and use vm_normal_page_pud()include/linux/mm.h mm/memory.c mm/pagewalk.c+22 -101 reply
14/14mm: rename vm_ops->find_special_page() to vm_ops->find_normal_page()drivers/xen/Kconfig drivers/xen/gntdev.c include/linux/mm.h +3 more+40 -142 replies

Reviews trailers per patch

10 of 14 patches have a Reviewed-by or Acked-by.

PatchOscar SalvadorPedro FalcatoLance YangAlistair Popple
1/14R-b R-b
2/14R-b R-b
3/14R-b R-b
4/14R-b R-b
5/14R-b R-b
6/14R-b
7/14
8/14R-b
9/14R-b
10/14R-b
11/14
12/14
13/14R-b
14/14

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 v1 thread

Cover letter [PATCH RFC 00/14] mm: vm_normal_page*() + CoW PFNMAP improvements

RFC because it's based on mm-new where some things might still change around the devmap removal stuff.

While removing support for CoW PFNMAPs is a noble goal, I am not even sure if we can remove said support for e.g., /dev/mem that easily.

In the end, Cow PFNMAPs are pretty simple: everything is "special" except CoW'ed anon folios, that are "normal".

The only complication is: how to identify such pages without pte_special(). Because with pte_special(), it's easy.

Well, of course, one day all architectures might support pte_special() ... either because we added support for pte_special() or removed support for ... these architectures from Linux.

No need to wait for that day. Let's do some cleanups around vm_normal_page()/vm_normal_page_pmd() and handling of the huge zero folio, and remove the "horrible special case to handle copy-on-write behaviour" that does questionable things in remap_pfn_range() with a VMA, simply by

... looking for anonymous folios in CoW PFNMAPs to identify anonymous folios? I know, sounds crazy ;)

Of course, we add sanity checks that nobody dares installing PFNMAPs of anonymous folios in these configs, that could trick us in assuming that these are due to CoW.

We only have to do that without support for pte_special(); for architectures that support pte_special(), nothing changes.

In the same process, add vm_normal_page_pud(), which is easy after the cleanups, and improve our documentation. Well, and clarify that "vm_ops->find_special_page" XEN thingy.

Briefly tested on UML (making sure vm_normal_page() still works as expected without pte_special() support) and on x86-64 with a bunch of tests (including ndctl, and cow.c which tests the huge zero folio).

Cc Andrew Morton <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Oleksandr Tyshchenko <[email protected]>
Cc Dan Williams <[email protected]>
Cc Alistair Popple <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Jan Kara <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Zi Yan <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc "Liam R. Howlett" <[email protected]>
Cc Nico Pache <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Dev Jain <[email protected]>
Cc Barry Song <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Jann Horn <[email protected]>
Cc Pedro Falcato <[email protected]>

David Hildenbrand (14):
mm/memory: drop highest_memmap_pfn sanity check in vm_normal_page()
mm: drop highest_memmap_pfn
mm: compare pfns only if the entry is present when inserting
pfns/pages
mm/huge_memory: move more common code into insert_pmd() mm/huge_memory: move more common code into insert_pud() mm/huge_memory: support huge zero folio in vmf_insert_folio_pmd() fs/dax: use vmf_insert_folio_pmd() to insert the huge zero folio mm/huge_memory: mark PMD mappings of the huge zero folio special mm/memory: introduce is_huge_zero_pfn() and use it in
vm_normal_page_pmd()
mm/memory: factor out common code from vm_normal_page_*()
mm: remove "horrible special case to handle copy-on-write behaviour"
mm: drop addr parameter from vm_normal_*_pmd()
mm: introduce and use vm_normal_page_pud()
mm: rename vm_ops->find_special_page() to vm_ops->find_normal_page()

 drivers/xen/Kconfig              |   1 +
 drivers/xen/gntdev.c             |   5 +-
 fs/dax.c                         |  47 ++----
 fs/proc/task_mmu.c               |   6 +-
 include/linux/huge_mm.h          |  12 +-
 include/linux/mm.h               |  41 +++--
 mm/Kconfig                       |   2 +
 mm/huge_memory.c                 | 135 +++++++---------
 mm/internal.h                    |   2 -
 mm/memory.c                      | 261 ++++++++++++++++---------------
 mm/mm_init.c                     |   3 -
 mm/nommu.c                       |   1 -
 mm/pagewalk.c                    |  22 +--
 tools/testing/vma/vma_internal.h |  18 ++-
 14 files changed, 281 insertions(+), 275 deletions(-)

base-commit: 2f24ee10fe6d1959d674a4298d63b66f54508a68

Signature · 1 line
2.49.0