Intel SGX development
 help / color / mirror / Atom feed
* [PATCH 00/30] mm: make VMA page offset handling more consistent
@ 2026-06-29 12:23 Lorenzo Stoakes
  2026-06-29 12:23 ` [PATCH 01/30] mm: move vma_start_pgoff() into mm.h and clean up Lorenzo Stoakes
                   ` (29 more replies)
  0 siblings, 30 replies; 56+ messages in thread
From: Lorenzo Stoakes @ 2026-06-29 12:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Russell King, Dinh Nguyen, Simon Schuster,
	James E . J . Bottomley, Helge Deller, Jarkko Sakkinen,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	Ian Abbott, H Hartley Sweeten, Lucas Stach, David Airlie,
	Simona Vetter, Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Rob Clark, Dmitry Baryshkov, Tomi Valkeinen,
	Thierry Reding, Mikko Perttunen, Jonathan Hunter,
	Christian Koenig, Huang Rui, Ankit Agrawal, Alex Williamson,
	Alexander Viro, Christian Brauner, Dan Williams, Muchun Song,
	Oscar Salvador, David Hildenbrand, Suren Baghdasaryan,
	Liam R . Howlett, Matthew Wilcox, Marek Szyprowski,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Namhyung Kim,
	Masami Hiramatsu, Oleg Nesterov, Steven Rostedt, SeongJae Park,
	Miaohe Lin, Hugh Dickins, Mike Rapoport, Kees Cook, Paolo Bonzini,
	linux-kernel, linux-arm-kernel, linux-parisc, linux-sgx, etnaviv,
	dri-devel, linux-arm-msm, freedreno, linux-tegra, kvm,
	linux-fsdevel, nvdimm, linux-mm, iommu, linux-perf-users,
	linux-trace-kernel, kasan-dev, damon, Pedro Falcato, Rik van Riel,
	Harry Yoo, Jann Horn

This series performs a series of cleanups and improvements around how the
vma->vm_pgoff field is used.

Folios belonging to file-backed mappings are simply indexed by the page
offset within the file they map.

However, anonymous folios belonging to pure anonymous mappings are indexed
by their "virtual" page offset, which is equal to addr >> PAGE_SHIFT at the
time at which the VMA was first faulted in.

The page offset of a VMA is stored in vma->vm_pgoff and indicates the page
offset of the start of the VMA range, whether it be file-backed or
anonymous.

The work here both cleans up how we reference this field, as well as laying
the foundations for a future series which addresses the inconsistency of
CoW'd folios in MAP_PRIVATE-file backed mappings, which are indexed as if
they were file-backed but behave as if they were anonymous.

This future series will make it such that all anonymous folios are indexed
by virtual page offset whether belonging to VMAs who satisfy
vma_is_anonymous() or MAP_PRIVATE-mapped file-backed mappings.

This series:

* Exposes vma_start_pgoff() and updates the kernel to use it consistently.
* Adds and uses the useful vma_end_pgoff() helper.
* Parameterises the file-backed mapping helpers vma_interval_tree_*()
  by adress_space rather than rb_root_cached.
* Renames the misleadingly-named vma_interval_tree_*() helpers to
  mapping_interval_tree_*() to be consistent with
  anon_vma_interval_tree_*().
* Parameterises anon_vma_interval_tree_*() by anon_vma.
* Moves mm/interval_tree.c to the rmap section.
* Adds vmg_*() helpers for page offset.
* Clarifies the confusing vmg_adjust_set_range() function.
* Introduces linear_page_delta() to provide relative pgoff within a VMA.
* Replaces open-coded versions of linear_page_delta() and
  linear_page_index() with invocations of these functions.
* Introduces and uses vma_assert_can_modify() to account for whether a VMA
  can be modified (detached or write locked).
* Adds and uses vma_[add,sub]_pgoff() to adjust VMA page offset.
* Moves __install_special_mapping() to vma.c.
* Makes vma_set_range() static and internal to vma.c.
* Introduces and makes use of vma_set_pgoff().
* Fixes incorrect vma.h header inclusion.
* Defaults VMA userland tests to 64-bit vma flags size.
* Updates VMA userland tests to give better output on failure.
* Various smaller cleanups.

Lorenzo Stoakes (30):
  mm: move vma_start_pgoff() into mm.h and clean up
  mm: add kdoc comments for vma_start/last_pgoff()
  tools/testing/vma: use vma_start_pgoff() in merge tests
  mm: introduce and use vma_end_pgoff()
  mm/rmap: update mm/interval_tree.c comments
  mm/rmap: parameterise vma_interval_tree_*() by address_space
  mm/rmap: elide unnecessary static inline's in interval_tree.c
  mm/rmap: rename vma_interval_tree_*() to mapping_interval_tree_*()
  mm/rmap: parameterise anon_vma_interval_tree_*() by anon_vma
  MAINTAINERS: Move mm/interval_tree.c to rmap section
  mm/vma: introduce and use vmg_pages(), vmg_[start, end]_pgoff()
  mm/vma: clean up anon_vma_compatible()
  mm/vma: refactor vmg_adjust_set_range() for clarity
  mm/vma: minor cleanup of expand_[upwards, downwards]()
  mm: introduce and use linear_page_delta()
  mm/vma: use vma_start_pgoff(), linear_page_index() in mm code
  mm: prefer vma_[start,end]_pgoff() to vma->vm_pgoff in kernel/
  mm/vma: remove duplicative vma_pgoff_offset() helper
  mm: use linear_page_[index, delta]() consistently
  mm/vma: introduce vma_assert_can_modify()
  mm/vma: add and use vma_[add/sub]_pgoff()
  mm/vma: move __install_special_mapping() to vma.c
  mm/vma: make vma_set_range() static, drop insert_vm_struct() decl
  mm/vma: update vma_shrink() to not pass unnecessary pgoff parameter
  mm/vma: update vmg_adjust_set_range() to offset pgoff instead
  mm/vma: introduce and use vma_set_pgoff()
  mm/vma: correct incorrect vma.h inclusion
  mm/vma: use guard clauses in can_vma_merge_[before, after]()
  tools/testing/vma: default VMA flag bits to 64-bit
  tools/testing/vma: output compared expression on ASSERT_[EQ, NE]()

 MAINTAINERS                           |   2 +-
 arch/arm/mm/fault-armv.c              |   4 +-
 arch/arm/mm/flush.c                   |   2 +-
 arch/nios2/mm/cacheflush.c            |   2 +-
 arch/parisc/kernel/cache.c            |   2 +-
 arch/x86/kernel/cpu/sgx/virt.c        |   3 +-
 drivers/comedi/comedi_fops.c          |   3 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem.c |   3 +-
 drivers/gpu/drm/gma500/gem.c          |   2 +-
 drivers/gpu/drm/msm/msm_gem.c         |   3 +-
 drivers/gpu/drm/omapdrm/omap_gem.c    |   5 +-
 drivers/gpu/drm/tegra/gem.c           |   3 +-
 drivers/gpu/drm/ttm/ttm_bo_vm.c       |   7 +-
 drivers/vfio/pci/nvgrace-gpu/main.c   |   3 +-
 drivers/vfio/pci/vfio_pci_core.c      |   3 +-
 fs/dax.c                              |   2 +-
 fs/hugetlbfs/inode.c                  |  15 +-
 include/linux/huge_mm.h               |   1 +
 include/linux/hugetlb.h               |   3 +-
 include/linux/mm.h                    | 118 +++++++++----
 include/linux/mmap_lock.h             |   8 +
 include/linux/pagemap.h               |  39 ++++-
 kernel/dma/coherent.c                 |   7 +-
 kernel/dma/direct.c                   |   6 +-
 kernel/dma/mapping.c                  |   8 +-
 kernel/dma/ops_helpers.c              |   4 +-
 kernel/events/core.c                  |  20 ++-
 kernel/events/uprobes.c               |  13 +-
 kernel/kcov.c                         |   2 +-
 kernel/trace/ring_buffer.c            |   3 +-
 mm/damon/vaddr.c                      |   5 +-
 mm/debug.c                            |   2 +-
 mm/filemap.c                          |   7 +-
 mm/huge_memory.c                      |   2 +-
 mm/hugetlb.c                          |  15 +-
 mm/internal.h                         |  33 ++--
 mm/interval_tree.c                    | 113 +++++++-----
 mm/khugepaged.c                       |   7 +-
 mm/ksm.c                              |   7 +-
 mm/madvise.c                          |   6 +-
 mm/mapping_dirty_helpers.c            |   2 +-
 mm/memory-failure.c                   |  10 +-
 mm/memory.c                           |  33 ++--
 mm/mempolicy.c                        |  13 +-
 mm/mmap.c                             |  41 +----
 mm/mmu_notifier.c                     |   2 +-
 mm/mremap.c                           |  12 +-
 mm/msync.c                            |   4 +-
 mm/nommu.c                            |  22 +--
 mm/pagewalk.c                         |   6 +-
 mm/rmap.c                             |  14 +-
 mm/shmem.c                            |   9 +-
 mm/userfaultfd.c                      |   4 +-
 mm/util.c                             |   4 +-
 mm/vma.c                              | 239 ++++++++++++++++++--------
 mm/vma.h                              |  59 ++++++-
 mm/vma_exec.c                         |  12 +-
 mm/vma_init.c                         |   6 +-
 mm/vma_internal.h                     |   4 +-
 tools/testing/vma/Makefile            |   2 +-
 tools/testing/vma/include/dup.h       |  41 ++++-
 tools/testing/vma/include/stubs.h     |  12 +-
 tools/testing/vma/shared.c            |   9 -
 tools/testing/vma/shared.h            |  36 ++--
 tools/testing/vma/tests/merge.c       |  40 ++---
 virt/kvm/guest_memfd.c                |   2 +-
 66 files changed, 699 insertions(+), 432 deletions(-)

--
2.54.0

^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2026-06-30 16:22 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 12:23 [PATCH 00/30] mm: make VMA page offset handling more consistent Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 01/30] mm: move vma_start_pgoff() into mm.h and clean up Lorenzo Stoakes
2026-06-29 15:27   ` Gregory Price
2026-06-30 16:10   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 02/30] mm: add kdoc comments for vma_start/last_pgoff() Lorenzo Stoakes
2026-06-29 15:31   ` Gregory Price
2026-06-30 16:11   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 03/30] tools/testing/vma: use vma_start_pgoff() in merge tests Lorenzo Stoakes
2026-06-29 15:40   ` Gregory Price
2026-06-29 16:35     ` Lorenzo Stoakes
2026-06-30 16:12   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 04/30] mm: introduce and use vma_end_pgoff() Lorenzo Stoakes
2026-06-29 15:54   ` Gregory Price
2026-06-30 16:13   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 05/30] mm/rmap: update mm/interval_tree.c comments Lorenzo Stoakes
2026-06-29 16:01   ` Gregory Price
2026-06-29 16:41     ` Lorenzo Stoakes
2026-06-29 17:11       ` Gregory Price
2026-06-29 17:40         ` Lorenzo Stoakes
2026-06-30 16:16   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 06/30] mm/rmap: parameterise vma_interval_tree_*() by address_space Lorenzo Stoakes
2026-06-30 16:19   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 07/30] mm/rmap: elide unnecessary static inline's in interval_tree.c Lorenzo Stoakes
2026-06-30 15:30   ` Gregory Price
2026-06-30 16:22   ` Pedro Falcato
2026-06-29 12:23 ` [PATCH 08/30] mm/rmap: rename vma_interval_tree_*() to mapping_interval_tree_*() Lorenzo Stoakes
2026-06-30 15:42   ` Gregory Price
2026-06-29 12:23 ` [PATCH 09/30] mm/rmap: parameterise anon_vma_interval_tree_*() by anon_vma Lorenzo Stoakes
2026-06-30 15:46   ` Gregory Price
2026-06-30 15:49     ` Lorenzo Stoakes
2026-06-30 15:55       ` Gregory Price
2026-06-30 15:59         ` Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 10/30] MAINTAINERS: Move mm/interval_tree.c to rmap section Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 11/30] mm/vma: introduce and use vmg_pages(), vmg_[start, end]_pgoff() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 12/30] mm/vma: clean up anon_vma_compatible() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 13/30] mm/vma: refactor vmg_adjust_set_range() for clarity Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 14/30] mm/vma: minor cleanup of expand_[upwards, downwards]() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 15/30] mm: introduce and use linear_page_delta() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 16/30] mm/vma: use vma_start_pgoff(), linear_page_index() in mm code Lorenzo Stoakes
2026-06-30  0:11   ` SJ Park
2026-06-29 12:23 ` [PATCH 17/30] mm: prefer vma_[start,end]_pgoff() to vma->vm_pgoff in kernel/ Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 18/30] mm/vma: remove duplicative vma_pgoff_offset() helper Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 19/30] mm: use linear_page_[index, delta]() consistently Lorenzo Stoakes
2026-06-29 13:56   ` Thomas Zimmermann
2026-06-29 14:56     ` Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 20/30] mm/vma: introduce vma_assert_can_modify() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 21/30] mm/vma: add and use vma_[add/sub]_pgoff() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 22/30] mm/vma: move __install_special_mapping() to vma.c Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 23/30] mm/vma: make vma_set_range() static, drop insert_vm_struct() decl Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 24/30] mm/vma: update vma_shrink() to not pass unnecessary pgoff parameter Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 25/30] mm/vma: update vmg_adjust_set_range() to offset pgoff instead Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 26/30] mm/vma: introduce and use vma_set_pgoff() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 27/30] mm/vma: correct incorrect vma.h inclusion Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 28/30] mm/vma: use guard clauses in can_vma_merge_[before, after]() Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 29/30] tools/testing/vma: default VMA flag bits to 64-bit Lorenzo Stoakes
2026-06-29 12:23 ` [PATCH 30/30] tools/testing/vma: output compared expression on ASSERT_[EQ, NE]() Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox