All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] mm: Add vma_lookup()
@ 2021-05-10 16:58 Liam Howlett
  2021-05-10 16:58 ` [PATCH 03/22] arch/arc/kernel/troubleshoot: use vma_lookup() instead of find_vma() Liam Howlett
                   ` (23 more replies)
  0 siblings, 24 replies; 32+ messages in thread
From: Liam Howlett @ 2021-05-10 16:58 UTC (permalink / raw)
  To: maple-tree, linux-mm, linux-kernel, Andrew Morton
  Cc: Song Liu, Davidlohr Bueso, Paul E . McKenney, Matthew Wilcox,
	Laurent Dufour, David Rientjes, Axel Rasmussen,
	Suren Baghdasaryan, Vlastimil Babka, Rik van Riel,
	Peter Zijlstra, Michel Lespinasse, Liam Howlett

Many places in the kernel use find_vma() to get a vma and then check the
start address of the vma to ensure the next vma was not returned.

Other places use the find_vma_intersection() call with add, addr + 1 as
the range; looking for just the vma at a specific address.

The third use of find_vma() is by developers who do not know that the
function starts searching at the provided address upwards for the next
vma.  This results in a bug that is often overlooked for a long time.

Adding the new vma_lookup() function will allow for cleaner code by
removing the find_vma() calls which check limits, making
find_vma_intersection() calls of a single address to be shorter, and
potentially reduce the incorrect uses of find_vma().

This patch set was originally part of the maple tree patch set.
Changes since being broken out on its own:
- Changed initial implementation of vma_lookup() to use find_vma() as requested
  by Michel Lespinasse.
- Updated commit comments to be more descriptive

These patches are based on next-20210506

Liam R. Howlett (22):
  mm: Add vma_lookup()
  drm/i915/selftests: Use vma_lookup() in __igt_mmap()
  arch/arc/kernel/troubleshoot: use vma_lookup() instead of find_vma()
  arch/arm64/kvm: Use vma_lookup() instead of find_vma_intersection()
  arch/powerpc/kvm/book3s_hv_uvmem: Use vma_lookup() instead of
    find_vma_intersection()
  arch/powerpc/kvm/book3s: Use vma_lookup() in
    kvmppc_hv_setup_htab_rma()
  arch/mips/kernel/traps: Use vma_lookup() instead of find_vma()
  arch/m68k/kernel/sys_m68k: Use vma_lookup() in sys_cacheflush()
  x86/sgx: Use vma_lookup() in sgx_encl_find()
  virt/kvm: Use vma_lookup() instead of find_vma_intersection()
  vfio: Use vma_lookup() instead of find_vma_intersection()
  net/ipv5/tcp: Use vma_lookup() in tcp_zerocopy_receive()
  drm/amdgpu: Use vma_lookup() in amdgpu_ttm_tt_get_user_pages()
  media: videobuf2: Use vma_lookup() in get_vaddr_frames()
  misc/sgi-gru/grufault: Use vma_lookup() in gru_find_vma()
  kernel/events/uprobes: Use vma_lookup() in find_active_uprobe()
  lib/test_hmm: Use vma_lookup() in dmirror_migrate()
  mm/ksm: Use vma_lookup() in find_mergeable_vma()
  mm/migrate: Use vma_lookup() in do_pages_stat_array()
  mm/mremap: Use vma_lookup() in vma_to_resize()
  mm/memory.c: Use vma_lookup() in __access_remote_vm()
  mm/mempolicy: Use vma_lookup() in __access_remote_vm()

 arch/arc/kernel/troubleshoot.c                 |  8 ++++----
 arch/arm64/kvm/mmu.c                           |  2 +-
 arch/m68k/kernel/sys_m68k.c                    |  4 ++--
 arch/mips/kernel/traps.c                       |  4 +---
 arch/powerpc/kvm/book3s_hv.c                   |  4 ++--
 arch/powerpc/kvm/book3s_hv_uvmem.c             |  2 +-
 arch/x86/kernel/cpu/sgx/encl.h                 |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c        |  4 ++--
 .../gpu/drm/i915/gem/selftests/i915_gem_mman.c |  2 +-
 drivers/media/common/videobuf2/frame_vector.c  |  2 +-
 drivers/misc/sgi-gru/grufault.c                |  4 ++--
 drivers/vfio/vfio_iommu_type1.c                |  2 +-
 include/linux/mm.h                             | 18 ++++++++++++++++++
 kernel/events/uprobes.c                        |  4 ++--
 lib/test_hmm.c                                 |  5 ++---
 mm/ksm.c                                       |  6 ++----
 mm/memory.c                                    |  4 ++--
 mm/mempolicy.c                                 |  2 +-
 mm/migrate.c                                   |  4 ++--
 mm/mremap.c                                    |  4 ++--
 net/ipv4/tcp.c                                 |  4 ++--
 virt/kvm/kvm_main.c                            |  2 +-
 22 files changed, 54 insertions(+), 41 deletions(-)

-- 
2.30.2

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

end of thread, other threads:[~2021-05-21 14:28 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 16:58 [PATCH 00/21] mm: Add vma_lookup() Liam Howlett
2021-05-10 16:58 ` [PATCH 03/22] arch/arc/kernel/troubleshoot: use vma_lookup() instead of find_vma() Liam Howlett
2021-05-10 16:58 ` [PATCH 01/22] mm: Add vma_lookup() Liam Howlett
2021-05-14  9:57   ` David Hildenbrand
2021-05-21  3:32   ` Davidlohr Bueso
2021-05-21 14:24     ` Liam Howlett
2021-05-10 16:58 ` [PATCH 02/22] drm/i915/selftests: Use vma_lookup() in __igt_mmap() Liam Howlett
2021-05-10 16:58 ` [PATCH 04/22] arch/arm64/kvm: Use vma_lookup() instead of find_vma_intersection() Liam Howlett
2021-05-10 16:58 ` [PATCH 05/22] arch/powerpc/kvm/book3s_hv_uvmem: " Liam Howlett
2021-05-10 16:58 ` [PATCH 06/22] arch/powerpc/kvm/book3s: Use vma_lookup() in kvmppc_hv_setup_htab_rma() Liam Howlett
2021-05-10 16:58 ` [PATCH 08/22] arch/m68k/kernel/sys_m68k: Use vma_lookup() in sys_cacheflush() Liam Howlett
2021-05-11  7:15   ` Geert Uytterhoeven
2021-05-11  7:15     ` Geert Uytterhoeven
2021-05-10 16:58 ` [PATCH 07/22] arch/mips/kernel/traps: Use vma_lookup() instead of find_vma() Liam Howlett
2021-05-10 16:58 ` [PATCH 09/22] x86/sgx: Use vma_lookup() in sgx_encl_find() Liam Howlett
2021-05-10 16:58 ` [PATCH 11/22] vfio: Use vma_lookup() instead of find_vma_intersection() Liam Howlett
2021-05-10 16:58 ` [PATCH 10/22] virt/kvm: " Liam Howlett
2021-05-10 16:58 ` [PATCH 12/22] net/ipv5/tcp: Use vma_lookup() in tcp_zerocopy_receive() Liam Howlett
2021-05-10 16:58 ` [PATCH 13/22] drm/amdgpu: Use vma_lookup() in amdgpu_ttm_tt_get_user_pages() Liam Howlett
2021-05-10 16:58 ` [PATCH 14/22] media: videobuf2: Use vma_lookup() in get_vaddr_frames() Liam Howlett
2021-05-10 16:58 ` [PATCH 16/22] kernel/events/uprobes: Use vma_lookup() in find_active_uprobe() Liam Howlett
2021-05-10 16:58 ` [PATCH 15/22] misc/sgi-gru/grufault: Use vma_lookup() in gru_find_vma() Liam Howlett
2021-05-10 16:58 ` [PATCH 18/22] mm/ksm: Use vma_lookup() in find_mergeable_vma() Liam Howlett
2021-05-10 16:58 ` [PATCH 17/22] lib/test_hmm: Use vma_lookup() in dmirror_migrate() Liam Howlett
2021-05-10 16:58 ` [PATCH 20/22] mm/mremap: Use vma_lookup() in vma_to_resize() Liam Howlett
2021-05-21  3:47   ` Davidlohr Bueso
2021-05-21 14:27     ` Liam Howlett
2021-05-10 16:58 ` [PATCH 19/22] mm/migrate: Use vma_lookup() in do_pages_stat_array() Liam Howlett
2021-05-10 16:58 ` [PATCH 22/22] mm/mempolicy: Use vma_lookup() in __access_remote_vm() Liam Howlett
2021-05-10 16:58 ` [PATCH 21/22] mm/memory.c: " Liam Howlett
2021-05-17 17:28 ` [PATCH 00/21] mm: Add vma_lookup() Laurent Dufour
2021-05-21  4:20 ` Davidlohr Bueso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.