Add a new mmap locking API wrapping mmap_sem calls
Subsystems (107)
v6 cover Add a new mmap locking API wrapping mmap_sem calls
Reposting this patch series on top of v5.7-rc6. I think this is ready for inclusion into the -mm tree; however there were some minor points of feedback to address and also it was easier to regenerate a full version after the v5.5 (only updating patches 09/10 and 10/10) caused some confusion.
This patch series adds a new mmap locking API replacing the existing mmap_sem lock and unlocks. Initially the API is just implemente in terms of inlined rwsem calls, so it doesn't provide any new functionality.
There are two justifications for the new API:
- At first, it provides an easy hooking point to instrument mmap_sem locking latencies independently of any other rwsems.
- In the future, it may be a starting point for replacing the rwsem implementation with a different one, such as range locks. This is something that is being explored, even though there is no wide concensus about this possible direction yet.
(see https://patchwork.kernel.org/cover/11401483/)
Changes since v5.5 of the patchset:
- Applied the changes on top of v5.7-rc6. This was a straight rebase except for the changes noted here.
- Re-generated the coccinelle changes (patch 04/12).
- Patch 08/12: use (name) in the MMAP_LOCK_INITIALIZER macro.
- Patch 09/12: use lockdep_assert_held() / lockdep_assert_held_write() so that mmap_assert_locked() and mmap_assert_write_locked() get better coverage when lockdep is enabled but CONFIG_DEBUG_VM is not.
- Added patches 11 and 12, converting comments that referenced mmap_sem rwsem calls or the mmap_sem lock itself, to reference the corresponding mmap locking APIs or the mmap_lock itself.
Changes since v5 of the patchset:
- Patch 09/10: Add both mmap_assert_locked() and mmap_assert_write_locked(); convert some call sites that were using lockdep assertions to use these new APIs instead.
Changes since v4 of the patchset:
- Applied the changes on top of v5.7-rc2. This was a straight rebase except for changes noted here.
- Patch 01/10: renamed the mmap_write_downgrade API (as suggested by Davidlohr Bueso).
- Patch 05/10: added arch/riscv/mm/pageattr.c changes that had been previously missed, as found by the kbuild bot.
- Patch 06/10: use SINGLE_DEPTH_NESTING as suggested by Matthew Wilcox.
- Patch 08/10: change MMAP_LOCK_INITIALIZER definition as suggested by Matthew Wilcox.
- Patch 09/10: add mm_assert_locked API as suggested by Matthew Wilcox.
Changes since v3 of the patchset:
- The changes now apply on top of v5.7-rc1. This was a straight rebase except for changes noted here.
- Re-generated the coccinelle changes (patch 04/10).
- Patch 06/10: removed the mmap_write_unlock_nested API; mmap_write_lock_nested() calls now pair with the regular mmap_write_unlock() as was suggested by many people.
- Patch 07/10: removed the mmap_read_release API; this is replaced with mmap_read_trylock_non_owner() which pairs with mmap_read_unlock_non_owner() Thanks to Peter Zijlstra for the suggestion.
Changes since v2 of the patchset:
- Removed the mmap_is_locked API - v2 had removed all uses of it, but the actual function definition was still there unused. Thanks to Jason Gunthorpe for noticing the unused mmap_is_locked function.
Changes since v1 of the patchset:
- Manually convert drivers/dma-buf/dma-resv.c ahead of the automated coccinelle conversion as this file requires a new include statement. Thanks to Intel's kbuild test bot for finding the issue.
- In coccinelle automated conversion, apply a single coccinelle rule as suggested by Markus Elfring.
- In manual conversion of sites missed by coccinelle, fix an issue where I had used mm_read_unlock (from an older version of my patchset) instead of mmap_read_unlock in some arch/mips code.
This was also identified by Intel's kbuild test bot.
- Do not add a new mmap_is_locked API, and use lockdep_assert_held instead. Thanks to Jason Gunthorpe and Matthew Wilcox for the suggestion.
The changes apply on top of v5.7-rc6.
I think these changes are ready for integration into the -mm tree now (for integration into v5.8). The coccinelle part of the change is relatively invasive, but can be skipped over on a file by file basis if it causes any conflicts with other pending changes. The new mmap locking API can interoperate with new code that is still using direct rwsem calls, until the last patch in the series which renames mmap_sem to enforce using the new API. Maybe that last patch could be delayed for a bit, so that we'd get a chance to convert any new code that locks mmap_sem in the -rc1 release before applying that last patch.
Michel Lespinasse (12):
mmap locking API: initial implementation as rwsem wrappers MMU notifier: use the new mmap locking API
DMA reservations: use the new mmap locking API
mmap locking API: use coccinelle to convert mmap_sem rwsem call sites mmap locking API: convert mmap_sem call sites missed by coccinelle mmap locking API: convert nested write lock sites
mmap locking API: add mmap_read_trylock_non_owner()
mmap locking API: add MMAP_LOCK_INITIALIZER
mmap locking API: add mmap_assert_locked() and
mmap_assert_write_locked()
mmap locking API: rename mmap_sem to mmap_lock
mmap locking API: convert mmap_sem API comments
mmap locking API: convert mmap_sem comments
.../admin-guide/mm/numa_memory_policy.rst | 10 +-- Documentation/admin-guide/mm/userfaultfd.rst | 2 +- Documentation/filesystems/locking.rst | 2 +- Documentation/vm/hmm.rst | 6 +- Documentation/vm/transhuge.rst | 4 +- arch/alpha/kernel/traps.c | 4 +- arch/alpha/mm/fault.c | 12 +-- arch/arc/kernel/process.c | 4 +- arch/arc/kernel/troubleshoot.c | 4 +- arch/arc/mm/fault.c | 6 +- arch/arm/kernel/process.c | 4 +- arch/arm/kernel/swp_emulate.c | 4 +- arch/arm/kernel/vdso.c | 2 +- arch/arm/lib/uaccess_with_memcpy.c | 16 ++-- arch/arm/mm/fault.c | 8 +- arch/arm64/kernel/traps.c | 4 +- arch/arm64/kernel/vdso.c | 8 +- arch/arm64/mm/fault.c | 8 +- arch/csky/kernel/vdso.c | 4 +- arch/csky/mm/fault.c | 8 +- arch/hexagon/kernel/vdso.c | 4 +- arch/hexagon/mm/vm_fault.c | 8 +- arch/ia64/kernel/perfmon.c | 8 +- arch/ia64/mm/fault.c | 16 ++-- arch/ia64/mm/init.c | 12 +-- arch/m68k/kernel/sys_m68k.c | 14 +-- arch/m68k/mm/fault.c | 10 +-- arch/microblaze/mm/fault.c | 16 ++-- arch/mips/kernel/traps.c | 4 +- arch/mips/kernel/vdso.c | 4 +- arch/mips/mm/fault.c | 12 +-- arch/nds32/kernel/vdso.c | 6 +- arch/nds32/mm/fault.c | 16 ++-- arch/nios2/mm/fault.c | 14 +-- arch/nios2/mm/init.c | 4 +- arch/openrisc/mm/fault.c | 12 +-- arch/parisc/kernel/traps.c | 6 +- arch/parisc/mm/fault.c | 10 +-- arch/powerpc/include/asm/pkeys.h | 2 +- arch/powerpc/kernel/vdso.c | 6 +- arch/powerpc/kvm/book3s_hv.c | 6 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 18 ++-- arch/powerpc/kvm/e500_mmu_host.c | 4 +- arch/powerpc/mm/book3s32/tlb.c | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 +- arch/powerpc/mm/book3s64/iommu_api.c | 4 +- arch/powerpc/mm/book3s64/subpage_prot.c | 14 +-- arch/powerpc/mm/copro_fault.c | 4 +- arch/powerpc/mm/fault.c | 20 ++--- arch/powerpc/mm/pgtable.c | 2 +- arch/powerpc/oprofile/cell/spu_task_sync.c | 6 +- arch/powerpc/platforms/cell/spufs/file.c | 10 +-- arch/riscv/kernel/vdso.c | 4 +- arch/riscv/mm/fault.c | 14 +-- arch/riscv/mm/pageattr.c | 4 +- arch/s390/kernel/uv.c | 4 +- arch/s390/kernel/vdso.c | 4 +- arch/s390/kvm/gaccess.c | 4 +- arch/s390/kvm/interrupt.c | 4 +- arch/s390/kvm/kvm-s390.c | 28 +++--- arch/s390/kvm/priv.c | 34 +++---- arch/s390/mm/fault.c | 16 ++-- arch/s390/mm/gmap.c | 76 ++++++++-------- arch/s390/mm/pgalloc.c | 2 +- arch/s390/pci/pci_mmio.c | 4 +- arch/sh/kernel/sys_sh.c | 6 +- arch/sh/kernel/vsyscall/vsyscall.c | 4 +- arch/sh/mm/cache-sh4.c | 2 +- arch/sh/mm/fault.c | 14 +-- arch/sparc/mm/fault_32.c | 20 ++--- arch/sparc/mm/fault_64.c | 16 ++-- arch/sparc/vdso/vma.c | 4 +- arch/um/include/asm/mmu_context.h | 5 +- arch/um/kernel/skas/mmu.c | 2 +- arch/um/kernel/tlb.c | 4 +- arch/um/kernel/trap.c | 6 +- arch/unicore32/mm/fault.c | 8 +- arch/x86/entry/vdso/vma.c | 14 +-- arch/x86/events/core.c | 4 +- arch/x86/include/asm/mmu.h | 2 +- arch/x86/include/asm/pgtable-3level.h | 8 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 +- arch/x86/kernel/ldt.c | 2 +- arch/x86/kernel/tboot.c | 2 +- arch/x86/kernel/vm86_32.c | 4 +- arch/x86/kvm/mmu/paging_tmpl.h | 8 +- arch/x86/mm/fault.c | 22 ++--- arch/x86/um/vdso/vma.c | 4 +- arch/xtensa/mm/fault.c | 12 +-- drivers/android/binder_alloc.c | 14 +-- drivers/char/mspec.c | 2 +- drivers/dma-buf/dma-resv.c | 5 +- drivers/firmware/efi/efi.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +-- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 4 +- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 14 +-- drivers/gpu/drm/i915/i915_perf.c | 2 +- drivers/gpu/drm/nouveau/nouveau_svm.c | 22 ++--- drivers/gpu/drm/radeon/radeon_cs.c | 4 +- drivers/gpu/drm/radeon/radeon_gem.c | 6 +- drivers/gpu/drm/ttm/ttm_bo_vm.c | 10 +-- drivers/infiniband/core/umem_odp.c | 4 +- drivers/infiniband/core/uverbs_main.c | 6 +- drivers/infiniband/hw/hfi1/mmu_rb.c | 2 +- drivers/infiniband/hw/mlx4/mr.c | 4 +- drivers/infiniband/hw/qib/qib_user_pages.c | 6 +- drivers/infiniband/hw/usnic/usnic_uiom.c | 4 +- drivers/infiniband/sw/siw/siw_mem.c | 4 +- drivers/iommu/amd_iommu_v2.c | 4 +- drivers/iommu/intel-svm.c | 4 +- drivers/media/v4l2-core/videobuf-core.c | 4 +- drivers/media/v4l2-core/videobuf-dma-contig.c | 4 +- drivers/media/v4l2-core/videobuf-dma-sg.c | 6 +- drivers/misc/cxl/cxllib.c | 6 +- drivers/misc/cxl/fault.c | 4 +- drivers/misc/sgi-gru/grufault.c | 24 ++--- drivers/misc/sgi-gru/grufile.c | 4 +- drivers/oprofile/buffer_sync.c | 12 +-- drivers/staging/android/ashmem.c | 4 +- drivers/staging/comedi/comedi_fops.c | 2 +- drivers/staging/kpc2000/kpc_dma/fileops.c | 4 +- drivers/tee/optee/call.c | 4 +- drivers/tty/vt/consolemap.c | 2 +- drivers/vfio/vfio_iommu_type1.c | 8 +- drivers/vhost/vdpa.c | 4 +- drivers/xen/gntdev.c | 6 +- drivers/xen/privcmd.c | 14 +-- fs/aio.c | 4 +- fs/coredump.c | 8 +- fs/exec.c | 18 ++-- fs/ext2/file.c | 2 +- fs/ext4/super.c | 6 +- fs/hugetlbfs/inode.c | 2 +- fs/io_uring.c | 4 +- fs/kernfs/file.c | 4 +- fs/proc/base.c | 24 ++--- fs/proc/task_mmu.c | 34 +++---- fs/proc/task_nommu.c | 18 ++-- fs/userfaultfd.c | 46 +++++----- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_inode.c | 14 +-- fs/xfs/xfs_iops.c | 4 +- include/asm-generic/pgtable.h | 6 +- include/linux/fs.h | 4 +- include/linux/huge_mm.h | 2 +- include/linux/mempolicy.h | 2 +- include/linux/mm.h | 11 +-- include/linux/mm_types.h | 4 +- include/linux/mmap_lock.h | 90 +++++++++++++++++++ include/linux/mmu_notifier.h | 13 +-- include/linux/pagemap.h | 2 +- include/linux/rmap.h | 2 +- include/linux/sched/mm.h | 10 +-- ipc/shm.c | 8 +- kernel/acct.c | 6 +- kernel/bpf/stackmap.c | 17 ++-- kernel/cgroup/cpuset.c | 4 +- kernel/events/core.c | 10 +-- kernel/events/uprobes.c | 20 ++--- kernel/exit.c | 10 +-- kernel/fork.c | 14 +-- kernel/futex.c | 4 +- kernel/relay.c | 2 +- kernel/sched/fair.c | 4 +- kernel/sys.c | 22 ++--- kernel/trace/trace_output.c | 4 +- lib/test_lockup.c | 16 ++-- mm/filemap.c | 46 +++++----- mm/frame_vector.c | 6 +- mm/gup.c | 70 +++++++-------- mm/hmm.c | 2 +- mm/huge_memory.c | 8 +- mm/hugetlb.c | 2 +- mm/init-mm.c | 2 +- mm/internal.h | 6 +- mm/khugepaged.c | 72 +++++++-------- mm/ksm.c | 48 +++++----- mm/maccess.c | 4 +- mm/madvise.c | 40 ++++----- mm/memcontrol.c | 10 +-- mm/memory.c | 60 ++++++------- mm/mempolicy.c | 36 ++++---- mm/migrate.c | 16 ++-- mm/mincore.c | 4 +- mm/mlock.c | 22 ++--- mm/mmap.c | 74 +++++++-------- mm/mmu_gather.c | 2 +- mm/mmu_notifier.c | 22 ++--- mm/mprotect.c | 20 ++--- mm/mremap.c | 14 +-- mm/msync.c | 8 +- mm/nommu.c | 22 ++--- mm/oom_kill.c | 14 +-- mm/pagewalk.c | 12 +-- mm/process_vm_access.c | 4 +- mm/ptdump.c | 4 +- mm/rmap.c | 12 +-- mm/shmem.c | 4 +- mm/swap_state.c | 4 +- mm/swapfile.c | 4 +- mm/userfaultfd.c | 26 +++--- mm/util.c | 12 +-- net/ipv4/tcp.c | 8 +- net/xdp/xdp_umem.c | 4 +- security/keys/keyctl.c | 2 +- sound/core/oss/pcm_oss.c | 2 +- virt/kvm/arm/mmu.c | 14 +-- virt/kvm/async_pf.c | 4 +- virt/kvm/kvm_main.c | 8 +- 216 files changed, 1178 insertions(+), 1091 deletions(-) create mode 100644 include/linux/mmap_lock.h
base-commit: b9bbe6ed63b2b9f2c9ee5cbd0f2c946a2723f4ce
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 1/12 mmap locking API: initial implementation as rwsem wrappers
This change wraps the existing mmap_sem related rwsem calls into a new mmap locking API. There are two justifications for the new API:
- At first, it provides an easy hooking point to instrument mmap_sem locking latencies independently of any other rwsems.
- In the future, it may be a starting point for replacing the rwsem implementation with a different one, such as range locks.
--- include/linux/mm.h | 1 + include/linux/mmap_lock.h | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 include/linux/mmap_lock.h
include/linux/mm.h +1 -0
@@ -15,6 +15,7 @@#include <linux/atomic.h> #include <linux/debug_locks.h> #include <linux/mm_types.h> +#include <linux/mmap_lock.h> #include <linux/range.h> #include <linux/pfn.h> #include <linux/percpu-refcount.h>
include/linux/mmap_lock.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 2/12 MMU notifier: use the new mmap locking API
In reply to Michel LespinasseThis use is converted manually ahead of the next patch in the series, as it requires including a new header which the automated conversion would miss.
--- include/linux/mmu_notifier.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/mmu_notifier.h +3 -2
@@ -5,6 +5,7 @@#include <linux/list.h> #include <linux/spinlock.h> #include <linux/mm_types.h> +#include <linux/mmap_lock.h> #include <linux/srcu.h> #include <linux/interval_tree.h>
@@ -277,9 +278,9 @@ mmu_notifier_get(const struct mmu_notifier_ops *ops, struct mm_struct *mm) {struct mmu_notifier *ret; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); ret =mmu_notifier_get_locked (ops, mm); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }void mmu_notifier_put (struct mmu_notifier *subscription);
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 3/12 DMA reservations: use the new mmap locking API
In reply to Michel LespinasseThis use is converted manually ahead of the next patch in the series, as it requires including a new header which the automated conversion would miss.
--- drivers/dma-buf/dma-resv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dma-buf/dma-resv.c +3 -2
@@ -34,6 +34,7 @@#include <linux/dma-resv.h> #include <linux/export.h> +#include <linux/mm.h> #include <linux/sched/mm.h> /**
@@ -109,7 +110,7 @@ static int __init dma_resv_lockdep(void)dma_resv_init (&obj); -down_read (&mm->mmap_sem); +mmap_read_lock (mm);ww_acquire_init (&ctx, &reservation_ww_class); ret =dma_resv_lock (&obj, &ctx);if (ret == -EDEADLK )
@@ -118,7 +119,7 @@ static int __init dma_resv_lockdep(void)fs_reclaim_release (GFP_KERNEL );ww_mutex_unlock (&obj.lock);ww_acquire_fini (&ctx); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 4/12 mmap locking API: use coccinelle to convert mmap_sem rwsem call sites
In reply to Michel LespinasseThis change converts the existing mmap_sem rwsem calls to use the new mmap locking API instead.
The change is generated using coccinelle with the following rule:
// spatch --sp-file mmap_lock_api.cocci --in-place --include-headers --dir .
@@
expression mm;
@@
(
-init_rwsem
+mmap_init_lock
|
-down_write
+mmap_write_lock
|
-down_write_killable
+mmap_write_lock_killable
|
-down_write_trylock
+mmap_write_trylock
|
-up_write
+mmap_write_unlock
|
-downgrade_write
+mmap_write_downgrade
|
-down_read
+mmap_read_lock
|
-down_read_killable
+mmap_read_lock_killable
|
-down_read_trylock
+mmap_read_trylock
|
-up_read
+mmap_read_unlock
)
-(&mm->mmap_sem)
+(mm)
--- arch/alpha/kernel/traps.c | 4 +- arch/alpha/mm/fault.c | 10 ++--- arch/arc/kernel/process.c | 4 +- arch/arc/kernel/troubleshoot.c | 4 +- arch/arc/mm/fault.c | 4 +- arch/arm/kernel/process.c | 4 +- arch/arm/kernel/swp_emulate.c | 4 +- arch/arm/lib/uaccess_with_memcpy.c | 16 +++---- arch/arm/mm/fault.c | 6 +-- arch/arm64/kernel/traps.c | 4 +- arch/arm64/kernel/vdso.c | 8 ++-- arch/arm64/mm/fault.c | 8 ++-- arch/csky/kernel/vdso.c | 4 +- arch/csky/mm/fault.c | 8 ++-- arch/hexagon/kernel/vdso.c | 4 +- arch/hexagon/mm/vm_fault.c | 8 ++-- arch/ia64/kernel/perfmon.c | 8 ++-- arch/ia64/mm/fault.c | 8 ++-- arch/ia64/mm/init.c | 12 ++--- arch/m68k/kernel/sys_m68k.c | 14 +++--- arch/m68k/mm/fault.c | 8 ++-- arch/microblaze/mm/fault.c | 12 ++--- arch/mips/kernel/traps.c | 4 +- arch/mips/kernel/vdso.c | 4 +- arch/nds32/kernel/vdso.c | 6 +-- arch/nds32/mm/fault.c | 12 ++--- arch/nios2/mm/fault.c | 12 ++--- arch/nios2/mm/init.c | 4 +- arch/openrisc/mm/fault.c | 10 ++--- arch/parisc/kernel/traps.c | 6 +-- arch/parisc/mm/fault.c | 8 ++-- arch/powerpc/kernel/vdso.c | 6 +-- arch/powerpc/kvm/book3s_hv.c | 6 +-- arch/powerpc/kvm/book3s_hv_uvmem.c | 12 ++--- arch/powerpc/kvm/e500_mmu_host.c | 4 +- arch/powerpc/mm/book3s64/iommu_api.c | 4 +- arch/powerpc/mm/book3s64/subpage_prot.c | 12 ++--- arch/powerpc/mm/copro_fault.c | 4 +- arch/powerpc/mm/fault.c | 12 ++--- arch/powerpc/oprofile/cell/spu_task_sync.c | 6 +-- arch/powerpc/platforms/cell/spufs/file.c | 4 +- arch/riscv/kernel/vdso.c | 4 +- arch/riscv/mm/fault.c | 10 ++--- arch/s390/kernel/uv.c | 4 +- arch/s390/kernel/vdso.c | 4 +- arch/s390/kvm/gaccess.c | 4 +- arch/s390/kvm/interrupt.c | 4 +- arch/s390/kvm/kvm-s390.c | 28 ++++++------ arch/s390/kvm/priv.c | 32 +++++++------- arch/s390/mm/fault.c | 14 +++--- arch/s390/mm/gmap.c | 44 +++++++++---------- arch/s390/pci/pci_mmio.c | 4 +- arch/sh/kernel/sys_sh.c | 6 +-- arch/sh/kernel/vsyscall/vsyscall.c | 4 +- arch/sh/mm/fault.c | 10 ++--- arch/sparc/mm/fault_32.c | 18 ++++---- arch/sparc/mm/fault_64.c | 12 ++--- arch/sparc/vdso/vma.c | 4 +- arch/um/include/asm/mmu_context.h | 2 +- arch/um/kernel/tlb.c | 2 +- arch/um/kernel/trap.c | 6 +-- arch/unicore32/mm/fault.c | 6 +-- arch/x86/entry/vdso/vma.c | 14 +++--- arch/x86/kernel/vm86_32.c | 4 +- arch/x86/mm/fault.c | 8 ++-- arch/x86/um/vdso/vma.c | 4 +- arch/xtensa/mm/fault.c | 10 ++--- drivers/android/binder_alloc.c | 10 ++--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 ++--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 +- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 ++-- drivers/gpu/drm/nouveau/nouveau_svm.c | 22 +++++----- drivers/gpu/drm/radeon/radeon_cs.c | 4 +- drivers/gpu/drm/radeon/radeon_gem.c | 6 +-- drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 +- drivers/infiniband/core/umem_odp.c | 4 +- drivers/infiniband/core/uverbs_main.c | 4 +- drivers/infiniband/hw/mlx4/mr.c | 4 +- drivers/infiniband/hw/qib/qib_user_pages.c | 6 +-- drivers/infiniband/hw/usnic/usnic_uiom.c | 4 +- drivers/infiniband/sw/siw/siw_mem.c | 4 +- drivers/iommu/amd_iommu_v2.c | 4 +- drivers/iommu/intel-svm.c | 4 +- drivers/media/v4l2-core/videobuf-core.c | 4 +- drivers/media/v4l2-core/videobuf-dma-contig.c | 4 +- drivers/media/v4l2-core/videobuf-dma-sg.c | 4 +- drivers/misc/cxl/cxllib.c | 4 +- drivers/misc/cxl/fault.c | 4 +- drivers/misc/sgi-gru/grufault.c | 16 +++---- drivers/misc/sgi-gru/grufile.c | 4 +- drivers/oprofile/buffer_sync.c | 10 ++--- drivers/staging/kpc2000/kpc_dma/fileops.c | 4 +- drivers/tee/optee/call.c | 4 +- drivers/vfio/vfio_iommu_type1.c | 8 ++-- drivers/vhost/vdpa.c | 4 +- drivers/xen/gntdev.c | 4 +- drivers/xen/privcmd.c | 14 +++--- fs/aio.c | 4 +- fs/coredump.c | 4 +- fs/exec.c | 16 +++---- fs/io_uring.c | 4 +- fs/proc/base.c | 12 ++--- fs/proc/task_mmu.c | 28 ++++++------ fs/proc/task_nommu.c | 18 ++++---- fs/userfaultfd.c | 20 ++++----- ipc/shm.c | 8 ++-- kernel/acct.c | 4 +- kernel/bpf/stackmap.c | 4 +- kernel/events/core.c | 4 +- kernel/events/uprobes.c | 16 +++---- kernel/exit.c | 8 ++-- kernel/fork.c | 12 ++--- kernel/futex.c | 4 +- kernel/sched/fair.c | 4 +- kernel/sys.c | 18 ++++---- kernel/trace/trace_output.c | 4 +- lib/test_lockup.c | 8 ++-- mm/filemap.c | 6 +-- mm/frame_vector.c | 4 +- mm/gup.c | 18 ++++---- mm/internal.h | 2 +- mm/khugepaged.c | 36 +++++++-------- mm/ksm.c | 34 +++++++------- mm/madvise.c | 20 ++++----- mm/memcontrol.c | 8 ++-- mm/memory.c | 12 ++--- mm/mempolicy.c | 22 +++++----- mm/migrate.c | 8 ++-- mm/mincore.c | 4 +- mm/mlock.c | 16 +++---- mm/mmap.c | 32 +++++++------- mm/mmu_notifier.c | 4 +- mm/mprotect.c | 12 ++--- mm/mremap.c | 6 +-- mm/msync.c | 8 ++-- mm/nommu.c | 16 +++---- mm/oom_kill.c | 4 +- mm/process_vm_access.c | 4 +- mm/ptdump.c | 4 +- mm/swapfile.c | 4 +- mm/userfaultfd.c | 18 ++++---- mm/util.c | 8 ++-- net/ipv4/tcp.c | 6 +-- net/xdp/xdp_umem.c | 4 +- virt/kvm/arm/mmu.c | 14 +++--- virt/kvm/async_pf.c | 4 +- virt/kvm/kvm_main.c | 8 ++-- 149 files changed, 652 insertions(+), 652 deletions(-)
arch/alpha/kernel/traps.c +2 -2
@@ -957,12 +957,12 @@ do_entUnaUser(void __user * va, unsigned long opcode, si_code =SEGV_ACCERR ; else {struct mm_struct *mm = current->mm; -down_read (&mm->mmap_sem); +mmap_read_lock (mm);if (find_vma (mm, (unsigned long )va)) si_code =SEGV_ACCERR ;else si_code =SEGV_MAPERR ; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); }send_sig_fault (SIGSEGV , si_code, va,0 , current);return ;
arch/alpha/mm/fault.c +5 -5
@@ -117,7 +117,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto bad_area;
@@ -180,14 +180,14 @@ do_page_fault(unsigned long address, unsigned long mmcsr, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/* Something tried to access memory that isn't in our memory map. Fix it, but check if it's kernel or user first. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (user_mode (regs)) goto do_sigsegv;
@@ -211,14 +211,14 @@ do_page_fault(unsigned long address, unsigned long mmcsr,/* We ran out of memory, or some other thing happened to us that made us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Send a sigbus, regardless of whether we were in kernel or user mode. */ force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *) address,0 );
arch/arc/kernel/process.c +2 -2
@@ -90,10 +90,10 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)if (unlikely (ret != -EFAULT )) goto fail; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); ret =fixup_user_fault (current, current->mm, (unsigned long ) uaddr,FAULT_FLAG_WRITE ,NULL ); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (likely (!ret)) goto again;
arch/arc/kernel/troubleshoot.c +2 -2
@@ -89,7 +89,7 @@ static void show_faulting_vma(unsigned long address)/* can't use print_vma_addr() yet as it doesn't check for * non-inclusive vma */ -down_read (&active_mm->mmap_sem); +mmap_read_lock (active_mm); vma =find_vma (active_mm, address);/* check against the find_vma( ) behaviour which returns the next VMA
@@ -111,7 +111,7 @@ static void show_faulting_vma(unsigned long address) }else pr_info (" @No matching VMA found\n" ); -up_read (&active_mm->mmap_sem); +mmap_read_unlock (active_mm); }static void show_ecr_verbose (struct pt_regs *regs)
arch/arc/mm/fault.c +2 -2
@@ -107,7 +107,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) flags |=FAULT_FLAG_WRITE ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma)
@@ -150,7 +150,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) } bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Major/minor page fault accounting
arch/arm/kernel/process.c +2 -2
@@ -431,7 +431,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) npages =1 ;/* for sigpage */ npages += vdso_total_pages; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; hint =sigpage_addr (mm, npages); addr =get_unmapped_area (NULL , hint, npages <<PAGE_SHIFT ,0 ,0 );
@@ -458,7 +458,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)arm_install_vdso (mm, addr +PAGE_SIZE ); up_fail: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); return ret; }#endif
arch/arm/kernel/swp_emulate.c +2 -2
@@ -97,12 +97,12 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr) {int si_code; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);if (find_vma (current->mm, addr) ==NULL ) si_code =SEGV_MAPERR ;else si_code =SEGV_ACCERR ; -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);pr_debug ("SWP{B} emulation: access caused memory abort!\n" ); arm_notify_die("Illegal memory access", regs,
arch/arm/lib/uaccess_with_memcpy.c +8 -8
@@ -96,7 +96,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) atomic =faulthandler_disabled ();if (!atomic) -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);while (n) {pte_t *pte;spinlock_t *ptl;
@@ -104,11 +104,11 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)while (!pin_page_for_write (to, &pte, &ptl)) {if (!atomic) -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (__put_user (0 , (char __user *)to)) goto out;if (!atomic) -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); } tocopy = (~(unsigned long )to & ~PAGE_MASK ) +1 ;
@@ -128,7 +128,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)spin_unlock (ptl); }if (!atomic) -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); out:return n;
@@ -165,17 +165,17 @@ __clear_user_memset(void __user *addr, unsigned long n)return 0 ; } -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);while (n) {pte_t *pte;spinlock_t *ptl;int tocopy;while (!pin_page_for_write (addr, &pte, &ptl)) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (__put_user (0 , (char __user *)addr)) goto out; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); } tocopy = (~(unsigned long )addr & ~PAGE_MASK ) +1 ;
@@ -193,7 +193,7 @@ __clear_user_memset(void __user *addr, unsigned long n)else spin_unlock (ptl); } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); out:return n;
arch/arm/mm/fault.c +3 -3
@@ -270,11 +270,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)* validly references user space from well defined areas of the code, * we can bug out early if this is from code which shouldn't. */ -if (!down_read_trylock (&mm->mmap_sem)) { +if (!mmap_read_trylock (mm)) {if (!user_mode (regs) && !search_exception_tables (regs->ARM_pc)) goto no_context; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in
@@ -324,7 +324,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Handle the "normal" case first - VM_FAULT_MAJOR
arch/arm64/kernel/traps.c +2 -2
@@ -387,12 +387,12 @@ void arm64_notify_segfault(unsigned long addr) {int code; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);if (find_vma (current->mm, addr) ==NULL ) code =SEGV_MAPERR ;else code =SEGV_ACCERR ; -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);force_signal_inject (SIGSEGV , code, addr); }
arch/arm64/kernel/vdso.c +4 -4
@@ -346,7 +346,7 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)struct mm_struct *mm = current->mm;int ret; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; ret =aarch32_kuser_helpers_setup (mm);
@@ -363,7 +363,7 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)#endif /* CONFIG_COMPAT_VDSO */ out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); return ret; }#endif /* CONFIG_COMPAT */
@@ -407,7 +407,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,struct mm_struct *mm = current->mm;int ret; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; ret = __setup_additional_pages(ARM64_VDSO,
@@ -415,7 +415,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, bprm, uses_interp); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/arm64/mm/fault.c +4 -4
@@ -491,11 +491,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,* validly references user space from well defined areas of the code, * we can bug out early if this is from code which shouldn't. */ -if (!down_read_trylock (&mm->mmap_sem)) { +if (!mmap_read_trylock (mm)) {if (!user_mode (regs) && !search_exception_tables (regs->pc)) goto no_context; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in which
@@ -504,7 +504,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,might_sleep ();#ifdef CONFIG_DEBUG_VM if (!user_mode (regs) && !search_exception_tables (regs->pc)) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); goto no_context; }#endif
@@ -526,7 +526,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, goto retry; } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Handle the "normal" (no error) case first.
arch/csky/kernel/vdso.c +2 -2
@@ -50,7 +50,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)unsigned long addr;struct mm_struct *mm = current->mm; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); addr =get_unmapped_area (NULL ,STACK_TOP ,PAGE_SIZE ,0 ,0 );if (IS_ERR_VALUE (addr)) {
@@ -70,7 +70,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) mm->context.vdso = (void *)addr; up_fail: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/csky/mm/fault.c +4 -4
@@ -120,7 +120,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,if (in_atomic () || !mm) goto bad_area_nosemaphore; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto bad_area;
@@ -170,7 +170,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, address); } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -178,7 +178,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:/* User mode accesses just cause a SIGSEGV */
@@ -217,7 +217,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, do_sigbus: tsk->thread.trap_no = (regs->sr >>16 ) &0xff ; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
arch/hexagon/kernel/vdso.c +2 -2
@@ -52,7 +52,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)unsigned long vdso_base;struct mm_struct *mm = current->mm; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ;/* Try to get it loaded right near ld.so/glibc. */
@@ -76,7 +76,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) mm->context.vdso = (void *)vdso_base; up_fail: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/hexagon/mm/vm_fault.c +4 -4
@@ -55,7 +55,7 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)if (user_mode (regs)) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto bad_area;
@@ -107,11 +107,11 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs) } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Handle copyin/out exception cases */ if (!user_mode (regs))
@@ -138,7 +138,7 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)return ; bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (user_mode (regs)) {force_sig_fault (SIGSEGV , si_code, (void __user *)address);
arch/ia64/kernel/perfmon.c +4 -4
@@ -2260,13 +2260,13 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t* now we atomically find some area in the address space and * remap the buffer in it. */ -down_write (&task->mm->mmap_sem); +mmap_write_lock (task->mm);/* find some free area in address space, must have mmap sem held */ vma->vm_start =get_unmapped_area (NULL ,0 , size,0 ,MAP_PRIVATE |MAP_ANONYMOUS );if (IS_ERR_VALUE (vma->vm_start)) {DPRINT (("Cannot find unmapped area for size %ld\n" , size)); -up_write (&task->mm->mmap_sem); +mmap_write_unlock (task->mm); goto error; } vma->vm_end = vma->vm_start + size;
@@ -2277,7 +2277,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t/* can only be applied to current task, need to have the mm semaphore held when called */ if (pfm_remap_buffer (vma, (unsigned long )smpl_buf, vma->vm_start, size)) {DPRINT (("Can't remap buffer\n" )); -up_write (&task->mm->mmap_sem); +mmap_write_unlock (task->mm); goto error; }
@@ -2288,7 +2288,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_tinsert_vm_struct (mm, vma);vm_stat_account (vma->vm_mm, vma->vm_flags,vma_pages (vma)); -up_write (&task->mm->mmap_sem); +mmap_write_unlock (task->mm);/* * keep track of user level virtual address
arch/ia64/mm/fault.c +4 -4
@@ -102,7 +102,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *reif (mask &VM_WRITE ) flags |=FAULT_FLAG_WRITE ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma_prev (mm, address, &prev_vma);if (!vma && !prev_vma )
@@ -178,7 +178,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ; check_expansion:
@@ -209,7 +209,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re goto good_area; bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);#ifdef CONFIG_VIRTUAL_MEM_MAP bad_area_no_up:#endif
@@ -275,7 +275,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *rereturn ; out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();
arch/ia64/mm/init.c +6 -6
@@ -118,13 +118,13 @@ ia64_init_addr_space (void) vma->vm_end = vma->vm_start +PAGE_SIZE ; vma->vm_flags =VM_DATA_DEFAULT_FLAGS |VM_GROWSUP |VM_ACCOUNT ; vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm);if (insert_vm_struct (current->mm, vma)) { -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);vm_area_free (vma);return ; } -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm); }/* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
@@ -136,13 +136,13 @@ ia64_init_addr_space (void) vma->vm_page_prot =__pgprot (pgprot_val (PAGE_READONLY ) | _PAGE_MA_NAT); vma->vm_flags =VM_READ |VM_MAYREAD |VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm);if (insert_vm_struct (current->mm, vma)) { -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);vm_area_free (vma);return ; } -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm); } } }
arch/m68k/kernel/sys_m68k.c +7 -7
@@ -399,7 +399,7 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)* Verify that the specified address region actually belongs * to this process. */ -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma (current->mm, addr);if (!vma || addr < vma->vm_start || addr + len > vma->vm_end) goto out_unlock;
@@ -450,7 +450,7 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) } } out_unlock: -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); out:return ret; }
@@ -472,7 +472,7 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,spinlock_t *ptl;unsigned long mem_value; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); pgd =pgd_offset (mm, (unsigned long )mem);if (!pgd_present (*pgd)) goto bad_access;
@@ -501,11 +501,11 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,__put_user (newval, mem);pte_unmap_unlock (pte, ptl); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return mem_value; bad_access: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* This is not necessarily a bad access, we can get here if a memory we're trying to write to should be copied-on-write. Make the kernel do the necessary page stuff, then re-iterate.
@@ -545,13 +545,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,struct mm_struct *mm = current->mm;unsigned long mem_value; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); mem_value = *mem;if (mem_value == oldval) *mem = newval; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return mem_value; }
arch/m68k/mm/fault.c +4 -4
@@ -86,7 +86,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma)
@@ -174,7 +174,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return 0 ;/*
@@ -182,7 +182,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,* us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();
@@ -211,6 +211,6 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, current->thread.faddr = address; send_sig: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return send_fault_sig (regs); }
arch/microblaze/mm/fault.c +6 -6
@@ -137,12 +137,12 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,* source. If this is invalid we can skip the address space check, * thus avoiding the deadlock. */ -if (unlikely (!down_read_trylock (&mm->mmap_sem))) { +if (unlikely (!mmap_read_trylock (mm))) {if (kernel_mode (regs) && !search_exception_tables (regs->pc)) goto bad_area_nosemaphore; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); } vma =find_vma (mm, address);
@@ -248,7 +248,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * keep track of tlb+htab misses that are good addrs but
@@ -259,7 +259,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,return ; bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore: pte_errors++;
@@ -278,7 +278,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,* us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs))bad_page_fault (regs, address,SIGKILL );else
@@ -286,7 +286,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (user_mode (regs)) {force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address);return ;
arch/mips/kernel/traps.c +2 -2
@@ -749,13 +749,13 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)return 1 ;case SIGSEGV : -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma (current->mm, (unsigned long )fault_addr);if (vma && (vma->vm_start <= (unsigned long )fault_addr)) si_code =SEGV_ACCERR ;else si_code =SEGV_MAPERR ; -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);force_sig_fault (SIGSEGV , si_code, fault_addr);return 1 ;
arch/mips/kernel/vdso.c +2 -2
@@ -94,7 +94,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)struct vm_area_struct *vma;int ret; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ;if (IS_ENABLED (CONFIG_MIPS_FP_SUPPORT )) {
@@ -187,6 +187,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) ret =0 ; out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/nds32/kernel/vdso.c +3 -3
@@ -130,7 +130,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) vdso_mapping_len += L1_cache_info[DCACHE ].aliasing_num -1 ;#endif -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; addr =vdso_random_addr (vdso_mapping_len);
@@ -185,12 +185,12 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) goto up_fail; } -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return 0 ; up_fail: mm->context.vdso =NULL ; -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/nds32/mm/fault.c +6 -6
@@ -127,12 +127,12 @@ void do_page_fault(unsigned long entry, unsigned long addr,* validly references user space from well defined areas of the code, * we can bug out early if this is from code which shouldn't. */ -if (unlikely (!down_read_trylock (&mm->mmap_sem))) { +if (unlikely (!mmap_read_trylock (mm))) {if (!user_mode (regs) && !search_exception_tables (instruction_pointer (regs))) goto no_context; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in which
@@ -256,7 +256,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -264,7 +264,7 @@ void do_page_fault(unsigned long entry, unsigned long addr,* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:
@@ -324,14 +324,14 @@ void do_page_fault(unsigned long entry, unsigned long addr,*/ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
arch/nios2/mm/fault.c +6 -6
@@ -83,11 +83,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; -if (!down_read_trylock (&mm->mmap_sem)) { +if (!mmap_read_trylock (mm)) {if (!user_mode (regs) && !search_exception_tables (regs->ea)) goto bad_area_nosemaphore; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); } vma =find_vma (mm, address);
@@ -169,7 +169,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -177,7 +177,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:/* User mode accesses just cause a SIGSEGV */
@@ -215,14 +215,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,* us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
arch/nios2/mm/init.c +2 -2
@@ -112,14 +112,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)struct mm_struct *mm = current->mm;int ret; -down_write (&mm->mmap_sem); +mmap_write_lock (mm);/* Map kuser helpers to user space address */ ret =install_special_mapping (mm,KUSER_BASE ,KUSER_SIZE ,VM_READ |VM_EXEC |VM_MAYREAD |VM_MAYEXEC , kuser_page); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/openrisc/mm/fault.c +5 -5
@@ -104,7 +104,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, goto no_context; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma)
@@ -192,7 +192,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -201,7 +201,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,*/ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:
@@ -260,14 +260,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, __asm__ __volatile__("l.nop 42" ); __asm__ __volatile__("l.nop 1" ); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Send a sigbus, regardless of whether we were in kernel
arch/parisc/kernel/traps.c +3 -3
@@ -717,7 +717,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)if (user_mode (regs)) {struct vm_area_struct *vma; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma (current->mm,regs->iaoq[0 ]);if (vma && (regs->iaoq[0 ] >= vma->vm_start) && (vma->vm_flags &VM_EXEC )) {
@@ -725,10 +725,10 @@ void notrace handle_interruption(int code, struct pt_regs *regs) fault_address = regs->iaoq[0 ]; fault_space = regs->iasq[0 ]; -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);break ;/* call do_page_fault() */ } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); }/* Fall Through */ case 27 :
arch/parisc/mm/fault.c +4 -4
@@ -282,7 +282,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,if (acc_type &VM_WRITE ) flags |=FAULT_FLAG_WRITE ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma_prev (mm, address, &prev_vma);if (!vma || address < vma->vm_start) goto check_expansion;
@@ -337,7 +337,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, goto retry; } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ; check_expansion:
@@ -349,7 +349,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,* Something tried to access memory that isn't in our memory map.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (user_mode (regs)) {int signo, si_code;
@@ -421,7 +421,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,parisc_terminate ("Bad Address (null pointer deref?)" , regs, code, address); out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();
arch/powerpc/kernel/vdso.c +3 -3
@@ -171,7 +171,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)* and end up putting it elsewhere. * Add enough to the size so that the result can be aligned. */ -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; vdso_base = get_unmapped_area(NULL, vdso_base, (vdso_pages << PAGE_SHIFT) +
@@ -211,11 +211,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) goto fail_mmapsem; } -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return 0 ; fail_mmapsem: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return rc; }
arch/powerpc/kvm/book3s_hv.c +3 -3
@@ -4627,14 +4627,14 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)/* Look up the VMA for the start of this memory slot */ hva = memslot->userspace_addr; -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm); vma =find_vma (kvm->mm, hva);if (!vma || vma->vm_start > hva || (vma->vm_flags &VM_IO )) goto up_out; psize =vma_kernel_pagesize (vma); -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);/* We can handle 4k, 64k or 16M pages in the VRMA */ if (psize >=0x1000000 )
@@ -4667,7 +4667,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)return err; up_out: -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm); goto out_srcu; }
arch/powerpc/kvm/book3s_hv_uvmem.c +6 -6
@@ -408,7 +408,7 @@ kvmppc_svm_page_in(struct vm_area_struct *vma, unsigned long start,*/ ret =ksm_madvise (vma, vma->vm_start, vma->vm_end,MADV_UNMERGEABLE , &vma->vm_flags); -downgrade_write (&kvm->mm->mmap_sem); +mmap_write_downgrade (kvm->mm); *downgrade = true;if (ret)return ret;
@@ -525,7 +525,7 @@ kvmppc_h_svm_page_in(struct kvm *kvm, unsigned long gpa, ret =H_PARAMETER ; srcu_idx =srcu_read_lock (&kvm->srcu); -down_write (&kvm->mm->mmap_sem); +mmap_write_lock (kvm->mm); start =gfn_to_hva (kvm, gfn);if (kvm_is_error_hva (start))
@@ -548,9 +548,9 @@ kvmppc_h_svm_page_in(struct kvm *kvm, unsigned long gpa,mutex_unlock (&kvm->arch.uvmem_lock); out:if (downgrade) -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);else -up_write (&kvm->mm->mmap_sem); +mmap_write_unlock (kvm->mm);srcu_read_unlock (&kvm->srcu, srcu_idx);return ret; }
@@ -703,7 +703,7 @@ kvmppc_h_svm_page_out(struct kvm *kvm, unsigned long gpa, ret =H_PARAMETER ; srcu_idx =srcu_read_lock (&kvm->srcu); -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm); start =gfn_to_hva (kvm, gfn);if (kvm_is_error_hva (start)) goto out;
@@ -716,7 +716,7 @@ kvmppc_h_svm_page_out(struct kvm *kvm, unsigned long gpa,if (!kvmppc_svm_page_out (vma, start, end, page_shift, kvm, gpa)) ret =H_SUCCESS ; out: -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);srcu_read_unlock (&kvm->srcu, srcu_idx);return ret; }
arch/powerpc/kvm/e500_mmu_host.c +2 -2
@@ -355,7 +355,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,if (tlbsel ==1 ) {struct vm_area_struct *vma; -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm); vma =find_vma (kvm->mm, hva); if (vma && hva >= vma->vm_start &&
@@ -441,7 +441,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, tsize =max (BOOK3E_PAGESZ_4K , tsize & ~1 ); } -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm); }if (likely (!pfnmap)) {
arch/powerpc/mm/book3s64/iommu_api.c +2 -2
@@ -96,7 +96,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, goto unlock_exit; } -down_read (&mm->mmap_sem); +mmap_read_lock (mm); chunk = (1UL << (PAGE_SHIFT +MAX_ORDER -1 )) /sizeof (struct vm_area_struct *); chunk =min (chunk, entries);
@@ -114,7 +114,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, pinned += ret;break ; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (pinned != entries) {if (!ret) ret = -EFAULT ;
arch/powerpc/mm/book3s64/subpage_prot.c +6 -6
@@ -92,7 +92,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len)size_t nw;unsigned long next, limit; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); spt =mm_ctx_subpage_prot (&mm->context);if (!spt)
@@ -127,7 +127,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len) } err_out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); }#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -217,7 +217,7 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,if (!access_ok (map, (len >>PAGE_SHIFT ) *sizeof (u32)))return -EFAULT ; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); spt =mm_ctx_subpage_prot (&mm->context);if (!spt) {
@@ -267,11 +267,11 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,if (addr + (nw <<PAGE_SHIFT ) > next) nw = (next - addr) >>PAGE_SHIFT ; -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);if (__copy_from_user (spp, map, nw *sizeof (u32)))return -EFAULT ; map += nw; -down_write (&mm->mmap_sem); +mmap_write_lock (mm);/* now flush any existing HPTEs for the range */ hpte_flush_range (mm, addr, nw);
@@ -280,6 +280,6 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr, spt->maxaddr = limit; err =0 ; out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return err; }
arch/powerpc/mm/copro_fault.c +2 -2
@@ -33,7 +33,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,if (mm->pgd ==NULL )return -EFAULT ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); ret = -EFAULT ; vma =find_vma (mm, ea);if (!vma)
@@ -82,7 +82,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea, current->min_flt++; out_unlock: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ret; }EXPORT_SYMBOL_GPL (copro_handle_mm_fault);
arch/powerpc/mm/fault.c +6 -6
@@ -108,7 +108,7 @@ static int __bad_area(struct pt_regs *regs, unsigned long address, int si_code)* Something tried to access memory that isn't in our memory map.. * Fix it, but check if it's kernel or user first.. */ -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return __bad_area_nosemaphore (regs, address, si_code); }
@@ -514,12 +514,12 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,* source. If this is invalid we can skip the address space check, * thus avoiding the deadlock. */ -if (unlikely (!down_read_trylock (&mm->mmap_sem))) { +if (unlikely (!mmap_read_trylock (mm))) {if (!is_user && !search_exception_tables (regs->nip))return bad_area_nosemaphore (regs, address); retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in
@@ -543,7 +543,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,if (!must_retry)return bad_area (regs, address); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (fault_in_pages_readable ((const char __user *)regs->nip,sizeof (unsigned int )))return bad_area_nosemaphore (regs, address);
@@ -575,7 +575,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,int pkey =vma_pkey (vma); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); return bad_key_fault_exception(regs, address, pkey); }#endif /* CONFIG_PPC_MEM_KEYS */
@@ -596,7 +596,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, } } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (unlikely (fault &VM_FAULT_ERROR ))return mm_fault_error (regs, address, fault);
arch/powerpc/oprofile/cell/spu_task_sync.c +3 -3
@@ -332,7 +332,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,fput (exe_file); } -down_read (&mm->mmap_sem); +mmap_read_lock (mm);for (vma = mm->mmap; vma; vma = vma->vm_next) {if (vma->vm_start > spu_ref || vma->vm_end <= spu_ref)continue ;
@@ -349,13 +349,13 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp, *spu_bin_dcookie =fast_get_dcookie (&vma->vm_file->f_path);pr_debug ("got dcookie for %pD\n" , vma->vm_file); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out:return app_cookie; fail_no_image_cookie: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); printk(KERN_ERR "SPU_PROF: " "%s, line %d: Cannot find dcookie for SPU binary\n",
arch/powerpc/platforms/cell/spufs/file.c +2 -2
@@ -336,11 +336,11 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf, goto refault;if (ctx->state ==SPU_STATE_SAVED ) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);spu_context_nospu_trace (spufs_ps_fault__sleep, ctx); err =spufs_wait (ctx->run_wq, ctx->state ==SPU_STATE_RUNNABLE );spu_context_trace (spufs_ps_fault__wake, ctx, ctx->spu); -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); }else { area = ctx->spu->problem_phys + ps_offs; ret = vmf_insert_pfn(vmf->vma, vmf->address,
arch/riscv/kernel/vdso.c +2 -2
@@ -61,7 +61,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, vdso_len = (vdso_pages +1 ) <<PAGE_SHIFT ; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); vdso_base =get_unmapped_area (NULL ,0 , vdso_len,0 ,0 );if (IS_ERR_VALUE (vdso_base)) { ret = vdso_base;
@@ -83,7 +83,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, mm->context.vdso =NULL ; end: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/riscv/mm/fault.c +5 -5
@@ -69,7 +69,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, addr); retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, addr);if (unlikely (!vma)) goto bad_area;
@@ -155,7 +155,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -163,7 +163,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)* Fix it, but check if it's kernel or user first. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) {do_trap (regs,SIGSEGV , code, addr);
@@ -191,14 +191,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs)* (which will retry the fault, or kill us if we got oom-killed). */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs)) goto no_context;
arch/s390/kernel/uv.c +2 -2
@@ -205,7 +205,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb) again: rc = -EFAULT ; -down_read (&gmap->mm->mmap_sem); +mmap_read_lock (gmap->mm); uaddr =__gmap_translate (gmap, gaddr);if (IS_ERR_VALUE (uaddr))
@@ -234,7 +234,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)pte_unmap_unlock (ptep, ptelock);unlock_page (page); out: -up_read (&gmap->mm->mmap_sem); +mmap_read_unlock (gmap->mm);if (rc == -EAGAIN ) {wait_on_page_writeback (page);
arch/s390/kernel/vdso.c +2 -2
@@ -208,7 +208,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)* it at vdso_base which is the "natural" base for it, but we might * fail and end up putting it elsewhere. */ -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; vdso_base =get_unmapped_area (NULL ,0 , vdso_pages <<PAGE_SHIFT ,0 ,0 );if (IS_ERR_VALUE (vdso_base)) {
@@ -239,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) rc =0 ; out_up: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return rc; }
arch/s390/kvm/gaccess.c +2 -2
@@ -1173,7 +1173,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg,int dat_protection, fake;int rc; -down_read (&sg->mm->mmap_sem); +mmap_read_lock (sg->mm);/* * We don't want any guest-2 tables to change - so the parent * tables/pointers we read stay valid - unshadowing is however
@@ -1202,6 +1202,6 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg,if (!rc) rc =gmap_shadow_page (sg, saddr,__pte (pte.val));ipte_unlock (vcpu); -up_read (&sg->mm->mmap_sem); +mmap_read_unlock (sg->mm);return rc; }
arch/s390/kvm/interrupt.c +2 -2
@@ -2767,10 +2767,10 @@ static struct page *get_map_page(struct kvm *kvm, u64 uaddr) {struct page *page =NULL ; -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm);get_user_pages_remote (NULL , kvm->mm, uaddr,1 ,FOLL_WRITE , &page,NULL ,NULL ); -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);return page; }
arch/s390/kvm/kvm-s390.c +14 -14
@@ -764,9 +764,9 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap) r = -EINVAL ; else { r =0 ; -down_write (&kvm->mm->mmap_sem); +mmap_write_lock (kvm->mm); kvm->mm->context.allow_gmap_hpage_1m =1 ; -up_write (&kvm->mm->mmap_sem); +mmap_write_unlock (kvm->mm);/* * We might have to create fake 4k page * tables. To avoid that the hardware works on
@@ -1816,7 +1816,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)if (!keys)return -ENOMEM ; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); srcu_idx =srcu_read_lock (&kvm->srcu);for (i =0 ; i < args->count; i++) { hva =gfn_to_hva (kvm, args->start_gfn + i);
@@ -1830,7 +1830,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)break ; }srcu_read_unlock (&kvm->srcu, srcu_idx); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (!r) { r = copy_to_user((uint8_t __user *)args->skeydata_addr, keys,
@@ -1874,7 +1874,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args) goto out; i =0 ; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); srcu_idx =srcu_read_lock (&kvm->srcu);while (i < args->count) { unlocked = false;
@@ -1901,7 +1901,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args) i++; }srcu_read_unlock (&kvm->srcu, srcu_idx); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); out:kvfree (keys);return r;
@@ -2090,14 +2090,14 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,if (!values)return -ENOMEM ; -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm); srcu_idx =srcu_read_lock (&kvm->srcu);if (peek) ret =kvm_s390_peek_cmma (kvm, args, values, bufsize);else ret =kvm_s390_get_cmma (kvm, args, values, bufsize);srcu_read_unlock (&kvm->srcu, srcu_idx); -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);if (kvm->arch.migration_mode) args->remaining =atomic64_read (&kvm->arch.cmma_dirty_pages);
@@ -2147,7 +2147,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm, goto out; } -down_read (&kvm->mm->mmap_sem); +mmap_read_lock (kvm->mm); srcu_idx =srcu_read_lock (&kvm->srcu);for (i =0 ; i < args->count; i++) { hva =gfn_to_hva (kvm, args->start_gfn + i);
@@ -2162,12 +2162,12 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,set_pgste_bits (kvm->mm, hva, mask, pgstev); }srcu_read_unlock (&kvm->srcu, srcu_idx); -up_read (&kvm->mm->mmap_sem); +mmap_read_unlock (kvm->mm);if (!kvm->mm->context.uses_cmm) { -down_write (&kvm->mm->mmap_sem); +mmap_write_lock (kvm->mm); kvm->mm->context.uses_cmm =1 ; -up_write (&kvm->mm->mmap_sem); +mmap_write_unlock (kvm->mm); } out:vfree (bits);
@@ -2240,9 +2240,9 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)if (r)break ; -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm); r =gmap_mark_unmergeable (); -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);if (r)break ;
arch/s390/kvm/priv.c +16 -16
@@ -270,18 +270,18 @@ static int handle_iske(struct kvm_vcpu *vcpu)return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); retry: unlocked = false; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); rc =get_guest_storage_key (current->mm, vmaddr, &key);if (rc) { rc =fixup_user_fault (current, current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked);if (!rc) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); goto retry; } } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (rc == -EFAULT )return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING );if (rc <0 )
@@ -317,17 +317,17 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); retry: unlocked = false; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); rc =reset_guest_reference_bit (current->mm, vmaddr);if (rc <0 ) { rc =fixup_user_fault (current, current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked);if (!rc) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); goto retry; } } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (rc == -EFAULT )return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING );if (rc <0 )
@@ -385,7 +385,7 @@ static int handle_sske(struct kvm_vcpu *vcpu)if (kvm_is_error_hva (vmaddr))return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); rc =cond_set_guest_storage_key (current->mm, vmaddr, key, &oldkey, m3 &SSKE_NQ , m3 &SSKE_MR , m3 &SSKE_MC );
@@ -395,7 +395,7 @@ static int handle_sske(struct kvm_vcpu *vcpu) FAULT_FLAG_WRITE, &unlocked); rc = !rc ? -EAGAIN : rc; } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (rc == -EFAULT )return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING );if (rc <0 )
@@ -1091,7 +1091,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)if (rc)return rc; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); rc =cond_set_guest_storage_key (current->mm, vmaddr, key,NULL , nq, mr, mc);if (rc <0 ) {
@@ -1099,7 +1099,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) FAULT_FLAG_WRITE, &unlocked); rc = !rc ? -EAGAIN : rc; } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (rc == -EFAULT )return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING );if (rc == -EAGAIN )
@@ -1220,9 +1220,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)* already correct, we do nothing and avoid the lock. */ if (vcpu->kvm->mm->context.uses_cmm ==0 ) { -down_write (&vcpu->kvm->mm->mmap_sem); +mmap_write_lock (vcpu->kvm->mm); vcpu->kvm->mm->context.uses_cmm =1 ; -up_write (&vcpu->kvm->mm->mmap_sem); +mmap_write_unlock (vcpu->kvm->mm); }/* * If we are here, we are supposed to have CMMA enabled in
@@ -1239,11 +1239,11 @@ static int handle_essa(struct kvm_vcpu *vcpu) }else {int srcu_idx; -down_read (&vcpu->kvm->mm->mmap_sem); +mmap_read_lock (vcpu->kvm->mm); srcu_idx =srcu_read_lock (&vcpu->kvm->srcu); i =__do_essa (vcpu, orc);srcu_read_unlock (&vcpu->kvm->srcu, srcu_idx); -up_read (&vcpu->kvm->mm->mmap_sem); +mmap_read_unlock (vcpu->kvm->mm);if (i <0 )return i;/* Account for the possible extra cbrl entry */
@@ -1251,10 +1251,10 @@ static int handle_essa(struct kvm_vcpu *vcpu) } vcpu->arch.sie_block->cbrlo &=PAGE_MASK ;/* reset nceo */ cbrlo =phys_to_virt (vcpu->arch.sie_block->cbrlo); -down_read (&gmap->mm->mmap_sem); +mmap_read_lock (gmap->mm);for (i =0 ; i < entries; ++i)__gmap_zap (gmap, cbrlo[i]); -up_read (&gmap->mm->mmap_sem); +mmap_read_unlock (gmap->mm);return 0 ; }
arch/s390/mm/fault.c +7 -7
@@ -434,7 +434,7 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) flags |=FAULT_FLAG_USER ;if (access ==VM_WRITE || (trans_exc_code & store_indication) ==0x400 ) flags |=FAULT_FLAG_WRITE ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); gmap =NULL ;if (IS_ENABLED (CONFIG_PGSTE ) && type ==GMAP_FAULT ) {
@@ -515,7 +515,7 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) } flags &= ~FAULT_FLAG_RETRY_NOWAIT ; flags |=FAULT_FLAG_TRIED ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); goto retry; } }
@@ -533,7 +533,7 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) } fault =0 ; out_up: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out:return fault; }
@@ -825,22 +825,22 @@ void do_secure_storage_access(struct pt_regs *regs)switch (get_fault_type (regs)) {case USER_FAULT : mm = current->mm; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, addr);if (!vma) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);do_fault_error (regs,VM_READ |VM_WRITE ,VM_FAULT_BADMAP );break ; } page =follow_page (vma, addr,FOLL_WRITE |FOLL_GET );if (IS_ERR_OR_NULL (page)) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);break ; }if (arch_make_page_accessible (page))send_sig (SIGSEGV , current,0 );put_page (page); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);break ;case KERNEL_FAULT : page =phys_to_page (addr);
arch/s390/mm/gmap.c +22 -22
147 lines not on this page · raw message
arch/s390/pci/pci_mmio.c +2 -2
@@ -18,7 +18,7 @@ static long get_pfn(unsigned long user_addr, unsigned long access,struct vm_area_struct *vma;long ret; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); ret = -EINVAL ; vma =find_vma (current->mm, user_addr);if (!vma)
@@ -28,7 +28,7 @@ static long get_pfn(unsigned long user_addr, unsigned long access, goto out; ret =follow_pfn (vma, user_addr, pfn); out: -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return ret; }
arch/sh/kernel/sys_sh.c +3 -3
@@ -69,10 +69,10 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)if (addr + len < addr)return -EFAULT ; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma (current->mm, addr);if (vma ==NULL || addr < vma->vm_start || addr + len > vma->vm_end) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return -EFAULT ; }
@@ -91,6 +91,6 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)if (op &CACHEFLUSH_I )flush_icache_range (addr, addr+len); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return 0 ; }
arch/sh/kernel/vsyscall/vsyscall.c +2 -2
@@ -61,7 +61,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)unsigned long addr;int ret; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; addr =get_unmapped_area (NULL ,0 ,PAGE_SIZE ,0 ,0 );
@@ -80,7 +80,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) current->mm->context.vdso = (void *)addr; up_fail: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/sh/mm/fault.c +5 -5
@@ -261,7 +261,7 @@ __bad_area(struct pt_regs *regs, unsigned long error_code,* Something tried to access memory that isn't in our memory map.. * Fix it, but check if it's kernel or user first.. */ -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);__bad_area_nosemaphore (regs, error_code, address, si_code); }
@@ -285,7 +285,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)struct task_struct *tsk = current;struct mm_struct *mm = tsk->mm; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die: */ if (!user_mode (regs))
@@ -310,7 +310,7 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,/* Release mmap_sem first if necessary */ if (!(fault &VM_FAULT_RETRY )) -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (!(fault &VM_FAULT_ERROR ))return 0 ;
@@ -424,7 +424,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, } retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (unlikely (!vma)) {
@@ -492,5 +492,5 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); }
arch/sparc/mm/fault_32.c +9 -9
@@ -196,7 +196,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm);if (!from_user && address >=PAGE_OFFSET ) goto bad_area;
@@ -272,7 +272,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -280,7 +280,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:/* User mode accesses just cause a SIGSEGV */
@@ -329,7 +329,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,* us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (from_user) {pagefault_out_of_memory ();return ;
@@ -337,7 +337,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, goto no_context; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);do_fault_siginfo (BUS_ADRERR ,SIGBUS , regs, text_fault);if (!from_user) goto no_context;
@@ -391,7 +391,7 @@ static void force_user_fault(unsigned long address, int write) code =SEGV_MAPERR ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto bad_area;
@@ -416,15 +416,15 @@ static void force_user_fault(unsigned long address, int write)case VM_FAULT_OOM : goto do_sigbus; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ; bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);__do_fault_siginfo (code,SIGSEGV , tsk->thread.kregs, address);return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);__do_fault_siginfo (BUS_ADRERR ,SIGBUS , tsk->thread.kregs, address); }
arch/sparc/mm/fault_64.c +6 -6
@@ -319,7 +319,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); -if (!down_read_trylock (&mm->mmap_sem)) { +if (!mmap_read_trylock (mm)) {if ((regs->tstate &TSTATE_PRIV ) && !search_exception_tables (regs->tpc)) { insn =get_fault_insn (regs, insn);
@@ -327,7 +327,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) } retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }if (fault_code &FAULT_CODE_BAD_RA )
@@ -459,7 +459,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto retry; } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); mm_rss =get_mm_rss (mm);#if defined(CONFIG_TRANSPARENT_HUGEPAGE )
@@ -490,7 +490,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)*/ bad_area: insn =get_fault_insn (regs, insn); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); handle_kernel_fault:do_kernel_fault (regs, si_code, fault_code, insn, address);
@@ -502,7 +502,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)*/ out_of_memory: insn =get_fault_insn (regs, insn); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!(regs->tstate &TSTATE_PRIV )) {pagefault_out_of_memory (); goto exit_exception;
@@ -515,7 +515,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) do_sigbus: insn =get_fault_insn (regs, insn); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Send a sigbus, regardless of whether we were in kernel
arch/sparc/vdso/vma.c +2 -2
@@ -366,7 +366,7 @@ static int map_vdso(const struct vdso_image *image,unsigned long text_start, addr =0 ;int ret =0 ; -down_write (&mm->mmap_sem); +mmap_write_lock (mm);/* * First, get an unmapped region: then randomize it, and make sure that
@@ -422,7 +422,7 @@ static int map_vdso(const struct vdso_image *image,if (ret) current->mm->context.vdso =NULL ; -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
arch/um/include/asm/mmu_context.h +1 -1
@@ -49,7 +49,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)__switch_mm (&new->context.id);down_write_nested (&new->mmap_sem,1 );uml_setup_stubs (new); -up_write (&new->mmap_sem); +mmap_write_unlock (new); } static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
arch/um/kernel/tlb.c +1 -1
@@ -350,7 +350,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,printk (KERN_ERR "fix_range_common: failed, killing current " "process: %d\n" ,task_tgid_vnr (current));/* We are under mmap_sem, release it such that current can terminate */ -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);force_sig (SIGKILL );do_signal (¤t->thread.regs); }
arch/um/kernel/trap.c +3 -3
@@ -47,7 +47,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,if (is_user) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto out;
@@ -123,7 +123,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,#endif flush_tlb_page (vma, address); out: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out_nosemaphore:return err;
@@ -132,7 +132,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,* We ran out of memory, call the OOM killer, and return the userspace * (which will retry the fault, or kill us if we got oom-killed). */ -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!is_user) goto out_nosemaphore;pagefault_out_of_memory ();
arch/unicore32/mm/fault.c +3 -3
@@ -224,12 +224,12 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)* validly references user space from well defined areas of the code, * we can bug out early if this is from code which shouldn't. */ -if (!down_read_trylock (&mm->mmap_sem)) { +if (!mmap_read_trylock (mm)) {if (!user_mode (regs) && !search_exception_tables (regs->UCreg_pc)) goto no_context; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in
@@ -264,7 +264,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs) } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* * Handle the "normal" case first - VM_FAULT_MAJOR
arch/x86/entry/vdso/vma.c +7 -7
@@ -144,7 +144,7 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)struct mm_struct *mm = task->mm;struct vm_area_struct *vma; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ;for (vma = mm->mmap; vma; vma = vma->vm_next) {
@@ -154,7 +154,7 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns) zap_page_range(vma, vma->vm_start, size); } -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return 0 ; }#else
@@ -268,7 +268,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)unsigned long text_start;int ret =0 ; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; addr = get_unmapped_area(NULL, addr,
@@ -311,7 +311,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr) } up_fail: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }
@@ -373,7 +373,7 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)struct mm_struct *mm = current->mm;struct vm_area_struct *vma; -down_write (&mm->mmap_sem); +mmap_write_lock (mm);/* * Check if we have already mapped vdso blob - fail to prevent * abusing from userspace install_speciall_mapping, which may
@@ -384,11 +384,11 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)for (vma = mm->mmap; vma; vma = vma->vm_next) {if (vma_is_special_mapping (vma, &vdso_mapping) ||vma_is_special_mapping (vma, &vvar_mapping)) { -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return -EEXIST ; } } -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return map_vdso (image, addr); }
arch/x86/kernel/vm86_32.c +2 -2
@@ -171,7 +171,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)pte_t *pte;int i; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); pgd =pgd_offset (mm,0xA0000 );if (pgd_none_or_clear_bad (pgd)) goto out;
@@ -197,7 +197,7 @@ static void mark_screen_rdonly(struct mm_struct *mm) }pte_unmap_unlock (pte, ptl); out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);flush_tlb_mm_range (mm,0xA0000 ,0xA0000 +32 *PAGE_SIZE ,PAGE_SHIFT , false); }
arch/x86/mm/fault.c +4 -4
@@ -951,7 +951,7 @@ __bad_area(struct pt_regs *regs, unsigned long error_code,* Something tried to access memory that isn't in our memory map.. * Fix it, but check if it's kernel or user first.. */ -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);__bad_area_nosemaphore (regs, error_code, address, pkey, si_code); }
@@ -1402,7 +1402,7 @@ void do_user_addr_fault(struct pt_regs *regs,* 1. Failed to acquire mmap_sem, and * 2. The access did not originate in userspace. */ -if (unlikely (!down_read_trylock (&mm->mmap_sem))) { +if (unlikely (!mmap_read_trylock (mm))) {if (!user_mode (regs) && !search_exception_tables (regs->ip)) {/* * Fault from code in kernel from
@@ -1412,7 +1412,7 @@ void do_user_addr_fault(struct pt_regs *regs,return ; } retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); }else {/* * The above down_read_trylock() might have succeeded in
@@ -1483,7 +1483,7 @@ void do_user_addr_fault(struct pt_regs *regs, goto retry; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (unlikely (fault &VM_FAULT_ERROR )) {mm_fault_error (regs, hw_error_code, address, fault);return ;
arch/x86/um/vdso/vma.c +2 -2
@@ -58,7 +58,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)if (!vdso_enabled)return 0 ; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE,
@@ -66,7 +66,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)VM_MAYREAD |VM_MAYWRITE |VM_MAYEXEC , vdsop); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return err; }
arch/xtensa/mm/fault.c +5 -5
@@ -74,7 +74,7 @@ void do_page_fault(struct pt_regs *regs)if (user_mode (regs)) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma)
@@ -139,7 +139,7 @@ void do_page_fault(struct pt_regs *regs) } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address);if (flags &VM_FAULT_MAJOR )perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, address);
@@ -152,7 +152,7 @@ void do_page_fault(struct pt_regs *regs)* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (user_mode (regs)) { current->thread.bad_vaddr = address; current->thread.error_code = is_write;
@@ -167,7 +167,7 @@ void do_page_fault(struct pt_regs *regs)* us unable to handle the page fault gracefully. */ out_of_memory: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs))bad_page_fault (regs, address,SIGKILL );else
@@ -175,7 +175,7 @@ void do_page_fault(struct pt_regs *regs)return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Send a sigbus, regardless of whether we were in kernel * or user mode.
drivers/android/binder_alloc.c +5 -5
@@ -212,7 +212,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, mm = alloc->vma_vm_mm;if (mm) { -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma = alloc->vma; }
@@ -270,7 +270,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,trace_binder_alloc_page_end (alloc, index); }if (mm) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); }return 0 ;
@@ -303,7 +303,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate, } err_no_vma:if (mm) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); }return vma ? -ENOMEM : -ESRCH ;
@@ -932,7 +932,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, mm = alloc->vma_vm_mm;if (!mmget_not_zero (mm)) goto err_mmget; -if (!down_read_trylock (&mm->mmap_sem)) +if (!mmap_read_trylock (mm)) goto err_down_read_mmap_sem_failed; vma =binder_alloc_get_vma (alloc);
@@ -946,7 +946,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,trace_binder_unmap_user_end (alloc, index); } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);trace_binder_unmap_kernel_start (alloc, index);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1382,9 +1382,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(* concurrently and the queues are actually stopped */ if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) { -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm); is_invalid_userptr =atomic_read (&mem->invalid); -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm); }mutex_lock (&mem->lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -5
@@ -832,7 +832,7 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) goto out_free_ranges; } -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, start);if (unlikely (!vma || start < vma->vm_start)) { r = -EFAULT ;
@@ -843,15 +843,15 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) r = -EPERM ; goto out_unlock; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); timeout = jiffies +msecs_to_jiffies (HMM_RANGE_DEFAULT_TIMEOUT ); retry: range->notifier_seq =mmu_interval_read_begin (&bo->notifier); -down_read (&mm->mmap_sem); +mmap_read_lock (mm); r =hmm_range_fault (range); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (unlikely (r <=0 )) {/* * FIXME: This timeout should encompass the retry from
@@ -880,7 +880,7 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)return 0 ; out_unlock: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out_free_pfns:kvfree (range->pfns); out_free_ranges:
drivers/gpu/drm/amd/amdkfd/kfd_events.c +2 -2
@@ -901,7 +901,7 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid,memset (&memory_exception_data,0 ,sizeof (memory_exception_data)); -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address); memory_exception_data.gpu_id = dev->id;
@@ -924,7 +924,7 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid, memory_exception_data.failure.NoExecute =0 ; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); pr_debug("notpresent %d, noexecute %d, readonly %d\n",
drivers/gpu/drm/i915/gem/i915_gem_mman.c +2 -2
@@ -93,7 +93,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,struct mm_struct *mm = current->mm;struct vm_area_struct *vma; -if (down_write_killable (&mm->mmap_sem)) { +if (mmap_write_lock_killable (mm)) { addr = -EINTR ; goto err; }
@@ -103,7 +103,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,pgprot_writecombine (vm_get_page_prot (vma->vm_flags)); else addr = -ENOMEM ; -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);if (IS_ERR_VALUE (addr)) goto err; }
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +4 -4
@@ -200,7 +200,7 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)if (IS_ERR (mn)) err =PTR_ERR (mn); -down_write (&mm->mm->mmap_sem); +mmap_write_lock (mm->mm);mutex_lock (&mm->i915->mm_lock);if (mm->mn ==NULL && !err) {/* Protected by mmap_sem (write-lock) */
@@ -217,7 +217,7 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm) err =0 ; }mutex_unlock (&mm->i915->mm_lock); -up_write (&mm->mm->mmap_sem); +mmap_write_unlock (mm->mm);if (mn && !IS_ERR (mn))kfree (mn);
@@ -468,7 +468,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)if (mmget_not_zero (mm)) {while (pinned < npages) {if (!locked) { -down_read (&mm->mmap_sem); +mmap_read_lock (mm); locked =1 ; } ret = get_user_pages_remote
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work) pinned += ret; }if (locked) -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); } }
drivers/gpu/drm/nouveau/nouveau_svm.c +11 -11
@@ -169,10 +169,10 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,*/ mm =get_task_mm (current); -down_read (&mm->mmap_sem); +mmap_read_lock (mm);if (!cli->svm.svmm) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return -EINVAL ; }
@@ -198,7 +198,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,*/ args->result =0 ; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);return 0 ;
@@ -348,7 +348,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,if (ret) goto out_free; -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm); svmm->notifier.ops = &nouveau_mn_ops; ret =__mmu_notifier_register (&svmm->notifier, current->mm);if (ret)
@@ -357,12 +357,12 @@ nouveau_svmm_init(struct drm_device *dev, void *data, cli->svm.svmm = svmm; cli->svm.cli = cli; -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);mutex_unlock (&cli->mutex);return 0 ; out_mm_unlock: -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm); out_free:mutex_unlock (&cli->mutex);kfree (svmm);
@@ -545,9 +545,9 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, range.notifier_seq =mmu_interval_read_begin (range.notifier); range.default_flags =0 ; range.pfn_flags_mask =-1UL ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); ret =hmm_range_fault (&range); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (ret <=0 ) {if (ret ==0 || ret == -EBUSY )continue ;
@@ -673,18 +673,18 @@ nouveau_svm_fault(struct nvif_notify *notify)/* Intersect fault window with the CPU VMA, cancelling * the fault if the address is invalid. */ -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma_intersection (mm, start, limit);if (!vma) {SVMM_ERR (svmm,"wndw %016llx-%016llx" , start, limit); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);nouveau_svm_fault_cancel_fault (svm, buffer->fault[fi]);continue ; } start =max_t (u64, start, vma->vm_start); limit =min_t (u64, limit, vma->vm_end); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);SVMM_DBG (svmm,"wndw %016llx-%016llx" , start, limit);if (buffer->fault[fi]->addr != start) {
drivers/gpu/drm/radeon/radeon_cs.c +2 -2
@@ -196,12 +196,12 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) p->vm_bos =radeon_vm_get_bos (p->rdev, p->ib.vm, &p->validated);if (need_mmap_lock) -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); r =radeon_bo_list_validate (p->rdev, &p->ticket, &p->validated, p->ring);if (need_mmap_lock) -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return r; }
drivers/gpu/drm/radeon/radeon_gem.c +3 -3
@@ -342,17 +342,17 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data, }if (args->flags &RADEON_GEM_USERPTR_VALIDATE ) { -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); r =radeon_bo_reserve (bo, true);if (r) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); goto release_object; }radeon_ttm_placement_from_domain (bo,RADEON_GEM_DOMAIN_GTT ); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);radeon_bo_unreserve (bo); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (r) goto release_object; }
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -2
@@ -68,7 +68,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, goto out_unlock;ttm_bo_get (bo); -up_read (&vmf->vma->vm_mm->mmap_sem); +mmap_read_unlock (vmf->vma->vm_mm); (void )dma_fence_wait (bo->moving, true);dma_resv_unlock (bo->base.resv);ttm_bo_put (bo);
@@ -144,7 +144,7 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,if (fault_flag_allow_retry_first (vmf->flags)) {if (!(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) {ttm_bo_get (bo); -up_read (&vmf->vma->vm_mm->mmap_sem); +mmap_read_unlock (vmf->vma->vm_mm);if (!dma_resv_lock_interruptible (bo->base.resv,NULL ))dma_resv_unlock (bo->base.resv);
drivers/infiniband/core/umem_odp.c +2 -2
@@ -429,7 +429,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,ALIGN (bcnt,PAGE_SIZE ) /PAGE_SIZE , PAGE_SIZE / sizeof(struct page *)); -down_read (&owning_mm->mmap_sem); +mmap_read_lock (owning_mm);/* * Note: this might result in redundent page getting. We can * avoid this by checking dma_list to be 0 before calling
@@ -440,7 +440,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, npages =get_user_pages_remote (owning_process, owning_mm, user_virt, gup_num_pages, flags, local_page_list,NULL ,NULL ); -up_read (&owning_mm->mmap_sem); +mmap_read_unlock (owning_mm);if (npages <0 ) {if (npages != -EAGAIN )
drivers/infiniband/core/uverbs_main.c +2 -2
@@ -838,7 +838,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)* at a time to get the lock ordering right. Typically there * will only be one mm, so no big deal. */ -down_read (&mm->mmap_sem); +mmap_read_lock (mm);if (!mmget_still_valid (mm)) goto skip_mm;mutex_lock (&ufile->umap_lock);
@@ -860,7 +860,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile) }mutex_unlock (&ufile->umap_lock); skip_mm: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); } }
drivers/infiniband/hw/mlx4/mr.c +2 -2
@@ -380,7 +380,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start,unsigned long untagged_start =untagged_addr (start);struct vm_area_struct *vma; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);/* * FIXME: Ideally this would iterate over all the vmas that * cover the memory, but for now it requires a single vma to
@@ -395,7 +395,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start, access_flags |=IB_ACCESS_LOCAL_WRITE ; } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); }return ib_umem_get (device, start, length, access_flags);
drivers/infiniband/hw/qib/qib_user_pages.c +3 -3
@@ -106,18 +106,18 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages, goto bail; } -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);for (got =0 ; got < num_pages; got += ret) { ret =pin_user_pages (start_page + got *PAGE_SIZE , num_pages - got,FOLL_LONGTERM |FOLL_WRITE |FOLL_FORCE , p + got,NULL );if (ret <0 ) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); goto bail_release; } } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return 0 ; bail_release:
drivers/infiniband/hw/usnic/usnic_uiom.c +2 -2
@@ -123,7 +123,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable, npages =PAGE_ALIGN (size + (addr & ~PAGE_MASK )) >>PAGE_SHIFT ; uiomr->owning_mm = mm = current->mm; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); locked =atomic64_add_return (npages, ¤t->mm->pinned_vm); lock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ;
@@ -187,7 +187,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable, }else mmgrab (uiomr->owning_mm); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);free_page ((unsigned long ) page_list);return ret; }
drivers/infiniband/sw/siw/siw_mem.c +2 -2
@@ -397,7 +397,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)if (!writable) foll_flags |=FOLL_FORCE ; -down_read (&mm_s->mmap_sem); +mmap_read_lock (mm_s); mlock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ;
@@ -441,7 +441,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) num_pages -= got; } out_sem_up: -up_read (&mm_s->mmap_sem); +mmap_read_unlock (mm_s);if (rv >0 )return umem;
drivers/iommu/amd_iommu_v2.c +2 -2
@@ -487,7 +487,7 @@ static void do_fault(struct work_struct *work) flags |=FAULT_FLAG_WRITE ; flags |=FAULT_FLAG_REMOTE ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_extend_vma (mm, address);if (!vma || address < vma->vm_start)/* failed to get a vma in the right range */
@@ -499,7 +499,7 @@ static void do_fault(struct work_struct *work) ret =handle_mm_fault (vma, address, flags); out: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (ret &VM_FAULT_ERROR )/* failed to service fault */
drivers/iommu/intel-svm.c +2 -2
@@ -620,7 +620,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)if (!mmget_not_zero (svm->mm)) goto bad_req; -down_read (&svm->mm->mmap_sem); +mmap_read_lock (svm->mm); vma =find_extend_vma (svm->mm, address);if (!vma || address < vma->vm_start) goto invalid;
@@ -635,7 +635,7 @@ static irqreturn_t prq_event_thread(int irq, void *d) result =QI_RESP_SUCCESS ; invalid: -up_read (&svm->mm->mmap_sem); +mmap_read_unlock (svm->mm);mmput (svm->mm); bad_req:/* Accounting for major/minor faults? */
drivers/media/v4l2-core/videobuf-core.c +2 -2
@@ -535,7 +535,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)MAGIC_CHECK (q->int_ops->magic,MAGIC_QTYPE_OPS );if (b->memory ==V4L2_MEMORY_MMAP ) -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);videobuf_queue_lock (q); retval = -EBUSY ;
@@ -622,7 +622,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)videobuf_queue_unlock (q);if (b->memory ==V4L2_MEMORY_MMAP ) -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return retval; }
drivers/media/v4l2-core/videobuf-dma-contig.c +2 -2
@@ -169,7 +169,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, mem->size =PAGE_ALIGN (vb->size + offset); ret = -EINVAL ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, untagged_baddr);if (!vma)
@@ -201,7 +201,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, } out_up: -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return ret; }
drivers/media/v4l2-core/videobuf-dma-sg.c +2 -2
@@ -200,9 +200,9 @@ static int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction, {int ret; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); ret =videobuf_dma_init_user_locked (dma, direction, data, size); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return ret; }
drivers/misc/cxl/cxllib.c +2 -2
@@ -207,7 +207,7 @@ static int get_vma_info(struct mm_struct *mm, u64 addr,struct vm_area_struct *vma =NULL ;int rc =0 ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, addr);if (!vma) {
@@ -218,7 +218,7 @@ static int get_vma_info(struct mm_struct *mm, u64 addr, *vma_start = vma->vm_start; *vma_end = vma->vm_end; out: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return rc; }
drivers/misc/cxl/fault.c +2 -2
@@ -321,7 +321,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx)return ; } -down_read (&mm->mmap_sem); +mmap_read_lock (mm);for (vma = mm->mmap; vma; vma = vma->vm_next) {for (ea = vma->vm_start; ea < vma->vm_end; ea =next_segment (ea, slb.vsid)) {
@@ -336,7 +336,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx) last_esid = slb.esid; } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); }
drivers/misc/sgi-gru/grufault.c +8 -8
@@ -69,14 +69,14 @@ static struct gru_thread_state *gru_find_lock_gts(unsigned long vaddr)struct vm_area_struct *vma;struct gru_thread_state *gts =NULL ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =gru_find_vma (vaddr);if (vma) gts =gru_find_thread_state (vma,TSID (vaddr, vma));if (gts)mutex_lock (>s->ts_ctxlock);else -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return gts; }
@@ -86,7 +86,7 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)struct vm_area_struct *vma;struct gru_thread_state *gts =ERR_PTR (-EINVAL ); -down_write (&mm->mmap_sem); +mmap_write_lock (mm); vma =gru_find_vma (vaddr);if (!vma) goto err;
@@ -95,11 +95,11 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)if (IS_ERR (gts)) goto err;mutex_lock (>s->ts_ctxlock); -downgrade_write (&mm->mmap_sem); +mmap_write_downgrade (mm);return gts; err: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return gts; }
@@ -109,7 +109,7 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)static void gru_unlock_gts (struct gru_thread_state *gts) {mutex_unlock (>s->ts_ctxlock); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); }/*
@@ -575,9 +575,9 @@ static irqreturn_t gru_intr(int chiplet, int blade)*/ gts->ustats.fmm_tlbmiss++;if (!gts->ts_force_cch_reload && -down_read_trylock (>s->ts_mm->mmap_sem)) { +mmap_read_trylock (gts->ts_mm)) {gru_try_dropin (gru, gts, tfh,NULL ); -up_read (>s->ts_mm->mmap_sem); +mmap_read_unlock (gts->ts_mm); }else {tfh_user_polling_mode (tfh);STAT (intr_mm_lock_failed);
drivers/misc/sgi-gru/grufile.c +2 -2
@@ -135,7 +135,7 @@ static int gru_create_new_context(unsigned long arg)if (!(req.options &GRU_OPT_MISS_MASK )) req.options |=GRU_OPT_MISS_FMM_INTR ; -down_write (¤t->mm->mmap_sem); +mmap_write_lock (current->mm); vma =gru_find_vma (req.gseg);if (vma) { vdata = vma->vm_private_data;
@@ -146,7 +146,7 @@ static int gru_create_new_context(unsigned long arg) vdata->vd_tlb_preload_count = req.tlb_preload_count; ret =0 ; } -up_write (¤t->mm->mmap_sem); +mmap_write_unlock (current->mm);return ret; }
drivers/oprofile/buffer_sync.c +5 -5
@@ -91,11 +91,11 @@ munmap_notify(struct notifier_block *self, unsigned long val, void *data)struct mm_struct *mm = current->mm;struct vm_area_struct *mpnt; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); mpnt =find_vma (mm, addr);if (mpnt && mpnt->vm_file && (mpnt->vm_flags &VM_EXEC )) { -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* To avoid latency problems, we only process the current CPU, * hoping that most samples for the task are on this CPU */
@@ -103,7 +103,7 @@ munmap_notify(struct notifier_block *self, unsigned long val, void *data)return 0 ; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return 0 ; }
@@ -256,7 +256,7 @@ lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)unsigned long cookie =NO_COOKIE ;struct vm_area_struct *vma; -down_read (&mm->mmap_sem); +mmap_read_lock (mm);for (vma =find_vma (mm, addr); vma; vma = vma->vm_next) {if (addr < vma->vm_start || addr >= vma->vm_end)
@@ -276,7 +276,7 @@ lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)if (!vma) cookie =INVALID_COOKIE ; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return cookie; }
drivers/staging/kpc2000/kpc_dma/fileops.c +2 -2
@@ -75,9 +75,9 @@ static int kpc_dma_transfer(struct dev_private_data *priv, }// Lock the user buffer pages in memory, and hold on to the page pointers (for the sglist) -down_read (¤t->mm->mmap_sem);/* get memory map semaphore */ +mmap_read_lock (current->mm);/* get memory map semaphore */ rv =get_user_pages (iov_base, acd->page_count,FOLL_TOUCH |FOLL_WRITE |FOLL_GET , acd->user_pages,NULL ); -up_read (¤t->mm->mmap_sem);/* release the semaphore */ +mmap_read_unlock (current->mm);/* release the semaphore */ if (rv != acd->page_count) {dev_err (&priv->ldev->pldev->dev,"Couldn't get_user_pages (%ld)\n" , rv); goto err_get_user_pages;
drivers/tee/optee/call.c +2 -2
@@ -561,10 +561,10 @@ static int check_mem_type(unsigned long start, size_t num_pages)if (virt_addr_valid (start))return 0 ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); rc =__check_mem_type (find_vma (mm, start), start + num_pages *PAGE_SIZE ); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return rc; }
drivers/vfio/vfio_iommu_type1.c +4 -4
@@ -278,11 +278,11 @@ static int vfio_lock_acct(struct vfio_dma *dma, long npage, bool async)if (!mm)return -ESRCH ;/* process exited */ - ret =down_write_killable (&mm->mmap_sem); + ret =mmap_write_lock_killable (mm);if (!ret) { ret =__account_locked_vm (mm,abs (npage), npage >0 , dma->task, dma->lock_cap); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); }if (async)
@@ -328,7 +328,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,if (prot &IOMMU_WRITE ) flags |=FOLL_WRITE ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm); ret =pin_user_pages_remote (NULL , mm, vaddr,1 , flags |FOLL_LONGTERM , page,NULL ,NULL );if (ret ==1 ) {
@@ -347,7 +347,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, ret =0 ; } done: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ret; }
drivers/vhost/vdpa.c +2 -2
@@ -527,7 +527,7 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,if (!npages)return -EINVAL ; -down_read (&dev->mm->mmap_sem); +mmap_read_lock (dev->mm); locked =atomic64_add_return (npages, &dev->mm->pinned_vm); lock_limit =rlimit (RLIMIT_MEMLOCK ) >>PAGE_SHIFT ;
@@ -580,7 +580,7 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,vhost_vdpa_unmap (v, msg->iova, msg->size);atomic64_sub (npages, &dev->mm->pinned_vm); } -up_read (&dev->mm->mmap_sem); +mmap_read_unlock (dev->mm);free_page ((unsigned long )page_list);return ret; }
drivers/xen/gntdev.c +2 -2
@@ -625,7 +625,7 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,return -EFAULT ;pr_debug ("priv %p, offset for vaddr %lx\n" , priv, (unsigned long )op.vaddr); -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma (current->mm, op.vaddr);if (!vma || vma->vm_ops != &gntdev_vmops) goto out_unlock;
@@ -639,7 +639,7 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv, rv =0 ; out_unlock: -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (rv ==0 &©_to_user (u, &op,sizeof (op)) !=0 )return -EFAULT ;
drivers/xen/privcmd.c +7 -7
@@ -278,7 +278,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)if (rc ||list_empty (&pagelist)) goto out; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); { struct page *page = list_first_entry(&pagelist,
@@ -303,7 +303,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata) out_up: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); out:free_page_list (&pagelist);
@@ -499,7 +499,7 @@ static long privcmd_ioctl_mmap_batch( } } -down_write (&mm->mmap_sem); +mmap_write_lock (mm); vma =find_vma (mm, m.addr); if (!vma ||
@@ -555,7 +555,7 @@ static long privcmd_ioctl_mmap_batch(BUG_ON (traverse_pages_block (m.num,sizeof (xen_pfn_t), &pagelist, mmap_batch_fn, &state)); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);if (state.global_error) {/* Write back errors in second pass. */
@@ -576,7 +576,7 @@ static long privcmd_ioctl_mmap_batch(return ret; out_unlock: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); goto out; }
@@ -741,7 +741,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata)if (data->domid !=DOMID_INVALID && data->domid != kdata.dom)return -EPERM ; -down_write (&mm->mmap_sem); +mmap_write_lock (mm); vma =find_vma (mm, kdata.addr);if (!vma || vma->vm_ops != &privcmd_vm_ops) {
@@ -820,7 +820,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) } out: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);kfree (pfns);return rc;
fs/aio.c +2 -2
@@ -519,7 +519,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events) ctx->mmap_size = nr_pages *PAGE_SIZE ;pr_debug ("attempting mmap of %lu bytes\n" , ctx->mmap_size); -if (down_write_killable (&mm->mmap_sem)) { +if (mmap_write_lock_killable (mm)) { ctx->mmap_size =0 ;aio_free_ring (ctx);return -EINTR ;
@@ -528,7 +528,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events) ctx->mmap_base =do_mmap_pgoff (ctx->aio_ring_file,0 , ctx->mmap_size,PROT_READ |PROT_WRITE ,MAP_SHARED ,0 , &unused,NULL ); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);if (IS_ERR ((void *)ctx->mmap_base)) { ctx->mmap_size =0 ;aio_free_ring (ctx);
fs/coredump.c +2 -2
@@ -445,12 +445,12 @@ static int coredump_wait(int exit_code, struct core_state *core_state) core_state->dumper.task = tsk; core_state->dumper.next =NULL ; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ;if (!mm->core_state) core_waiters =zap_threads (tsk, mm, core_state, exit_code); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);if (core_waiters >0 ) {struct core_thread *ptr;
fs/exec.c +8 -8
@@ -250,7 +250,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm)return -ENOMEM ;vma_set_anonymous (vma); -if (down_write_killable (&mm->mmap_sem)) { +if (mmap_write_lock_killable (mm)) { err = -EINTR ; goto err_free; }
@@ -272,11 +272,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm) goto err; mm->stack_vm = mm->total_vm =1 ; -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); bprm->p = vma->vm_end -sizeof (void *);return 0 ; err: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); err_free: bprm->vma =NULL ;vm_area_free (vma);
@@ -737,7 +737,7 @@ int setup_arg_pages(struct linux_binprm *bprm, bprm->loader -= stack_shift; bprm->exec -= stack_shift; -if (down_write_killable (&mm->mmap_sem)) +if (mmap_write_lock_killable (mm))return -EINTR ; vm_flags =VM_STACK_FLAGS ;
@@ -799,7 +799,7 @@ int setup_arg_pages(struct linux_binprm *bprm, ret = -EFAULT ; out_unlock: -up_write (&mm->mmap_sem); +mmap_write_unlock (mm);return ret; }EXPORT_SYMBOL (setup_arg_pages);
@@ -1064,9 +1064,9 @@ static int exec_mmap(struct mm_struct *mm)* through with the exec. We must hold mmap_sem around * checking core_state and changing tsk->mm. */ -down_read (&old_mm->mmap_sem); +mmap_read_lock (old_mm);if (unlikely (old_mm->core_state)) { -up_read (&old_mm->mmap_sem); +mmap_read_unlock (old_mm);mutex_unlock (&tsk->signal->exec_update_mutex);return -EINTR ; }
@@ -1082,7 +1082,7 @@ static int exec_mmap(struct mm_struct *mm)vmacache_flush (tsk);task_unlock (tsk);if (old_mm) { -up_read (&old_mm->mmap_sem); +mmap_read_unlock (old_mm);BUG_ON (active_mm != old_mm);setmax_mm_hiwater_rss (&tsk->signal->maxrss, old_mm);mm_update_next_owner (old_mm);
fs/io_uring.c +2 -2
@@ -7105,7 +7105,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg, } ret =0 ; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); pret =pin_user_pages (ubuf, nr_pages,FOLL_WRITE |FOLL_LONGTERM , pages, vmas);
@@ -7123,7 +7123,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg, }else { ret = pret <0 ? pret : -EFAULT ; } -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);if (ret) {/* * if we did partial map, or found file backed vmas,
fs/proc/base.c +6 -6
@@ -2104,11 +2104,11 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags) goto out;if (!dname_to_vma_addr (dentry, &vm_start, &vm_end)) { - status =down_read_killable (&mm->mmap_sem); + status =mmap_read_lock_killable (mm);if (!status) { exact_vma_exists = !!find_exact_vma (mm, vm_start, vm_end); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); } }
@@ -2155,7 +2155,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)if (rc) goto out_mmput; - rc =down_read_killable (&mm->mmap_sem); + rc =mmap_read_lock_killable (mm);if (rc) goto out_mmput;
@@ -2166,7 +2166,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)path_get (path); rc =0 ; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out_mmput:mmput (mm);
@@ -2256,7 +2256,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, goto out_put_task; result =ERR_PTR (-EINTR ); -if (down_read_killable (&mm->mmap_sem)) +if (mmap_read_lock_killable (mm)) goto out_put_mm; result =ERR_PTR (-ENOENT );
@@ -2269,7 +2269,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, (void *)(unsigned long)vma->vm_file->f_mode); out_no_vma: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out_put_mm:mmput (mm); out_put_task:
fs/proc/task_mmu.c +14 -14
@@ -145,7 +145,7 @@ static void *m_start(struct seq_file *m, loff_t *ppos)return NULL ; } -if (down_read_killable (&mm->mmap_sem)) { +if (mmap_read_lock_killable (mm)) {mmput (mm);put_task_struct (priv->task); priv->task =NULL ;
@@ -188,7 +188,7 @@ static void m_stop(struct seq_file *m, void *v)return ;release_task_mempolicy (priv); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);put_task_struct (priv->task); priv->task =NULL ;
@@ -841,7 +841,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)memset (&mss,0 ,sizeof (mss)); - ret =down_read_killable (&mm->mmap_sem); + ret =mmap_read_lock_killable (mm);if (ret) goto out_put_mm;
@@ -860,7 +860,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)__show_smap (m, &mss, true);release_task_mempolicy (priv); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); out_put_mm:mmput (mm);
@@ -1134,7 +1134,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, };if (type ==CLEAR_REFS_MM_HIWATER_RSS ) { -if (down_write_killable (&mm->mmap_sem)) { +if (mmap_write_lock_killable (mm)) { count = -EINTR ; goto out_mm; }
@@ -1144,11 +1144,11 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,* resident set size to this mm's current rss value. */ reset_mm_hiwater_rss (mm); -up_write (&mm->mmap_sem); +mmap_write_unlock (mm); goto out_mm; } -if (down_read_killable (&mm->mmap_sem)) { +if (mmap_read_lock_killable (mm)) { count = -EINTR ; goto out_mm; }
@@ -1157,8 +1157,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,for (vma = mm->mmap; vma; vma = vma->vm_next) {if (!(vma->vm_flags &VM_SOFTDIRTY ))continue ; -up_read (&mm->mmap_sem); -if (down_write_killable (&mm->mmap_sem)) { +mmap_read_unlock (mm); +if (mmap_write_lock_killable (mm)) {
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Part of the diff is not shown here. View the raw message.
PATCH v6 5/12 mmap locking API: convert mmap_sem call sites missed by coccinelle
In reply to Michel LespinasseConvert the last few remaining mmap_sem rwsem calls to use the new mmap locking API. These were missed by coccinelle for some reason (I think coccinelle does not support some of the preprocessor constructs in these files ?)
--- arch/mips/mm/fault.c | 10 +++++----- arch/riscv/mm/pageattr.c | 4 ++-- arch/x86/kvm/mmu/paging_tmpl.h | 8 ++++---- fs/proc/base.c | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-)
arch/mips/mm/fault.c +5 -5
@@ -97,7 +97,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; retry: -down_read (&mm->mmap_sem); +mmap_read_lock (mm); vma =find_vma (mm, address);if (!vma) goto bad_area;
@@ -190,7 +190,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, } } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);return ;/*
@@ -198,7 +198,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,* Fix it, but check if it's kernel or user first.. */ bad_area: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm); bad_area_nosemaphore:/* User mode accesses just cause a SIGSEGV */
@@ -250,14 +250,14 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,* We ran out of memory, call the OOM killer, and return the userspace * (which will retry the fault, or kill us if we got oom-killed). */ -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (!user_mode (regs)) goto no_context;pagefault_out_of_memory ();return ; do_sigbus: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
arch/riscv/mm/pageattr.c +2 -2
@@ -117,10 +117,10 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask,if (!numpages)return 0 ; -down_read (&init_mm.mmap_sem); +mmap_read_lock (&init_mm); ret =walk_page_range_novma (&init_mm, start, end, &pageattr_ops,NULL , &masks); -up_read (&init_mm.mmap_sem); +mmap_read_unlock (&init_mm);flush_tlb_kernel_range (start, end);
arch/x86/kvm/mmu/paging_tmpl.h +4 -4
@@ -165,22 +165,22 @@ static int FNAME(cmpxchg_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,unsigned long pfn;unsigned long paddr; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma_intersection (current->mm, vaddr, vaddr +PAGE_SIZE );if (!vma || !(vma->vm_flags &VM_PFNMAP )) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return -EFAULT ; } pfn = ((vaddr - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff; paddr = pfn <<PAGE_SHIFT ; table =memremap (paddr,PAGE_SIZE ,MEMREMAP_WB );if (!table) { -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return -EFAULT ; } ret =CMPXCHG (&table[index], orig_pte, new_pte);memunmap (table); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm); }return (ret != orig_pte);
fs/proc/base.c +3 -3
@@ -2314,7 +2314,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)if (!mm) goto out_put_task; - ret =down_read_killable (&mm->mmap_sem); + ret =mmap_read_lock_killable (mm);if (ret) {mmput (mm); goto out_put_task;
@@ -2341,7 +2341,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) p =genradix_ptr_alloc (&fa, nr_files++,GFP_KERNEL );if (!p) { ret = -ENOMEM ; -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm); goto out_put_task; }
@@ -2350,7 +2350,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) p->end = vma->vm_end; p->mode = vma->vm_file->f_mode; } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);for (i =0 ; i < nr_files; i++) {
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Andrew Morton
maintainerRe: [PATCH v6 05/12] mmap locking API: convert mmap_sem call sites missed by coccinelle
Quoted 4 lines · On Tue, 19 May 2020 22:29:01 -0700 Michel Lespinasse <[email protected]> wrote:
Convert the last few remaining
mmap_semrwsem calls to use the new mmap locking API. These were missed by coccinelle for some reason (I think coccinelle does not support some of the preprocessor constructs in these files ?)
From: Andrew Morton <[email protected]>
Subject: mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix
convert linux-next leftovers
---
arch/arm64/kvm/mmu.c | 14 +++++++------- lib/test_hmm.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
lib/test_hmm.c renamed from lib/test_hmm.c~mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix +7 -7
@@ -243,9 +243,9 @@ static int dmirror_range_fault(struct dm } range->notifier_seq =mmu_interval_read_begin (range->notifier); -down_read (&mm->mmap_sem); +mmap_read_lock (mm); ret =hmm_range_fault (range); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (ret) {if (ret == -EBUSY )continue ;
@@ -684,7 +684,7 @@ static int dmirror_migrate(struct dmirroif (!mmget_not_zero (mm))return -EINVAL ; -down_read (&mm->mmap_sem); +mmap_read_lock (mm);for (addr = start; addr < end; addr = next) { vma =find_vma (mm, addr); if (!vma || addr < vma->vm_start ||
@@ -711,7 +711,7 @@ static int dmirror_migrate(struct dmirrodmirror_migrate_finalize_and_map (&args, dmirror);migrate_vma_finalize (&args); } -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);/* Return the migrated data for verification. */
@@ -731,7 +731,7 @@ static int dmirror_migrate(struct dmirroreturn ret; out: -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);mmput (mm);return ret; }
@@ -823,9 +823,9 @@ static int dmirror_range_snapshot(struct range->notifier_seq =mmu_interval_read_begin (range->notifier); -down_read (&mm->mmap_sem); +mmap_read_lock (mm); ret =hmm_range_fault (range); -up_read (&mm->mmap_sem); +mmap_read_unlock (mm);if (ret) {if (ret == -EBUSY )continue ;
arch/arm64/kvm/mmu.c renamed from arch/arm64/kvm/mmu.c~mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix +7 -7
@@ -1084,7 +1084,7 @@ void stage2_unmap_vm(struct kvm *kvm)int idx; idx =srcu_read_lock (&kvm->srcu); -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);spin_lock (&kvm->mmu_lock); slots =kvm_memslots (kvm);
@@ -1092,7 +1092,7 @@ void stage2_unmap_vm(struct kvm *kvm)stage2_unmap_memslot (kvm, memslot);spin_unlock (&kvm->mmu_lock); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);srcu_read_unlock (&kvm->srcu, idx); }
@@ -1848,11 +1848,11 @@ static int user_mem_abort(struct kvm_vcp }/* Let's check if we will get back a huge page backed by hugetlbfs */ -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm); vma =find_vma_intersection (current->mm, hva, hva +1 );if (unlikely (!vma)) {kvm_err ("Failed to find VMA for hva 0x%lx\n" , hva); -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return -EFAULT ; }
@@ -1879,7 +1879,7 @@ static int user_mem_abort(struct kvm_vcpif (vma_pagesize ==PMD_SIZE || (vma_pagesize ==PUD_SIZE &&kvm_stage2_has_pmd (kvm))) gfn = (fault_ipa &huge_page_mask (hstate_vma (vma))) >>PAGE_SHIFT ; -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);/* We need minimum second+third level pages */ ret = mmu_topup_memory_cache(memcache, kvm_mmu_cache_min_pages(kvm),
@@ -2456,7 +2456,7 @@ int kvm_arch_prepare_memory_region(struc (kvm_phys_size(kvm) >> PAGE_SHIFT))return -EFAULT ; -down_read (¤t->mm->mmap_sem); +mmap_read_lock (current->mm);/* * A memory region could potentially cover multiple VMAs, and any holes * between them, so iterate over all of them to find out if we can map
@@ -2515,7 +2515,7 @@ int kvm_arch_prepare_memory_region(strucstage2_flush_memslot (kvm, memslot);spin_unlock (&kvm->mmu_lock); out: -up_read (¤t->mm->mmap_sem); +mmap_read_unlock (current->mm);return ret; }
_
Michel Lespinasse
Reviewed-byRe: [PATCH v6 05/12] mmap locking API: convert mmap_sem call sites missed by coccinelle
Looks good. I'm not sure if you need a review, but just in case:
Quoted 12 lines · Andrew Morton
Quoted 4 lines · On Tue, 19 May 2020 22:29:01 -0700 Michel Lespinasse <[email protected]> wrote:
Convert the last few remaining
mmap_semrwsem calls to use the new mmap locking API. These were missed by coccinelle for some reason (I think coccinelle does not support some of the preprocessor constructs in these files ?)From: Andrew Morton <[email protected]>
Subject: mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fixconvert linux-next leftovers
Quoted 15 lines
Cc Michel Lespinasse <[email protected]>Cc Daniel Jordan <[email protected]>Cc Laurent Dufour <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Davidlohr Bueso <[email protected]>Cc David Rientjes <[email protected]>Cc Hugh Dickins <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Jerome Glisse <[email protected]>Cc John Hubbard <[email protected]>Cc Liam Howlett <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Ying Han <[email protected]>Signed-off-by Andrew Morton <[email protected]>
PATCH v6 6/12 mmap locking API: convert nested write lock sites
In reply to Michel LespinasseAdd API for nested write locks and convert the few call sites doing that.
--- arch/um/include/asm/mmu_context.h | 3 ++- include/linux/mmap_lock.h | 5 +++++ kernel/fork.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
arch/um/include/asm/mmu_context.h +2 -1
@@ -8,6 +8,7 @@#include <linux/sched.h> #include <linux/mm_types.h> +#include <linux/mmap_lock.h> #include <asm/mmu.h>
@@ -47,7 +48,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)* when the new ->mm is used for the first time. */ __switch_mm (&new->context.id); -down_write_nested (&new->mmap_sem,1 ); +mmap_write_lock_nested (new,SINGLE_DEPTH_NESTING );uml_setup_stubs (new);mmap_write_unlock (new); }
include/linux/mmap_lock.h +5 -0
@@ -11,6 +11,11 @@ static inline void mmap_write_lock(struct mm_struct *mm)down_write (&mm->mmap_sem); } +static inline void mmap_write_lock_nested (struct mm_struct *mm,int subclass) +{ +down_write_nested (&mm->mmap_sem, subclass); +} +static inline int mmap_write_lock_killable (struct mm_struct *mm) {return down_write_killable (&mm->mmap_sem);
kernel/fork.c +1 -1
@@ -499,7 +499,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,/* * Not linked in yet - no deadlock potential: */ -down_write_nested (&mm->mmap_sem,SINGLE_DEPTH_NESTING ); +mmap_write_lock_nested (mm,SINGLE_DEPTH_NESTING );/* No ordering required: file already has been exposed. */ RCU_INIT_POINTER (mm->exe_file,get_mm_exe_file (oldmm));
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 7/12 mmap locking API: add mmap_read_trylock_non_owner()
In reply to Michel LespinasseAdd a couple APIs used by kernel/bpf/stackmap.c only:
- mmap_read_trylock_non_owner()
- mmap_read_unlock_non_owner() (may be called from a work queue).
It's still not ideal that bpf/stackmap subverts the lock ownership in this way. Thanks to Peter Zijlstra for suggesting this API as the least-ugly way of addressing this in the short term.
--- include/linux/mmap_lock.h | 14 ++++++++++++++ kernel/bpf/stackmap.c | 17 +++++------------ 2 files changed, 19 insertions(+), 12 deletions(-)
include/linux/mmap_lock.h +14 -0
@@ -56,4 +56,18 @@ static inline void mmap_read_unlock(struct mm_struct *mm) up_read(&mm->mmap_sem); } +static inline bool mmap_read_trylock_non_owner (struct mm_struct *mm) +{ +if (down_read_trylock (&mm->mmap_sem)) { +rwsem_release (&mm->mmap_sem.dep_map, _RET_IP_); +return true; + } +return false; +} + +static inline void mmap_read_unlock_non_owner (struct mm_struct *mm) +{ +up_read_non_owner (&mm->mmap_sem); +} +#endif /* _LINUX_MMAP_LOCK_H */
kernel/bpf/stackmap.c +5 -12
@@ -33,7 +33,7 @@ struct bpf_stack_map {/* irq_work to run up_read() for build_id lookup in nmi context */ struct stack_map_irq_work {struct irq_work irq_work; -struct rw_semaphore *sem; +struct mm_struct *mm; };static void do_up_read (struct irq_work *entry)
@@ -44,8 +44,7 @@ static void do_up_read(struct irq_work *entry)return ; work = container_of(entry, struct stack_map_irq_work, irq_work); -up_read_non_owner (work->sem); - work->sem =NULL ; +mmap_read_unlock_non_owner (work->mm); } static DEFINE_PER_CPU(struct stack_map_irq_work, up_read_work);
@@ -317,7 +316,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,* with build_id. */ if (!user || !current || !current->mm || irq_work_busy || -mmap_read_trylock (current->mm) ==0 ) { + !mmap_read_trylock_non_owner (current->mm)) {/* cannot access current->mm, fall back to ips */ for (i =0 ; i < trace_nr; i++) { id_offs[i].status =BPF_STACK_BUILD_ID_IP ;
@@ -342,16 +341,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, }if (!work) { -mmap_read_unlock (current->mm); +mmap_read_unlock_non_owner (current->mm); }else { - work->sem = ¤t->mm->mmap_sem; + work->mm = current->mm;irq_work_queue (&work->irq_work); -/* -* The irq_work will release the mmap_sem with -* up_read_non_owner(). The rwsem_release() is called -* here to release the lock from lockdep's perspective. -*/ -rwsem_release (¤t->mm->mmap_sem.dep_map, _RET_IP_); } }
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Re: [PATCH v6 07/12] mmap locking API: add mmap_read_trylock_non_owner()
Quoted 11 lines · Michel Lespinasse
Add a couple APIs used by
kernel/bpf/stackmap.conly:
-mmap_read_trylock_non_owner()
-mmap_read_unlock_non_owner()(may be called from a work queue).It's still not ideal that bpf/stackmap subverts the lock ownership in this way. Thanks to Peter Zijlstra for suggesting this API as the least-ugly way of addressing this in the short term.
Signed-off-by Michel Lespinasse <[email protected]>Reviewed-by Daniel Jordan <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>
Sigh, bpf, but ok.
Quoted 82 lines
---
include/linux/mmap_lock.h| 14 ++++++++++++++kernel/bpf/stackmap.c| 17 +++++------------2 files changed, 19 insertions(+), 12 deletions(-)include/linux/mmap_lock.h +14
-0@@ -56,4 +56,18 @@ static inline void mmap_read_unlock(struct mm_struct *mm) up_read(&mm->mmap_sem); } +static inline bool mmap_read_trylock_non_owner (struct mm_struct *mm) +{ +if (down_read_trylock (&mm->mmap_sem)) { +rwsem_release (&mm->mmap_sem.dep_map, _RET_IP_); +return true; + } +return false; +} + +static inline void mmap_read_unlock_non_owner (struct mm_struct *mm) +{ +up_read_non_owner (&mm->mmap_sem); +} +#endif /* _LINUX_MMAP_LOCK_H */ kernel/bpf/stackmap.c +5
-12@@ -33,7 +33,7 @@ struct bpf_stack_map {/* irq_work to run up_read() for build_id lookup in nmi context */ struct stack_map_irq_work {struct irq_work irq_work; -struct rw_semaphore *sem; +struct mm_struct *mm; };static void do_up_read (struct irq_work *entry)@@ -44,8 +44,7 @@ static void do_up_read(struct irq_work *entry)return ; work = container_of(entry, struct stack_map_irq_work, irq_work); -up_read_non_owner (work->sem); - work->sem =NULL ; +mmap_read_unlock_non_owner (work->mm); } static DEFINE_PER_CPU(struct stack_map_irq_work, up_read_work);@@ -317,7 +316,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,* with build_id. */ if (!user || !current || !current->mm || irq_work_busy || -mmap_read_trylock (current->mm) ==0 ) { + !mmap_read_trylock_non_owner (current->mm)) {/* cannot access current->mm, fall back to ips */ for (i =0 ; i < trace_nr; i++) { id_offs[i].status =BPF_STACK_BUILD_ID_IP ;@@ -342,16 +341,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, }if (!work) { -mmap_read_unlock (current->mm); +mmap_read_unlock_non_owner (current->mm); }else { - work->sem = ¤t->mm->mmap_sem; + work->mm = current->mm;irq_work_queue (&work->irq_work); -/* -* The irq_work will release the mmap_sem with -* up_read_non_owner(). The rwsem_release() is called -* here to release the lock from lockdep's perspective. -*/ -rwsem_release (¤t->mm->mmap_sem.dep_map, _RET_IP_); } }Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
PATCH v6 8/12 mmap locking API: add MMAP_LOCK_INITIALIZER
In reply to Michel LespinasseDefine a new initializer for the mmap locking api. Initially this just evaluates to __RWSEM_INITIALIZER as the API is defined as wrappers around rwsem.
--- arch/x86/kernel/tboot.c | 2 +- drivers/firmware/efi/efi.c | 2 +- include/linux/mmap_lock.h | 3 +++ mm/init-mm.c | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/tboot.c +1 -1
@@ -90,7 +90,7 @@ static struct mm_struct tboot_mm = { .pgd = swapper_pg_dir, .mm_users = ATOMIC_INIT(2), .mm_count =ATOMIC_INIT (1 ), - .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), +MMAP_LOCK_INITIALIZER (init_mm) .page_table_lock =__SPIN_LOCK_UNLOCKED (init_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist), };
drivers/firmware/efi/efi.c +1 -1
@@ -54,7 +54,7 @@ struct mm_struct efi_mm = { .mm_rb = RB_ROOT, .mm_users = ATOMIC_INIT(2), .mm_count =ATOMIC_INIT (1 ), - .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), +MMAP_LOCK_INITIALIZER (efi_mm) .page_table_lock =__SPIN_LOCK_UNLOCKED (efi_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0},
include/linux/mmap_lock.h +3 -0
@@ -1,6 +1,9 @@#ifndef _LINUX_MMAP_LOCK_H#define _LINUX_MMAP_LOCK_H +#define MMAP_LOCK_INITIALIZER (name) \ + .mmap_sem = __RWSEM_INITIALIZER((name).mmap_sem), +static inline void mmap_init_lock (struct mm_struct *mm) {init_rwsem (&mm->mmap_sem);
mm/init-mm.c +1 -1
@@ -31,7 +31,7 @@ struct mm_struct init_mm = { .pgd = swapper_pg_dir, .mm_users = ATOMIC_INIT(2), .mm_count =ATOMIC_INIT (1 ), - .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), +MMAP_LOCK_INITIALIZER (init_mm) .page_table_lock =__SPIN_LOCK_UNLOCKED (init_mm.page_table_lock), .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist),
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Re: [PATCH v6 08/12] mmap locking API: add MMAP_LOCK_INITIALIZER
Quoted 7 lines · Michel Lespinasse
Define a new initializer for the mmap locking api. Initially this just evaluates to
__RWSEM_INITIALIZERas the API is defined as wrappers around rwsem.Signed-off-by Michel Lespinasse <[email protected]>Reviewed-by Laurent Dufour <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>
PATCH v6 9/12 mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()
In reply to Michel LespinasseAdd new APIs to assert that mmap_sem is held.
Using this instead of rwsem_is_locked and lockdep_assert_held[_write] makes the assertions more tolerant of future changes to the lock type.
--- arch/x86/events/core.c | 2 +- fs/userfaultfd.c | 6 +++--- include/linux/mmap_lock.h | 14 ++++++++++++++ mm/gup.c | 2 +- mm/hmm.c | 2 +- mm/memory.c | 2 +- mm/mmu_notifier.c | 6 +++--- mm/pagewalk.c | 6 +++--- mm/util.c | 2 +- 9 files changed, 28 insertions(+), 14 deletions(-)
arch/x86/events/core.c +1 -1
@@ -2182,7 +2182,7 @@ static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)* For now, this can't happen because all callers hold mmap_sem * for write. If this changes, we'll need a different solution. */ -lockdep_assert_held_write (&mm->mmap_sem); +mmap_assert_write_locked (mm);if (atomic_inc_return (&mm->context.perf_rdpmc_allowed) ==1 )on_each_cpu_mask (mm_cpumask (mm), refresh_pce,NULL ,1 );
fs/userfaultfd.c +3 -3
@@ -234,7 +234,7 @@ static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx,pte_t *ptep, pte;bool ret = true; -VM_BUG_ON (!rwsem_is_locked (&mm->mmap_sem)); +mmap_assert_locked (mm); ptep =huge_pte_offset (mm, address,vma_mmu_pagesize (vma));
@@ -286,7 +286,7 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx,pte_t *pte;bool ret = true; -VM_BUG_ON (!rwsem_is_locked (&mm->mmap_sem)); +mmap_assert_locked (mm); pgd =pgd_offset (mm, address);if (!pgd_present (*pgd))
@@ -405,7 +405,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)* Coredumping runs without mmap_sem so we can only check that * the mmap_sem is held, if PF_DUMPCORE was not set. */ -WARN_ON_ONCE (!rwsem_is_locked (&mm->mmap_sem)); +mmap_assert_locked (mm); ctx = vmf->vma->vm_userfaultfd_ctx.ctx;if (!ctx)
include/linux/mmap_lock.h +14 -0
@@ -1,6 +1,8 @@#ifndef _LINUX_MMAP_LOCK_H#define _LINUX_MMAP_LOCK_H +#include <linux/mmdebug.h> +#define MMAP_LOCK_INITIALIZER (name) \ .mmap_sem = __RWSEM_INITIALIZER((name).mmap_sem),
@@ -73,4 +75,16 @@ static inline void mmap_read_unlock_non_owner(struct mm_struct *mm) up_read_non_owner(&mm->mmap_sem); } +static inline void mmap_assert_locked (struct mm_struct *mm) +{ +lockdep_assert_held (&mm->mmap_sem); +VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_sem), mm); +} + +static inline void mmap_assert_write_locked (struct mm_struct *mm) +{ +lockdep_assert_held_write (&mm->mmap_sem); +VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_sem), mm); +} +#endif /* _LINUX_MMAP_LOCK_H */
mm/gup.c +1 -1
@@ -1405,7 +1405,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,VM_BUG_ON (end & ~PAGE_MASK );VM_BUG_ON_VMA (start < vma->vm_start, vma);VM_BUG_ON_VMA (end > vma->vm_end, vma); -VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_sem), mm); +mmap_assert_locked (mm); gup_flags =FOLL_TOUCH |FOLL_POPULATE |FOLL_MLOCK ;if (vma->vm_flags &VM_LOCKONFAULT )
mm/hmm.c +1 -1
@@ -581,7 +581,7 @@ long hmm_range_fault(struct hmm_range *range)struct mm_struct *mm = range->notifier->mm;int ret; -lockdep_assert_held (&mm->mmap_sem); +mmap_assert_locked (mm); do { /* If range is no longer valid force retry. */
mm/memory.c +1 -1
@@ -1214,7 +1214,7 @@ static inline unsigned long zap_pud_range(struct mmu_gather *tlb, next =pud_addr_end (addr, end);if (pud_trans_huge (*pud) ||pud_devmap (*pud)) {if (next - addr !=HPAGE_PUD_SIZE ) { -VM_BUG_ON_VMA (!rwsem_is_locked (&tlb->mm->mmap_sem), vma); +mmap_assert_locked (tlb->mm);split_huge_pud (vma, pud, addr); }else if (zap_huge_pud (tlb, vma, pud, addr)) goto next;
mm/mmu_notifier.c +3 -3
@@ -609,7 +609,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,struct mmu_notifier_subscriptions *subscriptions =NULL ;int ret; -lockdep_assert_held_write (&mm->mmap_sem); +mmap_assert_write_locked (mm);BUG_ON (atomic_read (&mm->mm_users) <=0 );if (IS_ENABLED (CONFIG_LOCKDEP )) {
@@ -761,7 +761,7 @@ struct mmu_notifier *mmu_notifier_get_locked(const struct mmu_notifier_ops *ops,struct mmu_notifier *subscription;int ret; -lockdep_assert_held_write (&mm->mmap_sem); +mmap_assert_write_locked (mm);if (mm->notifier_subscriptions) { subscription =find_get_mmu_notifier (mm, ops);
@@ -1006,7 +1006,7 @@ int mmu_interval_notifier_insert_locked( mm->notifier_subscriptions;int ret; -lockdep_assert_held_write (&mm->mmap_sem); +mmap_assert_write_locked (mm);if (!subscriptions || !subscriptions->has_itree) { ret =__mmu_notifier_register (NULL , mm);
mm/pagewalk.c +3 -3
@@ -395,7 +395,7 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,if (!walk.mm)return -EINVAL ; -lockdep_assert_held (&walk.mm->mmap_sem); +mmap_assert_locked (walk.mm); vma =find_vma (walk.mm, start); do {
@@ -453,7 +453,7 @@ int walk_page_range_novma(struct mm_struct *mm, unsigned long start,if (start >= end || !walk.mm)return -EINVAL ; -lockdep_assert_held (&walk.mm->mmap_sem); +mmap_assert_locked (walk.mm);return __walk_page_range (start, end, &walk); }
@@ -472,7 +472,7 @@ int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,if (!walk.mm)return -EINVAL ; -lockdep_assert_held (&walk.mm->mmap_sem); +mmap_assert_locked (walk.mm); err =walk_page_test (vma->vm_start, vma->vm_end, &walk);if (err >0 )
mm/util.c +1 -1
@@ -437,7 +437,7 @@ int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc,unsigned long locked_vm, limit;int ret =0 ; -lockdep_assert_held_write (&mm->mmap_sem); +mmap_assert_write_locked (mm); locked_vm = mm->locked_vm;if (inc) {
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Re: [PATCH v6 09/12] mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()
Quoted 6 lines · Michel Lespinasse
Add new APIs to assert that
mmap_semis held.Using this instead of
rwsem_is_lockedand lockdep_assert_held[_write] makes the assertions more tolerant of future changes to the lock type.Signed-off-by Michel Lespinasse <[email protected]>
Re: [PATCH v6 09/12] mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()
In reply to Michel LespinasseQuoted 6 lines · Michel Lespinasse
Add new APIs to assert that
mmap_semis held.Using this instead of
rwsem_is_lockedand lockdep_assert_held[_write] makes the assertions more tolerant of future changes to the lock type.Signed-off-by Michel Lespinasse <[email protected]>
PATCH v6 10/12 mmap locking API: rename mmap_sem to mmap_lock
In reply to Michel LespinasseRename the mmap_sem field to mmap_lock. Any new uses of this lock should now go through the new mmap locking api. The mmap_lock is still implemented as a rwsem, though this could change in the future.
--- arch/ia64/mm/fault.c | 4 +-- arch/x86/mm/fault.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- include/linux/mm_types.h | 2 +- include/linux/mmap_lock.h | 38 +++++++++++++-------------- mm/memory.c | 2 +- mm/mmap.c | 4 +-- mm/mmu_notifier.c | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-)
arch/ia64/mm/fault.c +2 -2
@@ -70,8 +70,8 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re mask = ((((isr >>IA64_ISR_X_BIT ) &1UL ) <<VM_EXEC_BIT ) | (((isr >>IA64_ISR_W_BIT ) &1UL ) <<VM_WRITE_BIT )); -/* mmap_sem is performance critical.... */ -prefetchw (&mm->mmap_sem); +/* mmap_lock is performance critical.... */ +prefetchw (&mm->mmap_lock);/* * If we're in an interrupt or have no user context, we must not take the fault..
arch/x86/mm/fault.c +1 -1
@@ -1522,7 +1522,7 @@ dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long hw_error_code, unsigned long address) { - prefetchw(¤t->mm->mmap_sem); + prefetchw(¤t->mm->mmap_lock);trace_page_fault_entries (regs, hw_error_code, address);if (unlikely (kmmio_fault (regs, address)))
drivers/gpu/drm/etnaviv/etnaviv_gem.c +1 -1
@@ -661,7 +661,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj)struct etnaviv_gem_userptr *userptr = &etnaviv_obj->userptr;int ret, pinned =0 , npages = etnaviv_obj->base.size >>PAGE_SHIFT ; -might_lock_read (¤t->mm->mmap_sem); +might_lock_read (¤t->mm->mmap_lock);if (userptr->mm != current->mm)return -EPERM ;
include/linux/mm_types.h +1 -1
@@ -436,7 +436,7 @@ struct mm_struct {spinlock_t page_table_lock;/* Protects page tables and some * counters */ -struct rw_semaphore mmap_sem; +struct rw_semaphore mmap_lock;struct list_head mmlist;/* List of maybe swapped mm's. These * are globally strung together off
include/linux/mmap_lock.h +19 -19
@@ -4,67 +4,67 @@#include <linux/mmdebug.h> #define MMAP_LOCK_INITIALIZER (name) \ - .mmap_sem = __RWSEM_INITIALIZER((name).mmap_sem), + .mmap_lock = __RWSEM_INITIALIZER((name).mmap_lock),static inline void mmap_init_lock (struct mm_struct *mm) { -init_rwsem (&mm->mmap_sem); +init_rwsem (&mm->mmap_lock); }static inline void mmap_write_lock (struct mm_struct *mm) { -down_write (&mm->mmap_sem); +down_write (&mm->mmap_lock); }static inline void mmap_write_lock_nested (struct mm_struct *mm,int subclass) { -down_write_nested (&mm->mmap_sem, subclass); +down_write_nested (&mm->mmap_lock, subclass); }static inline int mmap_write_lock_killable (struct mm_struct *mm) { -return down_write_killable (&mm->mmap_sem); +return down_write_killable (&mm->mmap_lock); }static inline bool mmap_write_trylock (struct mm_struct *mm) { -return down_write_trylock (&mm->mmap_sem) !=0 ; +return down_write_trylock (&mm->mmap_lock) !=0 ; }static inline void mmap_write_unlock (struct mm_struct *mm) { -up_write (&mm->mmap_sem); +up_write (&mm->mmap_lock); }static inline void mmap_write_downgrade (struct mm_struct *mm) { -downgrade_write (&mm->mmap_sem); +downgrade_write (&mm->mmap_lock); }static inline void mmap_read_lock (struct mm_struct *mm) { -down_read (&mm->mmap_sem); +down_read (&mm->mmap_lock); }static inline int mmap_read_lock_killable (struct mm_struct *mm) { -return down_read_killable (&mm->mmap_sem); +return down_read_killable (&mm->mmap_lock); }static inline bool mmap_read_trylock (struct mm_struct *mm) { -return down_read_trylock (&mm->mmap_sem) !=0 ; +return down_read_trylock (&mm->mmap_lock) !=0 ; }static inline void mmap_read_unlock (struct mm_struct *mm) { -up_read (&mm->mmap_sem); +up_read (&mm->mmap_lock); }static inline bool mmap_read_trylock_non_owner (struct mm_struct *mm) { -if (down_read_trylock (&mm->mmap_sem)) { -rwsem_release (&mm->mmap_sem.dep_map, _RET_IP_); +if (down_read_trylock (&mm->mmap_lock)) { +rwsem_release (&mm->mmap_lock.dep_map, _RET_IP_);return true; }return false;
@@ -72,19 +72,19 @@ static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)static inline void mmap_read_unlock_non_owner (struct mm_struct *mm) { -up_read_non_owner (&mm->mmap_sem); +up_read_non_owner (&mm->mmap_lock); }static inline void mmap_assert_locked (struct mm_struct *mm) { -lockdep_assert_held (&mm->mmap_sem); -VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_sem), mm); +lockdep_assert_held (&mm->mmap_lock); +VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_lock), mm); }static inline void mmap_assert_write_locked (struct mm_struct *mm) { -lockdep_assert_held_write (&mm->mmap_sem); -VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_sem), mm); +lockdep_assert_held_write (&mm->mmap_lock); +VM_BUG_ON_MM (!rwsem_is_locked (&mm->mmap_lock), mm); }#endif /* _LINUX_MMAP_LOCK_H */
mm/memory.c +1 -1
@@ -4811,7 +4811,7 @@ void __might_fault(const char *file, int line)__might_sleep (file, line,0 );#if defined(CONFIG_DEBUG_ATOMIC_SLEEP )if (current->mm) -might_lock_read (¤t->mm->mmap_sem); +might_lock_read (¤t->mm->mmap_lock);#endif }EXPORT_SYMBOL (__might_fault);
mm/mmap.c +2 -2
@@ -3474,7 +3474,7 @@ static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma)* The LSB of head.next can't change from under us * because we hold the mm_all_locks_mutex. */ -down_write_nest_lock (&anon_vma->root->rwsem, &mm->mmap_sem); +down_write_nest_lock (&anon_vma->root->rwsem, &mm->mmap_lock);/* * We can safely modify head.next after taking the * anon_vma->root->rwsem. If some other vma in this mm shares
@@ -3504,7 +3504,7 @@ static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping)*/ if (test_and_set_bit (AS_MM_ALL_LOCKS , &mapping->flags))BUG (); -down_write_nest_lock (&mapping->i_mmap_rwsem, &mm->mmap_sem); +down_write_nest_lock (&mapping->i_mmap_rwsem, &mm->mmap_lock); } }
mm/mmu_notifier.c +1 -1
@@ -983,7 +983,7 @@ int mmu_interval_notifier_insert(struct mmu_interval_notifier *interval_sub,struct mmu_notifier_subscriptions *subscriptions;int ret; -might_lock (&mm->mmap_sem); +might_lock (&mm->mmap_lock); subscriptions =smp_load_acquire (&mm->notifier_subscriptions);if (!subscriptions || !subscriptions->has_itree) {
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Re: [PATCH v6 10/12] mmap locking API: rename mmap_sem to mmap_lock
Quoted 6 lines · Michel Lespinasse
Rename the
mmap_semfield tommap_lock. Any new uses of this lock should now go through the new mmap locking api. Themmap_lockis still implemented as a rwsem, though this could change in the future.Signed-off-by Michel Lespinasse <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>
Re: [PATCH v6 10/12] mmap locking API: rename mmap_sem to mmap_lock
In reply to Michel LespinasseQuoted 6 lines · Michel Lespinasse
Rename the
mmap_semfield tommap_lock. Any new uses of this lock should now go through the new mmap locking api. Themmap_lockis still implemented as a rwsem, though this could change in the future.Signed-off-by Michel Lespinasse <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>
PATCH v6 11/12 mmap locking API: convert mmap_sem API comments
In reply to Michel LespinasseConvert comments that reference old mmap_sem APIs to reference corresponding new mmap locking APIs instead.
--- Documentation/vm/hmm.rst | 6 +++--- arch/alpha/mm/fault.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/mm/fault.c | 2 +- arch/microblaze/mm/fault.c | 2 +- arch/mips/mm/fault.c | 2 +- arch/nds32/mm/fault.c | 2 +- arch/nios2/mm/fault.c | 2 +- arch/openrisc/mm/fault.c | 2 +- arch/parisc/mm/fault.c | 2 +- arch/riscv/mm/fault.c | 2 +- arch/sh/mm/fault.c | 2 +- arch/sparc/mm/fault_32.c | 2 +- arch/sparc/mm/fault_64.c | 2 +- arch/xtensa/mm/fault.c | 2 +- drivers/android/binder_alloc.c | 4 ++-- fs/hugetlbfs/inode.c | 2 +- fs/userfaultfd.c | 2 +- mm/filemap.c | 2 +- mm/gup.c | 12 ++++++------ mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 2 +- mm/ksm.c | 2 +- mm/memory.c | 4 ++-- mm/mempolicy.c | 2 +- mm/migrate.c | 4 ++-- mm/mmap.c | 2 +- mm/oom_kill.c | 8 ++++---- net/ipv4/tcp.c | 2 +- 29 files changed, 43 insertions(+), 43 deletions(-)
Documentation/vm/hmm.rst +3 -3
@@ -194,15 +194,15 @@ The usage pattern is:: again: range.notifier_seq = mmu_interval_read_begin(&interval_sub); - down_read(&mm->mmap_sem); + mmap_read_lock(mm); ret = hmm_range_fault(&range); if (ret) { - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); if (ret == -EBUSY) goto again; return ret; } - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); take_lock(driver->update); if (mmu_interval_read_retry(&ni, range.notifier_seq) {
arch/alpha/mm/fault.c +1 -1
@@ -171,7 +171,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/ia64/mm/fault.c +1 -1
@@ -169,7 +169,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *reif (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/m68k/mm/fault.c +1 -1
@@ -165,7 +165,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/microblaze/mm/fault.c +1 -1
@@ -239,7 +239,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/mips/mm/fault.c +1 -1
@@ -181,7 +181,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/nds32/mm/fault.c +1 -1
@@ -248,7 +248,7 @@ void do_page_fault(unsigned long entry, unsigned long addr,if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/nios2/mm/fault.c +1 -1
@@ -160,7 +160,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/openrisc/mm/fault.c +1 -1
@@ -183,7 +183,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/parisc/mm/fault.c +1 -1
@@ -329,7 +329,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, current->min_flt++;if (fault &VM_FAULT_RETRY ) {/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/riscv/mm/fault.c +1 -1
@@ -147,7 +147,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/sh/mm/fault.c +1 -1
@@ -484,7 +484,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, flags |=FAULT_FLAG_TRIED ;/* -* No need to up_read(&mm->mmap_sem) as we would +* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/sparc/mm/fault_32.c +1 -1
@@ -263,7 +263,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/sparc/mm/fault_64.c +1 -1
@@ -451,7 +451,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
arch/xtensa/mm/fault.c +1 -1
@@ -130,7 +130,7 @@ void do_page_fault(struct pt_regs *regs)if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; -/* No need to up_read(&mm->mmap_sem) as we would +/* No need to mmap_read_unlock(mm) as we would * have already released it in __lock_page_or_retry * in mm/filemap.c. */
drivers/android/binder_alloc.c +2 -2
@@ -933,7 +933,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,if (!mmget_not_zero (mm)) goto err_mmget;if (!mmap_read_trylock (mm)) - goto err_down_read_mmap_sem_failed; + goto err_mmap_read_lock_failed; vma =binder_alloc_get_vma (alloc);list_lru_isolate (lru, item);
@@ -960,7 +960,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,mutex_unlock (&alloc->mutex);return LRU_REMOVED_RETRY ; -err_down_read_mmap_sem_failed: +err_mmap_read_lock_failed:mmput_async (mm); err_mmget: err_page_already_freed:
fs/hugetlbfs/inode.c +1 -1
@@ -186,7 +186,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) }/* -* Called under down_write(mmap_sem). +* Called under mmap_write_lock(mm). */ #ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
fs/userfaultfd.c +1 -1
@@ -1248,7 +1248,7 @@ static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx,/* * To be sure waitqueue_active() is not reordered by the CPU * before the pagetable update, use an explicit SMP memory -* barrier here. PT lock release or up_read(mmap_sem) still +* barrier here. PT lock release or mmap_read_unlock(mm) still * have release semantics that can allow the * waitqueue_active() to be reordered before the pte update. */
mm/filemap.c +1 -1
@@ -1376,7 +1376,7 @@ EXPORT_SYMBOL_GPL(__lock_page_killable);* Return values: * 1 - page is locked; mmap_sem is still held. * 0 - page is not locked. -* mmap_sem has been released (up_read()), unless flags had both +* mmap_lock has been released (mmap_read_unlock(), unless flags had both * FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_RETRY_NOWAIT set, in * which case mmap_sem is still held. *
mm/gup.c +6 -6
@@ -1967,19 +1967,19 @@ EXPORT_SYMBOL(get_user_pages);* * get_user_pages_locked() is suitable to replace the form: * -* down_read(&mm->mmap_sem); +* mmap_read_lock(mm); * do_something() * get_user_pages(tsk, mm, ..., pages, NULL); -* up_read(&mm->mmap_sem); +* mmap_read_unlock(mm); * * to: * * int locked = 1; -* down_read(&mm->mmap_sem); +* mmap_read_lock(mm); * do_something() * get_user_pages_locked(tsk, mm, ..., pages, &locked); * if (locked) -* up_read(&mm->mmap_sem); +* mmap_read_unlock(mm); */ long get_user_pages_locked(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages,
@@ -2003,9 +2003,9 @@ EXPORT_SYMBOL(get_user_pages_locked);/* * get_user_pages_unlocked() is suitable to replace the form: * -* down_read(&mm->mmap_sem); +* mmap_read_lock(mm); * get_user_pages(tsk, mm, ..., pages, NULL); -* up_read(&mm->mmap_sem); +* mmap_read_unlock(mm); * * with: *
mm/huge_memory.c +2 -2
@@ -2038,9 +2038,9 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, goto unlock;/* -* In case prot_numa, we are under down_read(mmap_sem). It's critical +* In case prot_numa, we are under mmap_read_lock(mm). It's critical * to not clear pmd intermittently to avoid race with MADV_DONTNEED -* which is also under down_read(mmap_sem): +* which is also under mmap_read_lock(mm): * * CPU0: CPU1: * change_huge_pmd(prot_numa=1)
mm/khugepaged.c +1 -1
@@ -1444,7 +1444,7 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)/* * Check vma->anon_vma to exclude MAP_PRIVATE mappings that * got written to. These VMAs are likely not worth investing -* down_write(mmap_sem) as PMD-mapping is likely to be split +* mmap_write_lock(mm) as PMD-mapping is likely to be split * later. * * Not that vma->anon_vma check is racy: it can be set up after
mm/ksm.c +1 -1
@@ -2362,7 +2362,7 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page) }else {mmap_read_unlock (mm);/* -* up_read(&mm->mmap_sem) first because after +* mmap_read_unlock(mm) first because after * spin_unlock(&ksm_mmlist_lock) run, the "mm" may * already have been freed under us by __ksm_exit() * because the "mm_slot" is still hashed and
mm/memory.c +2 -2
@@ -3322,10 +3322,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)* pte_offset_map() on pmds where a huge pmd might be created * from a different thread. * -* pte_alloc_map() is safe to use under down_write(mmap_sem) or when +* pte_alloc_map() is safe to use under mmap_write_lock(mm) or when * parallel threads are excluded by other means. * -* Here we only have down_read(mmap_sem). +* Here we only have mmap_read_lock(mm). */ if (pte_alloc (vma->vm_mm, vmf->pmd))return VM_FAULT_OOM ;
mm/mempolicy.c +1 -1
@@ -2188,7 +2188,7 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order,* * This function allocates a page from the kernel page pool and applies * a NUMA policy associated with the VMA or the current process. -* When VMA is not NULL caller must hold down_read on the mmap_sem of the +* When VMA is not NULL caller must read-lock the mmap_lock of the * mm_struct of the VMA to prevent it from going away. Should be used for * all allocations for pages that will be mapped into user space. Returns * NULL when no page can be allocated.
mm/migrate.c +2 -2
@@ -2772,10 +2772,10 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,* pte_offset_map() on pmds where a huge pmd might be created * from a different thread. * -* pte_alloc_map() is safe to use under down_write(mmap_sem) or when +* pte_alloc_map() is safe to use under mmap_write_lock(mm) or when * parallel threads are excluded by other means. * -* Here we only have down_read(mmap_sem). +* Here we only have mmap_read_lock(mm). */ if (pte_alloc (mm, pmdp)) goto abort;
mm/mmap.c +1 -1
@@ -1361,7 +1361,7 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode, }/* -* The caller must hold down_write(¤t->mm->mmap_sem). +* The caller must write-lock current->mm->mmap_lock. */ unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot,
mm/oom_kill.c +4 -4
@@ -577,8 +577,8 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)/* * MMF_OOM_SKIP is set by exit_mmap when the OOM reaper can't * work on the mm anymore. The check for MMF_OOM_SKIP must run -* under mmap_sem for reading because it serializes against the -* down_write();up_write() cycle in exit_mmap(). +* under mmap_lock for reading because it serializes against the +* mmap_write_lock();mmap_write_unlock() cycle in exit_mmap(). */ if (test_bit (MMF_OOM_SKIP , &mm->flags)) {trace_skip_task_reaping (tsk->pid);
@@ -611,7 +611,7 @@ static void oom_reap_task(struct task_struct *tsk)int attempts =0 ;struct mm_struct *mm = tsk->signal->oom_mm; -/* Retry the down_read_trylock(mmap_sem) a few times */ +/* Retry the mmap_read_trylock(mm) a few times */ while (attempts++ <MAX_OOM_REAP_RETRIES && !oom_reap_task_mm (tsk, mm))schedule_timeout_idle (HZ /10 );
@@ -629,7 +629,7 @@ static void oom_reap_task(struct task_struct *tsk)/* * Hide this mm from OOM killer because it has been either reaped or -* somebody can't call up_write(mmap_sem). +* somebody can't call mmap_write_unlock(mm). */ set_bit (MMF_OOM_SKIP , &mm->flags);
net/ipv4/tcp.c +1 -1
@@ -1734,7 +1734,7 @@ int tcp_mmap(struct file *file, struct socket *sock,return -EPERM ; vma->vm_flags &= ~(VM_MAYWRITE |VM_MAYEXEC ); -/* Instruct vm_insert_page() to not down_read(mmap_sem) */ +/* Instruct vm_insert_page() to not mmap_read_lock(mm) */ vma->vm_flags |=VM_MIXEDMAP ; vma->vm_ops = &tcp_vm_ops;
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Re: [PATCH v6 11/12] mmap locking API: convert mmap_sem API comments
Quoted 4 lines · Michel Lespinasse
Convert comments that reference old
mmap_semAPIs to reference corresponding new mmap locking APIs instead.Signed-off-by Michel Lespinasse <[email protected]>
Re: [PATCH v6 11/12] mmap locking API: convert mmap_sem API comments
In reply to Michel LespinasseQuoted 4 lines · Michel Lespinasse
Convert comments that reference old
mmap_semAPIs to reference corresponding new mmap locking APIs instead.Signed-off-by Michel Lespinasse <[email protected]>
Re: [PATCH v6 11/12] mmap locking API: convert mmap_sem API comments
In reply to Michel LespinasseQuoted 4 lines · Michel Lespinasse
Convert comments that reference old
mmap_semAPIs to reference corresponding new mmap locking APIs instead.Signed-off-by Michel Lespinasse <[email protected]>
PATCH v6 12/12 mmap locking API: convert mmap_sem comments
In reply to Michel LespinasseConvert comments that reference mmap_sem to reference mmap_lock instead.
--- .../admin-guide/mm/numa_memory_policy.rst | 10 ++--- Documentation/admin-guide/mm/userfaultfd.rst | 2 +- Documentation/filesystems/locking.rst | 2 +- Documentation/vm/transhuge.rst | 4 +- arch/arc/mm/fault.c | 2 +- arch/arm/kernel/vdso.c | 2 +- arch/arm/mm/fault.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/microblaze/mm/fault.c | 2 +- arch/nds32/mm/fault.c | 2 +- arch/powerpc/include/asm/pkeys.h | 2 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 6 +-- arch/powerpc/mm/book3s32/tlb.c | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 +- arch/powerpc/mm/book3s64/subpage_prot.c | 2 +- arch/powerpc/mm/fault.c | 8 ++-- arch/powerpc/mm/pgtable.c | 2 +- arch/powerpc/platforms/cell/spufs/file.c | 6 +-- arch/riscv/mm/fault.c | 2 +- arch/s390/kvm/priv.c | 2 +- arch/s390/mm/fault.c | 2 +- arch/s390/mm/gmap.c | 32 +++++++-------- arch/s390/mm/pgalloc.c | 2 +- arch/sh/mm/cache-sh4.c | 2 +- arch/sh/mm/fault.c | 2 +- arch/sparc/mm/fault_64.c | 2 +- arch/um/kernel/skas/mmu.c | 2 +- arch/um/kernel/tlb.c | 2 +- arch/unicore32/mm/fault.c | 2 +- arch/x86/events/core.c | 2 +- arch/x86/include/asm/mmu.h | 2 +- arch/x86/include/asm/pgtable-3level.h | 8 ++-- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 +-- arch/x86/kernel/ldt.c | 2 +- arch/x86/mm/fault.c | 12 +++--- drivers/char/mspec.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 6 +-- drivers/gpu/drm/i915/i915_perf.c | 2 +- drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +-- drivers/infiniband/core/uverbs_main.c | 2 +- drivers/infiniband/hw/hfi1/mmu_rb.c | 2 +- drivers/media/v4l2-core/videobuf-dma-sg.c | 2 +- drivers/misc/cxl/cxllib.c | 2 +- drivers/misc/sgi-gru/grufault.c | 8 ++-- drivers/oprofile/buffer_sync.c | 2 +- drivers/staging/android/ashmem.c | 4 +- drivers/staging/comedi/comedi_fops.c | 2 +- drivers/tty/vt/consolemap.c | 2 +- drivers/xen/gntdev.c | 2 +- fs/coredump.c | 4 +- fs/exec.c | 2 +- fs/ext2/file.c | 2 +- fs/ext4/super.c | 6 +-- fs/kernfs/file.c | 4 +- fs/proc/base.c | 6 +-- fs/proc/task_mmu.c | 6 +-- fs/userfaultfd.c | 18 ++++----- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_inode.c | 14 +++---- fs/xfs/xfs_iops.c | 4 +- include/asm-generic/pgtable.h | 6 +-- include/linux/fs.h | 4 +- include/linux/huge_mm.h | 2 +- include/linux/mempolicy.h | 2 +- include/linux/mm.h | 10 ++--- include/linux/mm_types.h | 2 +- include/linux/mmu_notifier.h | 8 ++-- include/linux/pagemap.h | 2 +- include/linux/rmap.h | 2 +- include/linux/sched/mm.h | 10 ++--- kernel/acct.c | 2 +- kernel/cgroup/cpuset.c | 4 +- kernel/events/core.c | 6 +-- kernel/events/uprobes.c | 4 +- kernel/exit.c | 2 +- kernel/relay.c | 2 +- kernel/sys.c | 4 +- lib/test_lockup.c | 8 ++-- mm/filemap.c | 38 +++++++++--------- mm/frame_vector.c | 2 +- mm/gup.c | 38 +++++++++--------- mm/huge_memory.c | 4 +- mm/hugetlb.c | 2 +- mm/internal.h | 4 +- mm/khugepaged.c | 34 ++++++++-------- mm/ksm.c | 12 +++--- mm/maccess.c | 4 +- mm/madvise.c | 20 +++++----- mm/memcontrol.c | 2 +- mm/memory.c | 40 +++++++++---------- mm/mempolicy.c | 12 +++--- mm/migrate.c | 4 +- mm/mlock.c | 6 +-- mm/mmap.c | 36 ++++++++--------- mm/mmu_gather.c | 2 +- mm/mmu_notifier.c | 10 ++--- mm/mprotect.c | 8 ++-- mm/mremap.c | 8 ++-- mm/nommu.c | 6 +-- mm/oom_kill.c | 2 +- mm/pagewalk.c | 6 +-- mm/rmap.c | 12 +++--- mm/shmem.c | 4 +- mm/swap_state.c | 4 +- mm/userfaultfd.c | 8 ++-- mm/util.c | 2 +- security/keys/keyctl.c | 2 +- sound/core/oss/pcm_oss.c | 2 +- 112 files changed, 340 insertions(+), 340 deletions(-)
Documentation/admin-guide/mm/numa_memory_policy.rst +5 -5
@@ -364,19 +364,19 @@ follows: 2) for querying the policy, we do not need to take an extra reference on the target task's task policy nor vma policies because we always acquire the - task's mm's mmap_sem for read during the query. The set_mempolicy() and - mbind() APIs [see below] always acquire the mmap_sem for write when + task's mm's mmap_lock for read during the query. The set_mempolicy() and + mbind() APIs [see below] always acquire the mmap_lock for write when installing or replacing task or vma policies. Thus, there is no possibility of a task or thread freeing a policy while another task or thread is querying it. 3) Page allocation usage of task or vma policy occurs in the fault path where - we hold them mmap_sem for read. Again, because replacing the task or vma - policy requires that the mmap_sem be held for write, the policy can't be + we hold them mmap_lock for read. Again, because replacing the task or vma + policy requires that the mmap_lock be held for write, the policy can't be freed out from under us while we're using it for page allocation. 4) Shared policies require special consideration. One task can replace a - shared memory policy while another task, with a distinct mmap_sem, is + shared memory policy while another task, with a distinct mmap_lock, is querying or allocating a page based on the policy. To resolve this potential race, the shared policy infrastructure adds an extra reference to the shared policy during lookup while holding a spin lock on the shared
Documentation/admin-guide/mm/userfaultfd.rst +1 -1
@@ -33,7 +33,7 @@ memory ranges) provides two primary functionalities: The real advantage of userfaults if compared to regular virtual memory management of mremap/mprotect is that the userfaults in all their operations never involve heavyweight structures like vmas (in fact the -userfaultfd runtime load never takes the mmap_sem for writing). +userfaultfd runtime load never takes the mmap_lock for writing). Vmas are not suitable for page- (or hugepage) granular fault tracking when dealing with virtual address spaces that could span
Documentation/filesystems/locking.rst +1 -1
@@ -611,7 +611,7 @@ prototypes:: locking rules: ============= ======== =========================== -ops mmap_sem PageLocked(page) +ops mmap_lock PageLocked(page) ============= ======== =========================== open: yes close: yes
Documentation/vm/transhuge.rst +2 -2
@@ -98,9 +98,9 @@ split_huge_page() or split_huge_pmd() has a cost. To make pagetable walks huge pmd aware, all you need to do is to call pmd_trans_huge() on the pmd returned by pmd_offset. You must hold the -mmap_sem in read (or write) mode to be sure a huge pmd cannot be +mmap_lock in read (or write) mode to be sure a huge pmd cannot be created from under you by khugepaged (khugepaged collapse_huge_page -takes the mmap_sem in write mode in addition to the anon_vma lock). If +takes the mmap_lock in write mode in addition to the anon_vma lock). If pmd_trans_huge returns false, you just fallback in the old code paths. If instead pmd_trans_huge returns true, you have to take the page table lock (pmd_lock()) and re-run pmd_trans_huge. Taking the
arch/arc/mm/fault.c +1 -1
@@ -141,7 +141,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) }/* -* Fault retry nuances, mmap_sem already relinquished by core mm +* Fault retry nuances, mmap_lock already relinquished by core mm */ if (unlikely ((fault &VM_FAULT_RETRY ) && (flags &FAULT_FLAG_ALLOW_RETRY ))) {
arch/arm/kernel/vdso.c +1 -1
@@ -240,7 +240,7 @@ static int install_vvar(struct mm_struct *mm, unsigned long addr)return PTR_ERR_OR_ZERO (vma); } -/* assumes mmap_sem is write-locked */ +/* assumes mmap_lock is write-locked */ void arm_install_vdso (struct mm_struct *mm,unsigned long addr) {struct vm_area_struct *vma;
arch/arm/mm/fault.c +1 -1
@@ -292,7 +292,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) fault =__do_page_fault (mm, addr, fsr, flags, tsk);/* If we need to retry but a fatal signal is pending, handle the -* signal first. We do not need to release the mmap_sem because +* signal first. We do not need to release the mmap_lock because * it would already be released in __lock_page_or_retry in * mm/filemap.c. */ if (fault_signal_pending (fault, regs)) {
arch/ia64/mm/fault.c +1 -1
@@ -82,7 +82,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re#ifdef CONFIG_VIRTUAL_MEM_MAP /* * If fault is in region 5 and we are in the kernel, we may already -* have the mmap_sem (pfn_valid macro is called during mmap). There +* have the mmap_lock (pfn_valid macro is called during mmap). There * is no vma for region 5 addr's anyway, so skip getting the semaphore * and go directly to the exception handling code. */
arch/microblaze/mm/fault.c +1 -1
@@ -125,7 +125,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,/* When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in the * kernel and should generate an OOPS. Unfortunately, in the case of an -* erroneous fault occurring in a code path which already holds mmap_sem +* erroneous fault occurring in a code path which already holds mmap_lock * we will deadlock attempting to validate the fault against the * address space. Luckily the kernel only validly references user * space from well defined areas of code, which are listed in the
arch/nds32/mm/fault.c +1 -1
@@ -211,7 +211,7 @@ void do_page_fault(unsigned long entry, unsigned long addr,/* * If we need to retry but a fatal signal is pending, handle the -* signal first. We do not need to release the mmap_sem because it +* signal first. We do not need to release the mmap_lock because it * would already be released in __lock_page_or_retry in mm/filemap.c. */ if (fault_signal_pending (fault, regs)) {
arch/powerpc/include/asm/pkeys.h +1 -1
@@ -101,7 +101,7 @@ static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)/* * Returns a positive, 5-bit key on success, or -1 on failure. -* Relies on the mmap_sem to protect against concurrency in mm_pkey_alloc() and +* Relies on the mmap_lock to protect against concurrency in mm_pkey_alloc() and * mm_pkey_free(). */ static inline int mm_pkey_alloc (struct mm_struct *mm)
arch/powerpc/kvm/book3s_hv_uvmem.c +3 -3
@@ -47,7 +47,7 @@* Locking order * * 1. kvm->srcu - Protects KVM memslots -* 2. kvm->mm->mmap_sem - find_vma, migrate_vma_pages and helpers, ksm_madvise +* 2. kvm->mm->mmap_lock - find_vma, migrate_vma_pages and helpers, ksm_madvise * 3. kvm->arch.uvmem_lock - protects read/writes to uvmem slots thus acting * as sync-points for page-in/out */
@@ -402,8 +402,8 @@ kvmppc_svm_page_in(struct vm_area_struct *vma, unsigned long start, mig.dst = &dst_pfn;/* -* We come here with mmap_sem write lock held just for -* ksm_madvise(), otherwise we only need read mmap_sem. +* We come here with mmap_lock write lock held just for +* ksm_madvise(), otherwise we only need read mmap_lock. * Hence downgrade to read lock once ksm_madvise() is done. */ ret = ksm_madvise(vma, vma->vm_start, vma->vm_end,
arch/powerpc/mm/book3s32/tlb.c +1 -1
@@ -129,7 +129,7 @@ void flush_tlb_mm(struct mm_struct *mm)/* * It is safe to go down the mm's list of vmas when called -* from dup_mmap, holding mmap_sem. It would also be safe from +* from dup_mmap, holding mmap_lock. It would also be safe from * unmap_region or exit_mmap, but not from vmtruncate on SMP - * but it seems dup_mmap is the only SMP case which gets here. */
arch/powerpc/mm/book3s64/hash_pgtable.c +2 -2
@@ -236,7 +236,7 @@ pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addres* to hugepage, we first clear the pmd, then invalidate all * the PTE entries. The assumption here is that any low level * page fault will see a none pmd and take the slow path that -* will wait on mmap_sem. But we could very well be in a +* will wait on mmap_lock. But we could very well be in a * hash_page with local ptep pointer value. Such a hash page * can result in adding new HPTE entries for normal subpages. * That means we could be modifying the page content as we
@@ -250,7 +250,7 @@ pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addres* Now invalidate the hpte entries in the range * covered by pmd. This make sure we take a * fault and will find the pmd as none, which will -* result in a major fault which takes mmap_sem and +* result in a major fault which takes mmap_lock and * hence wait for collapse to complete. Without this * the __collapse_huge_page_copy can result in copying * the old content.
arch/powerpc/mm/book3s64/subpage_prot.c +1 -1
@@ -223,7 +223,7 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,if (!spt) {/* * Allocate subpage prot table if not already done. -* Do this with mmap_sem held +* Do this with mmap_lock held */ spt =kzalloc (sizeof (struct subpage_prot_table ),GFP_KERNEL );if (!spt) {
arch/powerpc/mm/fault.c +4 -4
@@ -488,9 +488,9 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, get_mm_addr_key(mm, address));/* -* We want to do this outside mmap_sem, because reading code around nip +* We want to do this outside mmap_lock, because reading code around nip * can result in fault, which will cause a deadlock when called with -* mmap_sem held +* mmap_lock held */ if (is_user) flags |=FAULT_FLAG_USER ;
@@ -502,7 +502,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,/* When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in the * kernel and should generate an OOPS. Unfortunately, in the case of an -* erroneous fault occurring in a code path which already holds mmap_sem +* erroneous fault occurring in a code path which already holds mmap_lock * we will deadlock attempting to validate the fault against the * address space. Luckily the kernel only validly references user * space from well defined areas of code, which are listed in the
@@ -586,7 +586,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,return user_mode (regs) ?0 :SIGBUS ;/* -* Handle the retry right now, the mmap_sem has been released in that +* Handle the retry right now, the mmap_lock has been released in that * case. */ if (unlikely (fault &VM_FAULT_RETRY )) {
arch/powerpc/mm/pgtable.c +1 -1
@@ -277,7 +277,7 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr) pmd =pmd_offset (pud, addr);/* * khugepaged to collapse normal pages to hugepage, first set -* pmd to none to force page fault/gup to take mmap_sem. After +* pmd to none to force page fault/gup to take mmap_lock. After * pmd is set to none, we do a pte_clear which does this assertion * so if we find pmd none, return. */
arch/powerpc/platforms/cell/spufs/file.c +3 -3
@@ -318,7 +318,7 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf,return VM_FAULT_SIGBUS ;/* -* Because we release the mmap_sem, the context may be destroyed while +* Because we release the mmap_lock, the context may be destroyed while * we're in spu_wait. Grab an extra reference so it isn't destroyed * in the meantime. */
@@ -327,8 +327,8 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf,/* * We have to wait for context to be loaded before we have * pages to hand out to the user, but we don't want to wait -* with the mmap_sem held. -* It is possible to drop the mmap_sem here, but then we need +* with the mmap_lock held. +* It is possible to drop the mmap_lock here, but then we need * to return VM_FAULT_NOPAGE because the mappings may have * hanged. */
arch/riscv/mm/fault.c +1 -1
@@ -114,7 +114,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)/* * If we need to retry but a fatal signal is pending, handle the -* signal first. We do not need to release the mmap_sem because it +* signal first. We do not need to release the mmap_lock because it * would already be released in __lock_page_or_retry in mm/filemap.c. */ if (fault_signal_pending (fault, regs))
arch/s390/kvm/priv.c +1 -1
@@ -1122,7 +1122,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) }/* -* Must be called with relevant read locks held (kvm->mm->mmap_sem, kvm->srcu) +* Must be called with relevant read locks held (kvm->mm->mmap_lock, kvm->srcu) */ static inline int __do_essa (struct kvm_vcpu *vcpu,const int orc) {
arch/s390/mm/fault.c +1 -1
@@ -508,7 +508,7 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)if (IS_ENABLED (CONFIG_PGSTE ) && gmap && (flags &FAULT_FLAG_RETRY_NOWAIT )) {/* FAULT_FLAG_RETRY_NOWAIT has been set, -* mmap_sem has not been released */ +* mmap_lock has not been released */ current->thread.gmap_pfault =1 ; fault =VM_FAULT_PFAULT ; goto out_up;
arch/s390/mm/gmap.c +16 -16
@@ -300,7 +300,7 @@ struct gmap *gmap_get_enabled(void)EXPORT_SYMBOL_GPL (gmap_get_enabled);/* -* gmap_alloc_table is assumed to be called with mmap_sem held +* gmap_alloc_table is assumed to be called with mmap_lock held */ static int gmap_alloc_table (struct gmap *gmap,unsigned long *table,unsigned long init,unsigned long gaddr)
@@ -466,7 +466,7 @@ EXPORT_SYMBOL_GPL(gmap_map_segment);* Returns user space address which corresponds to the guest address or * -EFAULT if no such mapping exists. * This function does not establish potentially missing page table entries. -* The mmap_sem of the mm that belongs to the address space must be held +* The mmap_lock of the mm that belongs to the address space must be held * when this function gets called. * * Note: Can also be called for shadow gmaps.
@@ -534,7 +534,7 @@ static void gmap_pmdp_xchg(struct gmap *gmap, pmd_t *old, pmd_t new,* * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT * if the vm address is already mapped to a different guest segment. -* The mmap_sem of the mm that belongs to the address space must be held +* The mmap_lock of the mm that belongs to the address space must be held * when this function gets called. */ int __gmap_link (struct gmap *gmap,unsigned long gaddr,unsigned long vmaddr)
@@ -655,7 +655,7 @@ int gmap_fault(struct gmap *gmap, unsigned long gaddr, goto out_up; }/* -* In the case that fixup_user_fault unlocked the mmap_sem during +* In the case that fixup_user_fault unlocked the mmap_lock during * faultin redo __gmap_translate to not race with a map/unmap_segment. */ if (unlocked)
@@ -669,7 +669,7 @@ int gmap_fault(struct gmap *gmap, unsigned long gaddr,EXPORT_SYMBOL_GPL (gmap_fault);/* -* this function is assumed to be called with mmap_sem held +* this function is assumed to be called with mmap_lock held */ void __gmap_zap (struct gmap *gmap,unsigned long gaddr) {
@@ -882,7 +882,7 @@ static int gmap_pte_op_fixup(struct gmap *gmap, unsigned long gaddr,if (fixup_user_fault (current, mm, vmaddr, fault_flags, &unlocked))return -EFAULT ;if (unlocked) -/* lost mmap_sem, caller has to retry __gmap_translate */ +/* lost mmap_lock, caller has to retry __gmap_translate */ return 0 ;/* Connect the page tables */ return __gmap_link (gmap, gaddr, vmaddr);
@@ -953,7 +953,7 @@ static inline void gmap_pmd_op_end(struct gmap *gmap, pmd_t *pmdp)* -EAGAIN if a fixup is needed * -EINVAL if unsupported notifier bits have been specified * -* Expected to be called with sg->mm->mmap_sem in read and +* Expected to be called with sg->mm->mmap_lock in read and * guest_table_lock held. */ static int gmap_protect_pmd(struct gmap *gmap, unsigned long gaddr,
@@ -999,7 +999,7 @@ static int gmap_protect_pmd(struct gmap *gmap, unsigned long gaddr,* Returns 0 if successfully protected, -ENOMEM if out of memory and * -EAGAIN if a fixup is needed. * -* Expected to be called with sg->mm->mmap_sem in read +* Expected to be called with sg->mm->mmap_lock in read */ static int gmap_protect_pte (struct gmap *gmap,unsigned long gaddr,pmd_t *pmdp,int prot,unsigned long bits)
@@ -1035,7 +1035,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr,* Returns 0 if successfully protected, -ENOMEM if out of memory and * -EFAULT if gaddr is invalid (or mapping for shadows is missing). * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ static int gmap_protect_range (struct gmap *gmap,unsigned long gaddr,unsigned long len,int prot,unsigned long bits)
@@ -1124,7 +1124,7 @@ EXPORT_SYMBOL_GPL(gmap_mprotect_notify);* if reading using the virtual address failed. -EINVAL if called on a gmap * shadow. * -* Called with gmap->mm->mmap_sem in read. +* Called with gmap->mm->mmap_lock in read. */ int gmap_read_table (struct gmap *gmap,unsigned long gaddr,unsigned long *val) {
@@ -1729,7 +1729,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow);* shadow table structure is incomplete, -ENOMEM if out of memory and * -EFAULT if an address in the parent gmap could not be resolved. * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ int gmap_shadow_r2t (struct gmap *sg,unsigned long saddr,unsigned long r2t,int fake)
@@ -1813,7 +1813,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_r2t);* shadow table structure is incomplete, -ENOMEM if out of memory and * -EFAULT if an address in the parent gmap could not be resolved. * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ int gmap_shadow_r3t (struct gmap *sg,unsigned long saddr,unsigned long r3t,int fake)
@@ -1897,7 +1897,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_r3t);* shadow table structure is incomplete, -ENOMEM if out of memory and * -EFAULT if an address in the parent gmap could not be resolved. * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ int gmap_shadow_sgt (struct gmap *sg,unsigned long saddr,unsigned long sgt,int fake)
@@ -1981,7 +1981,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_sgt);* Returns 0 if the shadow page table was found and -EAGAIN if the page * table was not found. * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ int gmap_shadow_pgt_lookup(struct gmap *sg, unsigned long saddr, unsigned long *pgt, int *dat_protection,
@@ -2021,7 +2021,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_pgt_lookup);* shadow table structure is incomplete, -ENOMEM if out of memory, * -EFAULT if an address in the parent gmap could not be resolved and * -* Called with gmap->mm->mmap_sem in read +* Called with gmap->mm->mmap_lock in read */ int gmap_shadow_pgt (struct gmap *sg,unsigned long saddr,unsigned long pgt,int fake)
@@ -2100,7 +2100,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_pgt);* shadow table structure is incomplete, -ENOMEM if out of memory and * -EFAULT if an address in the parent gmap could not be resolved. * -* Called with sg->mm->mmap_sem in read. +* Called with sg->mm->mmap_lock in read. */ int gmap_shadow_page (struct gmap *sg,unsigned long saddr,pte_t pte) {
arch/s390/mm/pgalloc.c +1 -1
@@ -114,7 +114,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)spin_lock_bh (&mm->page_table_lock);/* -* This routine gets called with mmap_sem lock held and there is +* This routine gets called with mmap_lock lock held and there is * no reason to optimize for the case of otherwise. However, if * that would ever change, the below check will let us know. */
arch/sh/mm/cache-sh4.c +1 -1
@@ -183,7 +183,7 @@ static void sh4_flush_cache_all(void *unused)* accessed with (hence cache set) is in accord with the physical * address (i.e. tag). It's no different here. * -* Caller takes mm->mmap_sem. +* Caller takes mm->mmap_lock. */ static void sh4_flush_cache_mm (void *arg) {
arch/sh/mm/fault.c +1 -1
@@ -308,7 +308,7 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,return 1 ; } -/* Release mmap_sem first if necessary */ +/* Release mmap_lock first if necessary */ if (!(fault &VM_FAULT_RETRY ))mmap_read_unlock (current->mm);
arch/sparc/mm/fault_64.c +1 -1
@@ -71,7 +71,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr) }/* -* We now make sure that mmap_sem is held in all paths that call +* We now make sure that mmap_lock is held in all paths that call * this. Additionally, to prevent kswapd from ripping ptes from * under us, raise interrupts around the time that we look at the * pte, kswapd will have to wait to get his smp ipi response from
arch/um/kernel/skas/mmu.c +1 -1
@@ -115,7 +115,7 @@ void uml_setup_stubs(struct mm_struct *mm) mm->context.stub_pages[0 ] =virt_to_page (__syscall_stub_start); mm->context.stub_pages[1 ] =virt_to_page (mm->context.id.stack); -/* dup_mmap already holds mmap_sem */ +/* dup_mmap already holds mmap_lock */ err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC | VM_DONTCOPY | VM_PFNMAP,
arch/um/kernel/tlb.c +1 -1
@@ -349,7 +349,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,if (ret) {printk (KERN_ERR "fix_range_common: failed, killing current " "process: %d\n" ,task_tgid_vnr (current)); -/* We are under mmap_sem, release it such that current can terminate */ +/* We are under mmap_lock, release it such that current can terminate */ mmap_write_unlock (current->mm);force_sig (SIGKILL );do_signal (¤t->thread.regs);
arch/unicore32/mm/fault.c +1 -1
@@ -247,7 +247,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs) fault =__do_pf (mm, addr, fsr, flags, tsk);/* If we need to retry but a fatal signal is pending, handle the -* signal first. We do not need to release the mmap_sem because +* signal first. We do not need to release the mmap_lock because * it would already be released in __lock_page_or_retry in * mm/filemap.c. */ if (fault_signal_pending (fault, regs))
arch/x86/events/core.c +1 -1
@@ -2179,7 +2179,7 @@ static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)* userspace with CR4.PCE clear while another task is still * doing on_each_cpu_mask() to propagate CR4.PCE. * -* For now, this can't happen because all callers hold mmap_sem +* For now, this can't happen because all callers hold mmap_lock * for write. If this changes, we'll need a different solution. */ mmap_assert_write_locked (mm);
arch/x86/include/asm/mmu.h +1 -1
@@ -45,7 +45,7 @@ typedef struct {#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS /* * One bit per protection key says whether userspace can -* use it or not. protected by mmap_sem. +* use it or not. protected by mmap_lock. */ u16 pkey_allocation_map;s16 execute_only_pkey;
arch/x86/include/asm/pgtable-3level.h +4 -4
@@ -39,23 +39,23 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)* pte_offset_map_lock() on 32-bit PAE kernels was reading the pmd_t with * a "*pmdp" dereference done by GCC. Problem is, in certain places * where pte_offset_map_lock() is called, concurrent page faults are -* allowed, if the mmap_sem is hold for reading. An example is mincore +* allowed, if the mmap_lock is hold for reading. An example is mincore * vs page faults vs MADV_DONTNEED. On the page fault side * pmd_populate() rightfully does a set_64bit(), but if we're reading the * pmd_t with a "*pmdp" on the mincore side, a SMP race can happen * because GCC will not read the 64-bit value of the pmd atomically. * * To fix this all places running pte_offset_map_lock() while holding the -* mmap_sem in read mode, shall read the pmdp pointer using this +* mmap_lock in read mode, shall read the pmdp pointer using this * function to know if the pmd is null or not, and in turn to know if * they can run pte_offset_map_lock() or pmd_trans_huge() or other pmd * operations. * -* Without THP if the mmap_sem is held for reading, the pmd can only +* Without THP if the mmap_lock is held for reading, the pmd can only * transition from null to not null while pmd_read_atomic() runs. So * we can always return atomic pmd values with this function. * -* With THP if the mmap_sem is held for reading, the pmd can become +* With THP if the mmap_lock is held for reading, the pmd can become * trans_huge or none or point to a pte (and in turn become "stable") * at any time under pmd_read_atomic(). We could read it truly * atomically here with an atomic64_read() for the THP enabled case (and
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1 -1
@@ -1326,7 +1326,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)* pseudo-locked region will still be here on return. * * The mutex has to be released temporarily to avoid a potential -* deadlock with the mm->mmap_sem semaphore which is obtained in +* deadlock with the mm->mmap_lock semaphore which is obtained in * the device_create() and debugfs_create_dir() callpath below * as well as before the mmap() callback is called. */
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -3
@@ -3199,10 +3199,10 @@ int __init rdtgroup_init(void)* during the debugfs directory creation also &sb->s_type->i_mutex_key * (the lockdep class of inode->i_rwsem). Other filesystem * interactions (eg. SyS_getdents) have the lock ordering: -* &sb->s_type->i_mutex_key --> &mm->mmap_sem -* During mmap(), called with &mm->mmap_sem, the rdtgroup_mutex +* &sb->s_type->i_mutex_key --> &mm->mmap_lock +* During mmap(), called with &mm->mmap_lock, the rdtgroup_mutex * is taken, thus creating dependency: -* &mm->mmap_sem --> rdtgroup_mutex for the latter that can cause +* &mm->mmap_lock --> rdtgroup_mutex for the latter that can cause * issues considering the other two lock dependencies. * By creating the debugfs directory here we avoid a dependency * that may cause deadlock (even though file operations cannot
arch/x86/kernel/ldt.c +1 -1
@@ -8,7 +8,7 @@* * Lock order: * contex.ldt_usr_sem -* mmap_sem +* mmap_lock * context.lock */
arch/x86/mm/fault.c +6 -6
@@ -1005,7 +1005,7 @@ bad_area_access_error(struct pt_regs *regs, unsigned long error_code,* 2. T1 : set PKRU to deny access to pkey=4, touches page * 3. T1 : faults... * 4. T2: mprotect_key(foo, PAGE_SIZE, pkey=5); -* 5. T1 : enters fault handler, takes mmap_sem, etc... +* 5. T1 : enters fault handler, takes mmap_lock, etc... * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really * faulted on a pte with its pkey=4. */
@@ -1394,12 +1394,12 @@ void do_user_addr_fault(struct pt_regs *regs,* Kernel-mode access to the user address space should only occur * on well-defined single instructions listed in the exception * tables. But, an erroneous kernel fault occurring outside one of -* those areas which also holds mmap_sem might deadlock attempting +* those areas which also holds mmap_lock might deadlock attempting * to validate the fault against the address space. * * Only do the expensive exception table search when we might be at * risk of a deadlock. This happens if we -* 1. Failed to acquire mmap_sem, and +* 1. Failed to acquire mmap_lock, and * 2. The access did not originate in userspace. */ if (unlikely (!mmap_read_trylock (mm))) {
@@ -1452,9 +1452,9 @@ void do_user_addr_fault(struct pt_regs *regs,* If for any reason at all we couldn't handle the fault, * make sure we exit gracefully rather than endlessly redo * the fault. Since we never set FAULT_FLAG_RETRY_NOWAIT, if -* we get VM_FAULT_RETRY back, the mmap_sem has been unlocked. +* we get VM_FAULT_RETRY back, the mmap_lock has been unlocked. * -* Note that handle_userfault() may also release and reacquire mmap_sem +* Note that handle_userfault() may also release and reacquire mmap_lock * (and not return with VM_FAULT_RETRY), when returning to userland to * repeat the page fault later with a VM_FAULT_NOPAGE retval * (potentially after handling any pending signal during the return to
@@ -1473,7 +1473,7 @@ void do_user_addr_fault(struct pt_regs *regs, }/* -* If we need to retry the mmap_sem has already been released, +* If we need to retry the mmap_lock has already been released, * and if there is a fatal signal pending there is no guarantee * that we made any progress. Handle this case first. */
drivers/char/mspec.c +1 -1
@@ -65,7 +65,7 @@ enum mspec_page_type {* This structure is shared by all vma's that are split off from the * original vma when split_vma()'s are done. * -* The refcnt is incremented atomically because mm->mmap_sem does not +* The refcnt is incremented atomically because mm->mmap_lock does not * protect in fork case where multiple tasks share the vma_data. */ struct vma_data {
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -181,7 +181,7 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s* disabled. The memory must be pinned and mapped to the hardware when * this is called in hqd_load functions, so it should never fault in * the first place. This resolves a circular lock dependency involving -* four locks, including the DQM lock and mmap_sem. +* four locks, including the DQM lock and mmap_lock. */ #define read_user_wptr (mmptr, wptr, dst) \ ({ \
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +1 -1
@@ -237,7 +237,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, data); -/* read_user_ptr may take the mm->mmap_sem. +/* read_user_ptr may take the mm->mmap_lock. * release srbm_mutex to avoid circular dependency between * srbm_mutex->mm_sem->reservation_ww_class_mutex->srbm_mutex. */
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +1 -1
@@ -224,7 +224,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);WREG32 (mmCP_HQD_PQ_DOORBELL_CONTROL, data); -/* read_user_ptr may take the mm->mmap_sem. +/* read_user_ptr may take the mm->mmap_lock. * release srbm_mutex to avoid circular dependency between * srbm_mutex->mm_sem->reservation_ww_class_mutex->srbm_mutex. */
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +3 -3
@@ -203,7 +203,7 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)mmap_write_lock (mm->mm);mutex_lock (&mm->i915->mm_lock);if (mm->mn ==NULL && !err) { -/* Protected by mmap_sem (write-lock) */ +/* Protected by mmap_lock (write-lock) */ err =__mmu_notifier_register (&mn->mn, mm->mm);if (!err) {/* Protected by mm_lock */
@@ -522,8 +522,8 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)/* Spawn a worker so that we can acquire the * user pages without holding our mutex. Access -* to the user pages requires mmap_sem, and we have -* a strict lock ordering of mmap_sem, struct_mutex - +* to the user pages requires mmap_lock, and we have +* a strict lock ordering of mmap_lock, struct_mutex - * we already hold struct_mutex here and so cannot * call gup without encountering a lock inversion. *
drivers/gpu/drm/i915/i915_perf.c +1 -1
@@ -3623,7 +3623,7 @@ static int read_properties_unlocked(struct i915_perf *perf,* buffered data written by the GPU besides periodic OA metrics. * * Note we copy the properties from userspace outside of the i915 perf -* mutex to avoid an awkward lockdep with mmap_sem. +* mutex to avoid an awkward lockdep with mmap_lock. * * Most of the implementation details are handled by * i915_perf_open_ioctl_locked() after taking the &perf->lock
drivers/gpu/drm/ttm/ttm_bo_vm.c +3 -3
@@ -58,7 +58,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, goto out_clear;/* -* If possible, avoid waiting for GPU with mmap_sem +* If possible, avoid waiting for GPU with mmap_lock * held. We only do this if the fault allows retry and this * is the first attempt. */
@@ -131,14 +131,14 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo, {/* * Work around locking order reversal in fault / nopfn -* between mmap_sem and bo_reserve: Perform a trylock operation +* between mmap_lock and bo_reserve: Perform a trylock operation * for reserve, and if it fails, retry the fault after waiting * for the buffer to become unreserved. */ if (unlikely (!dma_resv_trylock (bo->base.resv))) {/* * If the fault allows retry and this is the first -* fault attempt, we try to release the mmap_sem +* fault attempt, we try to release the mmap_lock * before waiting */ if (fault_flag_allow_retry_first (vmf->flags)) {
drivers/infiniband/core/uverbs_main.c +1 -1
@@ -833,7 +833,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)return ;/* -* The umap_lock is nested under mmap_sem since it used within +* The umap_lock is nested under mmap_lock since it used within * the vma_ops callbacks, so we have to clean the list one mm * at a time to get the lock ordering right. Typically there * will only be one mm, so no big deal.
drivers/infiniband/hw/hfi1/mmu_rb.c +1 -1
@@ -333,7 +333,7 @@ static void do_remove(struct mmu_rb_handler *handler,/* * Work queue function to remove all nodes that have been queued up to -* be removed. The key feature is that mm->mmap_sem is not being held +* be removed. The key feature is that mm->mmap_lock is not being held * and the remove callback can sleep while taking it, if needed. */ static void handle_remove (struct work_struct *work)
drivers/media/v4l2-core/videobuf-dma-sg.c +1 -1
@@ -533,7 +533,7 @@ static int __videobuf_iolock(struct videobuf_queue *q, }else {/* NOTE: HACK: videobuf_iolock on V4L2_MEMORY_MMAP buffers can only be called from videobuf_qbuf -we take current->mm->mmap_sem there, to prevent +we take current->mm->mmap_lock there, to prevent locking inversion, so don't take it here */ err = videobuf_dma_init_user_locked(&mem->dma,
drivers/misc/cxl/cxllib.c +1 -1
@@ -245,7 +245,7 @@ int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64 flags) dar += page_size) {if (dar < vma_start || dar >= vma_end) {/* -* We don't hold the mm->mmap_sem semaphore +* We don't hold the mm->mmap_lock semaphore * while iterating, since the semaphore is * required by one of the lower-level page * fault processing functions and it could
drivers/misc/sgi-gru/grufault.c +4 -4
@@ -43,7 +43,7 @@ static inline int is_gru_paddr(unsigned long paddr) }/* -* Find the vma of a GRU segment. Caller must hold mmap_sem. +* Find the vma of a GRU segment. Caller must hold mmap_lock. */ struct vm_area_struct *gru_find_vma (unsigned long vaddr) {
@@ -59,7 +59,7 @@ struct vm_area_struct *gru_find_vma(unsigned long vaddr)* Find and lock the gts that contains the specified user vaddr. * * Returns: -* - *gts with the mmap_sem locked for read and the GTS locked. +* - *gts with the mmap_lock locked for read and the GTS locked. * - NULL if vaddr invalid OR is not a valid GSEG vaddr. */
@@ -199,7 +199,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,* Only supports Intel large pages (2MB only) on x86_64. * ZZZ - hugepage support is incomplete * -* NOTE: mmap_sem is already held on entry to this function. This +* NOTE: mmap_lock is already held on entry to this function. This * guarantees existence of the page tables. */ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
@@ -570,7 +570,7 @@ static irqreturn_t gru_intr(int chiplet, int blade) }/* -* This is running in interrupt context. Trylock the mmap_sem. +* This is running in interrupt context. Trylock the mmap_lock. * If it fails, retry the fault in user context. */ gts->ustats.fmm_tlbmiss++;
drivers/oprofile/buffer_sync.c +1 -1
@@ -486,7 +486,7 @@ typedef enum {/* Sync one of the CPU's buffers into the global event buffer. * Here we need to go through each batch of samples punctuated -* by context switch notes, taking the task's mmap_sem and doing +* by context switch notes, taking the task's mmap_lock and doing * lookup in task->mm->mmap to convert EIP into dcookie/offset * value. */
drivers/staging/android/ashmem.c +2 -2
@@ -555,7 +555,7 @@ static int set_name(struct ashmem_area *asma, void __user *name)/* * Holding the ashmem_mutex while doing a copy_from_user might cause -* an data abort which would try to access mmap_sem. If another +* an data abort which would try to access mmap_lock. If another * thread has invoked ashmem_mmap then it will be holding the * semaphore and will be waiting for ashmem_mutex, there by leading to * deadlock. We'll release the mutex and take the name to a local
@@ -586,7 +586,7 @@ static int get_name(struct ashmem_area *asma, void __user *name)* Have a local variable to which we'll copy the content * from asma with the lock held. Later we can copy this to the user * space safely without holding any locks. So even if we proceed to -* wait for mmap_sem, it won't lead to deadlock. +* wait for mmap_lock, it won't lead to deadlock. */ char local_name[ASHMEM_NAME_LEN ];
drivers/staging/comedi/comedi_fops.c +1 -1
@@ -2309,7 +2309,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)int retval =0 ;/* -* 'trylock' avoids circular dependency with current->mm->mmap_sem +* 'trylock' avoids circular dependency with current->mm->mmap_lock * and down-reading &dev->attach_lock should normally succeed without * contention unless the device is in the process of being attached * or detached.
drivers/tty/vt/consolemap.c +1 -1
@@ -12,7 +12,7 @@* Fix bug in inverse translation. Stanislav Voronyi <[email protected]>, Dec 1998 * * In order to prevent the following circular lock dependency: -* &mm->mmap_sem --> cpu_hotplug.lock --> console_lock --> &mm->mmap_sem +* &mm->mmap_lock --> cpu_hotplug.lock --> console_lock --> &mm->mmap_lock * * We cannot allow page fault to happen while holding the console_lock. * Therefore, all the userspace copy operations have to be done outside
drivers/xen/gntdev.c +1 -1
@@ -1014,7 +1014,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)* to the PTE from going stale. * * Since this vma's mappings can't be touched without the -* mmap_sem, and we are holding it now, there is no need for +* mmap_lock, and we are holding it now, there is no need for * the notifier_range locking pattern. */ mmu_interval_read_begin (&map->notifier);
fs/coredump.c +2 -2
@@ -393,7 +393,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,* of ->siglock provides a memory barrier. * * do_exit: -* The caller holds mm->mmap_sem. This means that the task which +* The caller holds mm->mmap_lock. This means that the task which * uses this mm can't pass exit_mm(), so it can't exit or clear * its ->mm. *
@@ -401,7 +401,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,* It does list_replace_rcu(&leader->tasks, ¤t->tasks), * we must see either old or new leader, this does not matter. * However, it can change p->sighand, so lock_task_sighand(p) -* must be used. Since p->mm != NULL and we hold ->mmap_sem +* must be used. Since p->mm != NULL and we hold ->mmap_lock * it can't fail. * * Note also that "g" can be the old leader with ->mm == NULL
fs/exec.c +1 -1
@@ -1061,7 +1061,7 @@ static int exec_mmap(struct mm_struct *mm)/* * Make sure that if there is a core dump in progress * for the old mm, we get out and die instead of going -* through with the exec. We must hold mmap_sem around +* through with the exec. We must hold mmap_lock around * checking core_state and changing tsk->mm. */ mmap_read_lock (old_mm);
fs/ext2/file.c +1 -1
@@ -79,7 +79,7 @@ static ssize_t ext2_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)/* * The lock ordering for ext2 DAX fault paths is: * -* mmap_sem (MM) +* mmap_lock (MM) * sb_start_pagefault (vfs, freeze) * ext2_inode_info->dax_sem * address_space->i_mmap_rwsem or page_lock (mutually exclusive in DAX)
fs/ext4/super.c +3 -3
@@ -93,11 +93,11 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,* i_mmap_rwsem (inode->i_mmap_rwsem)! * * page fault path: -* mmap_sem -> sb_start_pagefault -> i_mmap_sem (r) -> transaction start -> +* mmap_lock -> sb_start_pagefault -> i_mmap_sem (r) -> transaction start -> * page lock -> i_data_sem (rw) * * buffered write path: -* sb_start_write -> i_mutex -> mmap_sem +* sb_start_write -> i_mutex -> mmap_lock * sb_start_write -> i_mutex -> transaction start -> page lock -> * i_data_sem (rw) *
@@ -107,7 +107,7 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,* i_data_sem (rw) * * direct IO: -* sb_start_write -> i_mutex -> mmap_sem +* sb_start_write -> i_mutex -> mmap_lock * sb_start_write -> i_mutex -> transaction start -> i_data_sem (rw) * * writepages:
fs/kernfs/file.c +2 -2
@@ -652,9 +652,9 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)* The following is done to give a different lockdep key to * @of->mutex for files which implement mmap. This is a rather * crude way to avoid false positive lockdep warning around -* mm->mmap_sem - mmap nests @of->mutex under mm->mmap_sem and +* mm->mmap_lock - mmap nests @of->mutex under mm->mmap_lock and * reading /sys/block/sda/trace/act_mask grabs sr_mutex, under -* which mm->mmap_sem nests, while holding @of->mutex. As each +* which mm->mmap_lock nests, while holding @of->mutex. As each * open file has a separate mutex, it's okay as long as those don't * happen on the same file. At this point, we can't easily give * each file a separate locking class. Let's differentiate on
fs/proc/base.c +3 -3
@@ -2325,11 +2325,11 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)/* * We need two passes here: * -* 1) Collect vmas of mapped files with mmap_sem taken -* 2) Release mmap_sem and instantiate entries +* 1) Collect vmas of mapped files with mmap_lock taken +* 2) Release mmap_lock and instantiate entries * * otherwise we get lockdep complained, since filldir() -* routine might require mmap_sem taken in might_fault(). +* routine might require mmap_lock taken in might_fault(). */ for (vma = mm->mmap, pos =2 ; vma; vma = vma->vm_next) {
fs/proc/task_mmu.c +3 -3
@@ -587,7 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,if (pmd_trans_unstable (pmd)) goto out;/* -* The mmap_sem held all the way back in m_start() is what +* The mmap_lock held all the way back in m_start() is what * keeps khugepaged out of here and from collapsing things * in here. */
@@ -746,7 +746,7 @@ static void smap_gather_stats(struct vm_area_struct *vma, } }#endif -/* mmap_sem is held in m_start */ +/* mmap_lock is held in m_start */ walk_page_vma (vma, &smaps_walk_ops, mss); }
@@ -1821,7 +1821,7 @@ static int show_numa_map(struct seq_file *m, void *v)if (is_vm_hugetlb_page (vma))seq_puts (m," huge" ); -/* mmap_sem is held by m_start */ +/* mmap_lock is held by m_start */ walk_page_vma (vma, &show_numa_ops, md);if (!md->pages)
fs/userfaultfd.c +9 -9
@@ -369,13 +369,13 @@ static inline bool userfaultfd_signal_pending(unsigned int flags)* FAULT_FLAG_KILLABLE are not straightforward. The "Caution" * recommendation in __lock_page_or_retry is not an understatement. * -* If FAULT_FLAG_ALLOW_RETRY is set, the mmap_sem must be released +* If FAULT_FLAG_ALLOW_RETRY is set, the mmap_lock must be released * before returning VM_FAULT_RETRY only if FAULT_FLAG_RETRY_NOWAIT is * not set. * * If FAULT_FLAG_ALLOW_RETRY is set but FAULT_FLAG_KILLABLE is not * set, VM_FAULT_RETRY can still be returned if and only if there are -* fatal_signal_pending()s, and the mmap_sem must be released before +* fatal_signal_pending()s, and the mmap_lock must be released before * returning it. */ vm_fault_t handle_userfault (struct vm_fault *vmf,unsigned long reason)
@@ -396,14 +396,14 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)* FOLL_DUMP case, anon memory also checks for FOLL_DUMP with * the no_page_table() helper in follow_page_mask(), but the * shmem_vm_ops->fault method is invoked even during -* coredumping without mmap_sem and it ends up here. +* coredumping without mmap_lock and it ends up here. */ if (current->flags & (PF_EXITING |PF_DUMPCORE )) goto out;/* -* Coredumping runs without mmap_sem so we can only check that -* the mmap_sem is held, if PF_DUMPCORE was not set. +* Coredumping runs without mmap_lock so we can only check that +* the mmap_lock is held, if PF_DUMPCORE was not set. */ mmap_assert_locked (mm);
@@ -422,7 +422,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)/* * If it's already released don't get it. This avoids to loop * in __get_user_pages if userfaultfd_release waits on the -* caller of handle_userfault to release the mmap_sem. +* caller of handle_userfault to release the mmap_lock. */ if (unlikely (READ_ONCE (ctx->released))) {/*
@@ -481,7 +481,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)if (vmf->flags &FAULT_FLAG_RETRY_NOWAIT ) goto out; -/* take the reference before dropping the mmap_sem */ +/* take the reference before dropping the mmap_lock */ userfaultfd_ctx_get (ctx);init_waitqueue_func_entry (&uwq.wq, userfaultfd_wake_function);
@@ -890,9 +890,9 @@ static int userfaultfd_release(struct inode *inode, struct file *file)* Flush page faults out of all CPUs. NOTE: all page faults * must be retried without returning VM_FAULT_SIGBUS if * userfaultfd_ctx_get() succeeds but vma->vma_userfault_ctx -* changes while handle_userfault released the mmap_sem. So +* changes while handle_userfault released the mmap_lock. So * it's critical that released is set to true (above), before -* taking the mmap_sem for writing. +* taking the mmap_lock for writing. */ mmap_write_lock (mm); still_valid =mmget_still_valid (mm);
fs/xfs/xfs_file.c +1 -1
@@ -1173,7 +1173,7 @@ xfs_file_llseek(* Locking for serialisation of IO during page faults. This results in a lock * ordering of: * -* mmap_sem (MM) +* mmap_lock (MM) * sb_start_pagefault(vfs, freeze) * i_mmaplock (XFS - truncate serialisation) * page_lock (MM)
fs/xfs/xfs_inode.c +7 -7
@@ -144,17 +144,17 @@ xfs_ilock_attr_map_shared(* * i_rwsem -> i_mmap_lock -> page_lock -> i_ilock * -* mmap_sem locking order: +* mmap_lock locking order: * -* i_rwsem -> page lock -> mmap_sem -* mmap_sem -> i_mmap_lock -> page_lock +* i_rwsem -> page lock -> mmap_lock +* mmap_lock -> i_mmap_lock -> page_lock * -* The difference in mmap_sem locking order mean that we cannot hold the +* The difference in mmap_lock locking order mean that we cannot hold the * i_mmap_lock over syscall based read(2)/write(2) based IO. These IO paths can -* fault in pages during copy in/out (for buffered IO) or require the mmap_sem +* fault in pages during copy in/out (for buffered IO) or require the mmap_lock * in get_user_pages() to map the user pages into the kernel address space for * direct IO. Similarly the i_rwsem cannot be taken inside a page fault because -* page faults already hold the mmap_sem. +* page faults already hold the mmap_lock. * * Hence to serialise fully against both syscall and mmap based IO, we need to * take both the i_rwsem and the i_mmap_lock. These locks should *only* be both
@@ -1634,7 +1634,7 @@ xfs_release(return 0 ;/* * If we can't get the iolock just skip truncating the blocks -* past EOF because we could deadlock with the mmap_sem +* past EOF because we could deadlock with the mmap_lock * otherwise. We'll get another chance to drop them once the * last reference to the inode is dropped, so we'll never leak * blocks permanently.
fs/xfs/xfs_iops.c +2 -2
@@ -27,11 +27,11 @@#include <linux/iversion.h> /* -* Directories have different lock order w.r.t. mmap_sem compared to regular +* Directories have different lock order w.r.t. mmap_lock compared to regular * files. This is due to readdir potentially triggering page faults on a user * buffer inside filldir(), and this happens with the ilock on the directory * held. For regular files, the lock order is the other way around - the -* mmap_sem is taken during the page fault, and then we lock the ilock to do +* mmap_lock is taken during the page fault, and then we lock the ilock to do * block mapping. Hence we need a different class for the directory ilock so * that lockdep can tell them apart. */
include/asm-generic/pgtable.h +3 -3
@@ -981,11 +981,11 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)#endif /* * This function is meant to be used by sites walking pagetables with -* the mmap_sem hold in read mode to protect against MADV_DONTNEED and +* the mmap_lock hold in read mode to protect against MADV_DONTNEED and * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd * into a null pmd and the transhuge page fault can convert a null pmd * into an hugepmd or into a regular pmd (if the hugepage allocation -* fails). While holding the mmap_sem in read mode the pmd becomes +* fails). While holding the mmap_lock in read mode the pmd becomes * stable and stops changing under us only if it's not null and not a * transhuge pmd. When those races occurs and this function makes a * difference vs the standard pmd_none_or_clear_bad, the result is
@@ -995,7 +995,7 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)* * For 32bit kernels with a 64bit large pmd_t this automatically takes * care of reading the pmd atomically to avoid SMP race conditions -* against pmd_populate() when the mmap_sem is hold for reading by the +* against pmd_populate() when the mmap_lock is hold for reading by the * caller (a special atomic read not done by "gcc" as in the generic * version above, is also needed when THP is disabled because the page * fault can populate the pmd from under us).
include/linux/fs.h +2 -2
@@ -1673,10 +1673,10 @@ static inline int sb_start_write_trylock(struct super_block *sb)* * Since page fault freeze protection behaves as a lock, users have to preserve * ordering of freeze protection and other filesystem locks. It is advised to -* put sb_start_pagefault() close to mmap_sem in lock ordering. Page fault +* put sb_start_pagefault() close to mmap_lock in lock ordering. Page fault * handling code implies lock dependency: * -* mmap_sem +* mmap_lock * -> sb_start_pagefault */ static inline void sb_start_pagefault (struct super_block *sb)
include/linux/huge_mm.h +1 -1
@@ -248,7 +248,7 @@ static inline int is_swap_pmd(pmd_t pmd)return !pmd_none (pmd) && !pmd_present (pmd); } -/* mmap_sem must be held on entry */ +/* mmap_lock must be held on entry */ static inline spinlock_t *pmd_trans_huge_lock (pmd_t *pmd,struct vm_area_struct *vma) {
include/linux/mempolicy.h +1 -1
@@ -31,7 +31,7 @@ struct mm_struct;* Locking policy for interlave: * In process context there is no locking because only the process accesses * its own state. All vma manipulation is somewhat protected by a down_read on -* mmap_sem. +* mmap_lock. * * Freeing policy: * Mempolicy objects are reference counted. A mempolicy will be freed when
include/linux/mm.h +5 -5
@@ -406,7 +406,7 @@ extern pgprot_t protection_map[16];* @FAULT_FLAG_WRITE: Fault was a write fault. * @FAULT_FLAG_MKWRITE: Fault was mkwrite of existing PTE. * @FAULT_FLAG_ALLOW_RETRY: Allow to retry the fault if blocked. -* @FAULT_FLAG_RETRY_NOWAIT: Don't drop mmap_sem and wait when retrying. +* @FAULT_FLAG_RETRY_NOWAIT: Don't drop mmap_lock and wait when retrying. * @FAULT_FLAG_KILLABLE: The fault task is in SIGKILL killable region. * @FAULT_FLAG_TRIED: The fault has been tried once. * @FAULT_FLAG_USER: The fault originated in userspace.
@@ -456,10 +456,10 @@ extern pgprot_t protection_map[16];* fault_flag_allow_retry_first - check ALLOW_RETRY the first time * * This is mostly used for places where we want to try to avoid taking -* the mmap_sem for too long a time when waiting for another condition +* the mmap_lock for too long a time when waiting for another condition * to change, in which case we can try to be polite to release the -* mmap_sem in the first round to avoid potential starvation of other -* processes that would also want the mmap_sem. +* mmap_lock in the first round to avoid potential starvation of other +* processes that would also want the mmap_lock. * * Return: true if the page fault allows retry and this is the first * attempt of the fault handling; false otherwise.
@@ -587,7 +587,7 @@ struct vm_operations_struct {* (vma,addr) marked as MPOL_SHARED. The shared policy infrastructure * in mm/mempolicy.c will do this automatically. * get_policy() must NOT add a ref if the policy at (vma,addr) is not -* marked as MPOL_SHARED. vma policies are protected by the mmap_sem. +* marked as MPOL_SHARED. vma policies are protected by the mmap_lock. * If no [shared/vma] mempolicy exists at the addr, get_policy() op * must return NULL--i.e., do not "fallback" to task or system default * policy.
include/linux/mm_types.h +1 -1
@@ -340,7 +340,7 @@ struct vm_area_struct {* can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack * or brk vma (with NULL file) can only be in an anon_vma list. */ -struct list_head anon_vma_chain;/* Serialized by mmap_sem & +struct list_head anon_vma_chain;/* Serialized by mmap_lock & * page_table_lock */ struct anon_vma *anon_vma;/* Serialized by page_table_lock */
include/linux/mmu_notifier.h +4 -4
@@ -122,7 +122,7 @@ struct mmu_notifier_ops {/* * invalidate_range_start() and invalidate_range_end() must be -* paired and are called only when the mmap_sem and/or the +* paired and are called only when the mmap_lock and/or the * locks protecting the reverse maps are held. If the subsystem * can't guarantee that no additional references are taken to * the pages in the range, it has to implement the
@@ -213,13 +213,13 @@ struct mmu_notifier_ops { };/* -* The notifier chains are protected by mmap_sem and/or the reverse map +* The notifier chains are protected by mmap_lock and/or the reverse map * semaphores. Notifier chains are only changed when all reverse maps and -* the mmap_sem locks are taken. +* the mmap_lock locks are taken. * * Therefore notifier chains can only be traversed when either * -* 1. mmap_sem is held. +* 1. mmap_lock is held. * 2. One of the reverse map locks is held (i_mmap_rwsem or anon_vma->rwsem). * 3. No other concurrent thread can access the list (release) */
include/linux/pagemap.h +1 -1
@@ -498,7 +498,7 @@ static inline int lock_page_killable(struct page *page)* lock_page_or_retry - Lock the page, unless this would block and the * caller indicated that it can handle a retry. * -* Return value and mmap_sem implications depend on flags; see +* Return value and mmap_lock implications depend on flags; see * __lock_page_or_retry(). */ static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm,
include/linux/rmap.h +1 -1
@@ -77,7 +77,7 @@ struct anon_vma {struct anon_vma_chain {struct vm_area_struct *vma;struct anon_vma *anon_vma; -struct list_head same_vma;/* locked by mmap_sem & page_table_lock */ +struct list_head same_vma;/* locked by mmap_lock & page_table_lock */ struct rb_node rb;/* locked by anon_vma->rwsem */ unsigned long rb_subtree_last;#ifdef CONFIG_DEBUG_VM_RB
include/linux/sched/mm.h +5 -5
@@ -51,7 +51,7 @@ static inline void mmdrop(struct mm_struct *mm)/* * This has to be called after a get_task_mm()/mmget_not_zero() -* followed by taking the mmap_sem for writing before modifying the +* followed by taking the mmap_lock for writing before modifying the * vmas or anything the coredump pretends not to change from under it. * * It also has to be called when mmgrab() is used in the context of
@@ -59,14 +59,14 @@ static inline void mmdrop(struct mm_struct *mm)* the context of the process to run down_write() on that pinned mm. * * NOTE: find_extend_vma() called from GUP context is the only place -* that can modify the "mm" (notably the vm_start/end) under mmap_sem +* that can modify the "mm" (notably the vm_start/end) under mmap_lock * for reading and outside the context of the process, so it is also -* the only case that holds the mmap_sem for reading that must call -* this function. Generally if the mmap_sem is hold for reading +* the only case that holds the mmap_lock for reading that must call +* this function. Generally if the mmap_lock is hold for reading * there's no need of this check after get_task_mm()/mmget_not_zero(). * * This function can be obsoleted and the check can be removed, after -* the coredump code will hold the mmap_sem for writing before +* the coredump code will hold the mmap_lock for writing before * invoking the ->core_dump methods. */ static inline bool mmget_still_valid (struct mm_struct *mm)
kernel/acct.c +1 -1
@@ -40,7 +40,7 @@* is one more bug... 10/11/98, AV. * * Oh, fsck... Oopsable SMP race in do_process_acct() - we must hold -* ->mmap_sem to walk the vma list of current->mm. Nasty, since it leaks +* ->mmap_lock to walk the vma list of current->mm. Nasty, since it leaks * a struct file opened for write. Fixed. 2/6/2000, AV. */
kernel/cgroup/cpuset.c +2 -2
@@ -1655,7 +1655,7 @@ static void update_tasks_nodemask(struct cpuset *cs)guarantee_online_mems (cs, &newmems);/* -* The mpol_rebind_mm() call takes mmap_sem, which we couldn't +* The mpol_rebind_mm() call takes mmap_lock, which we couldn't * take while holding tasklist_lock. Forks can happen - the * mpol_dup() cpuset_being_rebound check will catch such forks, * and rebind their vma mempolicies too. Because we still hold
@@ -1760,7 +1760,7 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)* * Call with cpuset_mutex held. May take callback_lock during call. * Will take tasklist_lock, scan tasklist for tasks in cpuset cs, -* lock each such tasks mm->mmap_sem, scan its vma's and rebind +* lock each such tasks mm->mmap_lock, scan its vma's and rebind * their mempolicies to the cpusets new mems_allowed. */ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
kernel/events/core.c +3 -3
@@ -1313,7 +1313,7 @@ static void put_ctx(struct perf_event_context *ctx)* perf_event::child_mutex; * perf_event_context::lock * perf_event::mmap_mutex -* mmap_sem +* mmap_lock * perf_addr_filters_head::lock * * cpu_hotplug_lock
@@ -3077,7 +3077,7 @@ static int perf_event_stop(struct perf_event *event, int restart)* pre-existing mappings, called once when new filters arrive via SET_FILTER * ioctl; * (2) perf_addr_filters_adjust(): adjusting filters' offsets based on newly -* registered mapping, called for every new mmap(), with mm::mmap_sem down +* registered mapping, called for every new mmap(), with mm::mmap_lock down * for reading; * (3) perf_event_addr_filters_exec(): clearing filters' offsets in the process * of exec.
@@ -9739,7 +9739,7 @@ static void perf_addr_filters_splice(struct perf_event *event,/* * Scan through mm's vmas and see if one of them matches the * @filter; if so, adjust filter's address range. -* Called with mm::mmap_sem down for reading. +* Called with mm::mmap_lock down for reading. */ static void perf_addr_filter_apply(struct perf_addr_filter *filter, struct mm_struct *mm,
kernel/events/uprobes.c +2 -2
@@ -463,7 +463,7 @@ static int update_ref_ctr(struct uprobe *uprobe, struct mm_struct *mm,* @vaddr: the virtual address to store the opcode. * @opcode: opcode to be written at @vaddr. * -* Called with mm->mmap_sem held for write. +* Called with mm->mmap_lock held for write. * Return 0 (success) or a negative errno. */ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
@@ -1355,7 +1355,7 @@ static int delayed_ref_ctr_inc(struct vm_area_struct *vma) }/* -* Called from mmap_region/vma_adjust with mm->mmap_sem acquired. +* Called from mmap_region/vma_adjust with mm->mmap_lock acquired. * * Currently we ignore all errors and always return 0, the callers * can't handle the failure anyway.
kernel/exit.c +1 -1
@@ -438,7 +438,7 @@ static void exit_mm(void)sync_mm_rss (mm);/* * Serialize with any possible pending coredump. -* We must hold mmap_sem around checking core_state +* We must hold mmap_lock around checking core_state * and clearing tsk->mm. The core-inducing thread * will increment ->nr_threads for each thread in the * group with ->mm != NULL.
kernel/relay.c +1 -1
@@ -91,7 +91,7 @@ static void relay_free_page_array(struct page **array)* * Returns 0 if ok, negative on error * -* Caller should already have grabbed mmap_sem. +* Caller should already have grabbed mmap_lock. */ static int relay_mmap_buf (struct rchan_buf *buf,struct vm_area_struct *vma) {
kernel/sys.c +2 -2
@@ -2007,7 +2007,7 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data }/* -* arg_lock protects concurent updates but we still need mmap_sem for +* arg_lock protects concurent updates but we still need mmap_lock for * read to exclude races with sys_brk. */ mmap_read_lock (mm);
@@ -2122,7 +2122,7 @@ static int prctl_set_mm(int opt, unsigned long addr,/* * arg_lock protects concurent updates of arg boundaries, we need -* mmap_sem for a) concurrent sys_brk, b) finding VMA for addr +* mmap_lock for a) concurrent sys_brk, b) finding VMA for addr * validation. */ mmap_read_lock (mm);
lib/test_lockup.c +4 -4
@@ -103,7 +103,7 @@ MODULE_PARM_DESC(lock_rcu, "grab rcu_read_lock: generate rcu stalls");static bool lock_mmap_sem;module_param (lock_mmap_sem, bool,0400 ); -MODULE_PARM_DESC (lock_mmap_sem,"lock mm->mmap_sem: block procfs interfaces" ); +MODULE_PARM_DESC (lock_mmap_sem,"lock mm->mmap_lock: block procfs interfaces" );static unsigned long lock_rwsem_ptr;module_param_unsafe (lock_rwsem_ptr, ulong,0400 );
@@ -191,7 +191,7 @@ static void test_lock(bool master, bool verbose)if (lock_mmap_sem && master) {if (verbose) -pr_notice ("lock mmap_sem pid=%d\n" , main_task->pid); +pr_notice ("lock mmap_lock pid=%d\n" , main_task->pid);if (lock_read)mmap_read_lock (main_task->mm);else
@@ -280,7 +280,7 @@ static void test_unlock(bool master, bool verbose)else mmap_write_unlock (main_task->mm);if (verbose) -pr_notice ("unlock mmap_sem pid=%d\n" , main_task->pid); +pr_notice ("unlock mmap_lock pid=%d\n" , main_task->pid); }if (lock_rwsem_ptr && master) {
@@ -505,7 +505,7 @@ static int __init test_lockup_init(void) }if (lock_mmap_sem && !main_task->mm) { -pr_err ("no mm to lock mmap_sem\n" ); +pr_err ("no mm to lock mmap_lock\n" );return -EINVAL ; }
mm/filemap.c +19 -19
@@ -76,16 +76,16 @@* ->i_mutex * ->i_mmap_rwsem (truncate->unmap_mapping_range) * -* ->mmap_sem +* ->mmap_lock * ->i_mmap_rwsem * ->page_table_lock or pte_lock (various, mainly in memory.c) * ->i_pages lock (arch-dependent flush_dcache_mmap_lock) * -* ->mmap_sem +* ->mmap_lock * ->lock_page (access_process_vm) * * ->i_mutex (generic_perform_write) -* ->mmap_sem (fault_in_pages_readable->do_page_fault) +* ->mmap_lock (fault_in_pages_readable->do_page_fault) * * bdi->wb.list_lock * sb_lock (fs/fs-writeback.c)
@@ -1374,21 +1374,21 @@ EXPORT_SYMBOL_GPL(__lock_page_killable);/* * Return values: -* 1 - page is locked; mmap_sem is still held. +* 1 - page is locked; mmap_lock is still held. * 0 - page is not locked. * mmap_lock has been released (mmap_read_unlock(), unless flags had both * FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_RETRY_NOWAIT set, in -* which case mmap_sem is still held. +* which case mmap_lock is still held. * * If neither ALLOW_RETRY nor KILLABLE are set, will always return 1 -* with the page locked and the mmap_sem unperturbed. +* with the page locked and the mmap_lock unperturbed. */ int __lock_page_or_retry (struct page *page,struct mm_struct *mm,unsigned int flags) {if (fault_flag_allow_retry_first (flags)) {/* -* CAUTION! In this case, mmap_sem is not released +* CAUTION! In this case, mmap_lock is not released * even though return 0. */ if (flags &FAULT_FLAG_RETRY_NOWAIT )
@@ -2315,14 +2315,14 @@ EXPORT_SYMBOL(generic_file_read_iter);#ifdef CONFIG_MMU #define MMAP_LOTSAMISS (100)/* -* lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_sem +* lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_lock * @vmf - the vm_fault for this fault. * @page - the page to lock. * @fpin - the pointer to the file we may pin (or is already pinned). * -* This works similar to lock_page_or_retry in that it can drop the mmap_sem. +* This works similar to lock_page_or_retry in that it can drop the mmap_lock. * It differs in that it actually returns the page locked if it returns 1 and 0 -* if it couldn't lock the page. If we did have to drop the mmap_sem then fpin +* if it couldn't lock the page. If we did have to drop the mmap_lock then fpin * will point to the pinned file and needs to be fput()'ed at a later point. */ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,
@@ -2333,7 +2333,7 @@ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,/* * NOTE! This will make us return with VM_FAULT_RETRY, but with -* the mmap_sem still held. That's how FAULT_FLAG_RETRY_NOWAIT +* the mmap_lock still held. That's how FAULT_FLAG_RETRY_NOWAIT * is supposed to work. We have way too many special cases.. */ if (vmf->flags &FAULT_FLAG_RETRY_NOWAIT )
@@ -2343,10 +2343,10 @@ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,if (vmf->flags &FAULT_FLAG_KILLABLE ) {if (__lock_page_killable (page)) {/* -* We didn't have the right flags to drop the mmap_sem, +* We didn't have the right flags to drop the mmap_lock, * but all fault_handlers only check for fatal signals * if we return VM_FAULT_RETRY, so we need to drop the -* mmap_sem here and return 0 if we don't have a fpin. +* mmap_lock here and return 0 if we don't have a fpin. */ if (*fpin ==NULL )mmap_read_unlock (vmf->vma->vm_mm);
@@ -2411,7 +2411,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)/* * Asynchronous readahead happens when we find the page and PG_readahead, * so we want to possibly extend the readahead further. We return the file that -* was pinned if we have to drop the mmap_sem in order to do IO. +* was pinned if we have to drop the mmap_lock in order to do IO. */ static struct file *do_async_mmap_readahead (struct vm_fault *vmf,struct page *page)
@@ -2446,12 +2446,12 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf,* it in the page cache, and handles the special cases reasonably without * having a lot of duplicated code. * -* vma->vm_mm->mmap_sem must be held on entry. +* vma->vm_mm->mmap_lock must be held on entry. * -* If our return value has VM_FAULT_RETRY set, it's because the mmap_sem +* If our return value has VM_FAULT_RETRY set, it's because the mmap_lock * may be dropped before doing I/O or by lock_page_maybe_drop_mmap(). * -* If our return value does not have VM_FAULT_RETRY set, the mmap_sem +* If our return value does not have VM_FAULT_RETRY set, the mmap_lock * has not been released. * * We never return with VM_FAULT_RETRY and a bit from VM_FAULT_ERROR set.
@@ -2521,7 +2521,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) goto page_not_uptodate;/* -* We've made it this far and we had to drop our mmap_sem, now is the +* We've made it this far and we had to drop our mmap_lock, now is the * time to return to the upper layer and have it re-find the vma and * redo the fault. */
@@ -2572,7 +2572,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) out_retry:/* -* We dropped the mmap_sem, we need to return to the fault handler to +* We dropped the mmap_lock, we need to return to the fault handler to * re-find the vma and come back and find our hopefully still populated * page. */
mm/frame_vector.c +1 -1
@@ -29,7 +29,7 @@* different type underlying the specified range of virtual addresses. * When the function isn't able to map a single page, it returns error. * -* This function takes care of grabbing mmap_sem as necessary. +* This function takes care of grabbing mmap_lock as necessary. */ int get_vaddr_frames (unsigned long start,unsigned int nr_frames,unsigned int gup_flags,struct frame_vector *vec)
mm/gup.c +19 -19
@@ -584,7 +584,7 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, pmdval =READ_ONCE (*pmd);/* * MADV_DONTNEED may convert the pmd to null because -* mmap_sem is held in read mode +* mmap_lock is held in read mode */ if (pmd_none (pmdval))return no_page_table (vma, flags);
@@ -847,8 +847,8 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address, }/* -* mmap_sem must be held on entry. If @locked != NULL and *@flags -* does not include FOLL_NOWAIT, the mmap_sem may be released. If it +* mmap_lock must be held on entry. If @locked != NULL and *@flags +* does not include FOLL_NOWAIT, the mmap_lock may be released. If it * is, *@locked will be set to 0 and -EBUSY returned. */ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
@@ -971,7 +971,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)* only intends to ensure the pages are faulted in. * @vmas: array of pointers to vmas corresponding to each page. * Or NULL if the caller does not require them. -* @locked: whether we're still with the mmap_sem held +* @locked: whether we're still with the mmap_lock held * * Returns either number of pages pinned (which may be less than the * number requested), or an error. Details about the return value:
@@ -983,9 +983,9 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)* * The caller is responsible for releasing returned @pages, via put_page(). * -* @vmas are valid only as long as mmap_sem is held. +* @vmas are valid only as long as mmap_lock is held. * -* Must be called with mmap_sem held. It may be released. See below. +* Must be called with mmap_lock held. It may be released. See below. * * __get_user_pages walks a process's page tables and takes a reference to * each struct page that each user address corresponds to at a given
@@ -1006,12 +1006,12 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)* appropriate) must be called after the page is finished with, and * before put_page is called. * -* If @locked != NULL, *@locked will be set to 0 when mmap_sem is +* If @locked != NULL, *@locked will be set to 0 when mmap_lock is * released by an up_read(). That can happen if @gup_flags does not * have FOLL_NOWAIT. * * A caller using such a combination of @locked and @gup_flags -* must therefore hold the mmap_sem for reading only, and recognize +* must therefore hold the mmap_lock for reading only, and recognize * when it's been released. Otherwise, it must be held for either * reading or writing and will not be released. *
@@ -1072,7 +1072,7 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,if (locked && *locked ==0 ) {/* * We've got a VM_FAULT_RETRY -* and we've lost mmap_sem. +* and we've lost mmap_lock. * We must stop here. */ BUG_ON (gup_flags &FOLL_NOWAIT );
@@ -1175,7 +1175,7 @@ static bool vma_permits_fault(struct vm_area_struct *vma,* @mm: mm_struct of target mm * @address: user address * @fault_flags:flags to pass down to handle_mm_fault() -* @unlocked: did we unlock the mmap_sem while retrying, maybe NULL if caller +* @unlocked: did we unlock the mmap_lock while retrying, maybe NULL if caller * does not allow retry * * This is meant to be called in the specific scenario where for locking reasons
@@ -1195,8 +1195,8 @@ static bool vma_permits_fault(struct vm_area_struct *vma,* such architectures, gup() will not be enough to make a subsequent access * succeed. * -* This function will not return with an unlocked mmap_sem. So it has not the -* same semantics wrt the @mm->mmap_sem as does filemap_fault(). +* This function will not return with an unlocked mmap_lock. So it has not the +* same semantics wrt the @mm->mmap_lock as does filemap_fault(). */ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, unsigned long address, unsigned int fault_flags,
@@ -1380,13 +1380,13 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,* @vma: target vma * @start: start address * @end: end address -* @locked: whether the mmap_sem is still held +* @locked: whether the mmap_lock is still held * * This takes care of mlocking the pages too if VM_LOCKED is set. * * return 0 on success, negative error code on error. * -* vma->vm_mm->mmap_sem must be held. +* vma->vm_mm->mmap_lock must be held. * * If @locked is NULL, it may be held for read or write and will * be unperturbed.
@@ -1438,7 +1438,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,* * This is used to implement mlock() and the MAP_POPULATE / MAP_LOCKED mmap * flags. VMAs must be already marked with the desired vm_flags, and -* mmap_sem must not be held. +* mmap_lock must not be held. */ int __mm_populate (unsigned long start,unsigned long len,int ignore_errors) {
@@ -1505,7 +1505,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)* NULL wherever the ZERO_PAGE, or an anonymous pte_none, has been found - * allowing a hole to be left in the corefile to save diskspace. * -* Called without mmap_sem, but after all other threads have been killed. +* Called without mmap_lock, but after all other threads have been killed. */ #ifdef CONFIG_ELF_CORE struct page *get_dump_page (unsigned long addr)
@@ -1866,9 +1866,9 @@ static long __get_user_pages_remote(struct task_struct *tsk,* * The caller is responsible for releasing returned @pages, via put_page(). * -* @vmas are valid only as long as mmap_sem is held. +* @vmas are valid only as long as mmap_lock is held. * -* Must be called with mmap_sem held for read or write. +* Must be called with mmap_lock held for read or write. * * get_user_pages walks a process's page tables and takes a reference to * each struct page that each user address corresponds to at a given
@@ -2802,7 +2802,7 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages,* @pages: array that receives pointers to the pages pinned. * Should be at least nr_pages long. * -* Attempt to pin user pages in memory without taking mm->mmap_sem. +* Attempt to pin user pages in memory without taking mm->mmap_lock. * If not successful, it will fall back to taking the lock and * calling get_user_pages(). *
mm/huge_memory.c +2 -2
@@ -1951,7 +1951,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,/* * We don't have to worry about the ordering of src and dst -* ptlocks because exclusive mmap_sem prevents deadlock. +* ptlocks because exclusive mmap_lock prevents deadlock. */ old_ptl =__pmd_trans_huge_lock (old_pmd, vma);if (old_ptl) {
@@ -2797,7 +2797,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)if (PageAnon (head)) {/* -* The caller does not necessarily hold an mmap_sem that would +* The caller does not necessarily hold an mmap_lock that would * prevent the anon_vma disappearing so we first we take a * reference to it and then lock the anon_vma for write. This * is similar to page_lock_anon_vma_read except the write lock
mm/hugetlb.c +1 -1
@@ -4583,7 +4583,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, (const void __user *) src_addr, pages_per_huge_page(h), false); -/* fallback to copy_from_user outside mmap_sem */ +/* fallback to copy_from_user outside mmap_lock */ if (unlikely (ret)) { ret = -ENOENT ; *pagep = page;
mm/internal.h +2 -2
@@ -333,7 +333,7 @@ static inline void munlock_vma_pages_all(struct vm_area_struct *vma) }/* -* must be called with vma's mmap_sem held for read or write, and page locked. +* must be called with vma's mmap_lock held for read or write, and page locked. */ extern void mlock_vma_page (struct page *page);extern unsigned int munlock_vma_page (struct page *page);
@@ -402,7 +402,7 @@ static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,/* * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or -* anything, so we only pin the file and drop the mmap_sem if only +* anything, so we only pin the file and drop the mmap_lock if only * FAULT_FLAG_ALLOW_RETRY is set, while this is the first attempt. */ if (fault_flag_allow_retry_first(flags) &&
mm/khugepaged.c +17 -17
@@ -503,7 +503,7 @@ void __khugepaged_exit(struct mm_struct *mm)* under mmap sem read mode). Stop here (after we * return all pagetables will be destroyed) until * khugepaged has finished working on the pagetables -* under the mmap_sem. +* under the mmap_lock. */ mmap_write_lock (mm);mmap_write_unlock (mm);
@@ -848,8 +848,8 @@ khugepaged_alloc_page(struct page **hpage, gfp_t gfp, int node)#endif /* -* If mmap_sem temporarily dropped, revalidate vma -* before taking mmap_sem. +* If mmap_lock temporarily dropped, revalidate vma +* before taking mmap_lock. * Return 0 if succeeds, otherwise return none-zero * value (scan code). */
@@ -881,7 +881,7 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address,* Only done if khugepaged_scan_pmd believes it is worthwhile. * * Called and returns without pte mapped or spinlocks held, -* but with mmap_sem held to protect against vma changes. +* but with mmap_lock held to protect against vma changes. */ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
@@ -913,7 +913,7 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm, swapped_in++; ret =do_swap_page (&vmf); -/* do_swap_page returns VM_FAULT_RETRY with released mmap_sem */ +/* do_swap_page returns VM_FAULT_RETRY with released mmap_lock */ if (ret &VM_FAULT_RETRY ) {mmap_read_lock (mm);if (hugepage_vma_revalidate (mm, address, &vmf.vma)) {
@@ -962,9 +962,9 @@ static void collapse_huge_page(struct mm_struct *mm, gfp =alloc_hugepage_khugepaged_gfpmask () | __GFP_THISNODE;/* -* Before allocating the hugepage, release the mmap_sem read lock. +* Before allocating the hugepage, release the mmap_lock read lock. * The allocation can take potentially a long time if it involves -* sync compaction, and we do not need to hold the mmap_sem during +* sync compaction, and we do not need to hold the mmap_lock during * that. We will recheck the vma after taking it again in write mode. */ mmap_read_unlock (mm);
@@ -996,8 +996,8 @@ static void collapse_huge_page(struct mm_struct *mm, }/* -* __collapse_huge_page_swapin always returns with mmap_sem locked. -* If it fails, we release mmap_sem and jump out_nolock. +* __collapse_huge_page_swapin always returns with mmap_lock locked. +* If it fails, we release mmap_lock and jump out_nolock. * Continuing to collapse causes inconsistency. */ if (!__collapse_huge_page_swapin (mm, vma, address, pmd, referenced)) {
@@ -1247,7 +1247,7 @@ static int khugepaged_scan_pmd(struct mm_struct *mm,pte_unmap_unlock (pte, ptl);if (ret) { node =khugepaged_find_target_node (); -/* collapse_huge_page will return with the mmap_sem released */ +/* collapse_huge_page will return with the mmap_lock released */ collapse_huge_page (mm, address, hpage, node, referenced); } out:
@@ -1448,7 +1448,7 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)* later. * * Not that vma->anon_vma check is racy: it can be set up after -* the check but before we took mmap_sem by the fault path. +* the check but before we took mmap_lock by the fault path. * But page lock would prevent establishing any new ptes of the * page, so we are safe. *
@@ -1468,10 +1468,10 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)if (!pmd)continue ;/* -* We need exclusive mmap_sem to retract page table. +* We need exclusive mmap_lock to retract page table. * * We use trylock due to lock inversion: we need to acquire -* mmap_sem while holding page lock. Fault path does it in +* mmap_lock while holding page lock. Fault path does it in * reverse order. Trylock is a way to avoid deadlock. */ if (mmap_write_trylock (vma->vm_mm)) {
@@ -1967,7 +1967,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,*/ vma =NULL ;if (unlikely (!mmap_read_trylock (mm))) - goto breakouterloop_mmap_sem; + goto breakouterloop_mmap_lock;if (likely (!khugepaged_test_exit (mm))) vma =find_vma (mm, khugepaged_scan.address);
@@ -2024,15 +2024,15 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, khugepaged_scan.address +=HPAGE_PMD_SIZE ; progress +=HPAGE_PMD_NR ;if (ret) -/* we released mmap_sem so break loop */ - goto breakouterloop_mmap_sem; +/* we released mmap_lock so break loop */ + goto breakouterloop_mmap_lock;if (progress >= pages) goto breakouterloop; } } breakouterloop:mmap_read_unlock (mm);/* exit_mmap will destroy ptes after this */ -breakouterloop_mmap_sem: +breakouterloop_mmap_lock:spin_lock (&khugepaged_mm_lock);VM_BUG_ON (khugepaged_scan.mm_slot != mm_slot);
mm/ksm.c +6 -6
@@ -442,7 +442,7 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm,/* * ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's * page tables after it has passed through ksm_exit() - which, if necessary, -* takes mmap_sem briefly to serialize against them. ksm_exit() does not set +* takes mmap_lock briefly to serialize against them. ksm_exit() does not set * a special flag: they can just back out as soon as mm_users goes to zero. * ksm_test_exit() is used throughout to make this test for exit: in some * places for correctness, in some places just to avoid unnecessary work.
@@ -831,7 +831,7 @@ static void remove_trailing_rmap_items(struct mm_slot *mm_slot,* Though it's very tempting to unmerge rmap_items from stable tree rather * than check every pte of a given vma, the locking doesn't quite work for * that - an rmap_item is assigned to the stable tree after inserting ksm -* page and upping mmap_sem. Nor does it fit with the way we skip dup'ing +* page and upping mmap_lock. Nor does it fit with the way we skip dup'ing * rmap_items from parent to child at fork time (so as not to waste time * if exit comes before the next scan reaches it). *
@@ -1292,7 +1292,7 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,/* Unstable nid is in union with stable anon_vma: remove first */ remove_rmap_item_from_tree (rmap_item); -/* Must get reference to anon_vma while still holding mmap_sem */ +/* Must get reference to anon_vma while still holding mmap_lock */ rmap_item->anon_vma = vma->anon_vma;get_anon_vma (vma->anon_vma); out:
@@ -2343,13 +2343,13 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page) struct mm_slot, mm_list);if (ksm_scan.address ==0 ) {/* -* We've completed a full scan of all vmas, holding mmap_sem +* We've completed a full scan of all vmas, holding mmap_lock * throughout, and found no VM_MERGEABLE: so do the same as * __ksm_exit does to remove this mm from all our lists now. * This applies either when cleaning up after __ksm_exit * (but beware: we can reach here even before __ksm_exit), * or when all VM_MERGEABLE areas have been unmapped (and -* mmap_sem then protects against race with MADV_MERGEABLE). +* mmap_lock then protects against race with MADV_MERGEABLE). */ hash_del (&slot->link);list_del (&slot->mm_list);
@@ -2536,7 +2536,7 @@ void __ksm_exit(struct mm_struct *mm)* This process is exiting: if it's straightforward (as is the * case when ksmd was never running), free mm_slot immediately. * But if it's at the cursor or has rmap_items linked to it, use -* mmap_sem to synchronize with any break_cows before pagetables +* mmap_lock to synchronize with any break_cows before pagetables * are freed, and leave the mm_slot on the list for ksmd to free. * Beware: ksm may already have noticed it exiting and freed the slot. */
mm/maccess.c +2 -2
@@ -40,9 +40,9 @@ probe_write_common(void __user *dst, const void *src, size_t size)* happens, handle that and return -EFAULT. * * We ensure that the copy_from_user is executed in atomic context so that -* do_page_fault() doesn't attempt to take mmap_sem. This makes +* do_page_fault() doesn't attempt to take mmap_lock. This makes * probe_kernel_read() suitable for use within regions where the caller -* already holds mmap_sem, or other locks which nest inside mmap_sem. +* already holds mmap_lock, or other locks which nest inside mmap_lock. * * probe_kernel_read_strict() is the same as probe_kernel_read() except for * the case where architectures have non-overlapping user and kernel address
mm/madvise.c +10 -10
@@ -40,7 +40,7 @@ struct madvise_walk_private {/* * Any behaviour which results in changes to the vma->vm_flags needs to -* take mmap_sem for writing. Others, which simply traverse vmas, need +* take mmap_lock for writing. Others, which simply traverse vmas, need * to only take it for reading. */ static int madvise_need_mmap_write (int behavior)
@@ -165,7 +165,7 @@ static long madvise_behavior(struct vm_area_struct *vma, success:/* -* vm_flags is protected by the mmap_sem held in write mode. +* vm_flags is protected by the mmap_lock held in write mode. */ vma->vm_flags = new_flags;
@@ -285,9 +285,9 @@ static long madvise_willneed(struct vm_area_struct *vma,* Filesystem's fadvise may need to take various locks. We need to * explicitly grab a reference because the vma (and hence the * vma's reference to the file) can go away as soon as we drop -* mmap_sem. +* mmap_lock. */ - *prev =NULL ;/* tell sys_madvise we drop mmap_sem */ + *prev =NULL ;/* tell sys_madvise we drop mmap_lock */ get_file (file);mmap_read_unlock (current->mm); offset = (loff_t)(start - vma->vm_start)
@@ -768,7 +768,7 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,return -EINVAL ;if (!userfaultfd_remove (vma, start, end)) { - *prev =NULL ;/* mmap_sem has been dropped, prev is stale */ + *prev =NULL ;/* mmap_lock has been dropped, prev is stale */ mmap_read_lock (current->mm); vma =find_vma (current->mm, start);
@@ -791,7 +791,7 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,if (end > vma->vm_end) {/* * Don't fail if end > vma->vm_end. If the old -* vma was splitted while the mmap_sem was +* vma was splitted while the mmap_lock was * released the effect of the concurrent * operation may not cause madvise() to * have an undefined result. There may be an
@@ -826,7 +826,7 @@ static long madvise_remove(struct vm_area_struct *vma,int error;struct file *f; - *prev =NULL ;/* tell sys_madvise we drop mmap_sem */ + *prev =NULL ;/* tell sys_madvise we drop mmap_lock */ if (vma->vm_flags &VM_LOCKED )return -EINVAL ;
@@ -847,11 +847,11 @@ static long madvise_remove(struct vm_area_struct *vma,* Filesystem's fallocate may need to take i_mutex. We need to * explicitly grab a reference because the vma (and hence the * vma's reference to the file) can go away as soon as we drop -* mmap_sem. +* mmap_lock. */ get_file (f);if (userfaultfd_remove (vma, start, end)) { -/* mmap_sem was not released by userfaultfd_remove() */ +/* mmap_lock was not released by userfaultfd_remove() */ mmap_read_unlock (current->mm); } error = vfs_fallocate(f,
@@ -1153,7 +1153,7 @@ int do_madvise(unsigned long start, size_t len_in, int behavior) goto out;if (prev) vma = prev->vm_next; -else /* madvise_remove dropped mmap_sem */ +else /* madvise_remove dropped mmap_lock */ vma =find_vma (current->mm, start); } out:
mm/memcontrol.c +1 -1
@@ -5890,7 +5890,7 @@ static void mem_cgroup_move_charge(void) retry:if (unlikely (!mmap_read_trylock (mc.mm))) {/* -* Someone who are holding the mmap_sem might be waiting in +* Someone who are holding the mmap_lock might be waiting in * waitq. So we cancel all extra charges, wake up all waiters, * and retry. Because we cancel precharges, we might not be able * to move enough charges, but moving charge is a best-effort
mm/memory.c +20 -20
@@ -1188,7 +1188,7 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,* Here there can be other concurrent MADV_DONTNEED or * trans huge page faults running, and if the pmd is * none or trans huge it can change under us. This is -* because MADV_DONTNEED holds the mmap_sem in read +* because MADV_DONTNEED holds the mmap_lock in read * mode. */ if (pmd_none_or_trans_huge_or_clear_bad (pmd))
@@ -1639,7 +1639,7 @@ EXPORT_SYMBOL(vm_insert_pages);* The page does not need to be reserved. * * Usually this function is called from f_op->mmap() handler -* under mm->mmap_sem write-lock, so it can change vma->vm_flags. +* under mm->mmap_lock write-lock, so it can change vma->vm_flags. * Caller must set VM_MIXEDMAP on vma if it wants to call this * function from other places, for example from page-fault handler. *
@@ -2576,7 +2576,7 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf)* mapping may be NULL here because some device drivers do not * set page.mapping but still dirty their pages * -* Drop the mmap_sem before waiting on IO, if we can. The file +* Drop the mmap_lock before waiting on IO, if we can. The file * is pinning the mapping, as per above. */ if ((dirtied || page_mkwrite) && mapping) {
@@ -2626,7 +2626,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf)/* * Handle the case of a page which we actually need to copy to a new page. * -* Called with mmap_sem locked and the old page referenced, but +* Called with mmap_lock locked and the old page referenced, but * without the ptl held. * * High level logic flow:
@@ -2889,9 +2889,9 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf)* change only once the write actually happens. This avoids a few races, * and potentially makes it more efficient. * -* We enter with non-exclusive mmap_sem (to exclude vma changes, +* We enter with non-exclusive mmap_lock (to exclude vma changes, * but allow concurrent faults), with pte both mapped and locked. -* We return with mmap_sem still held, but pte unmapped and unlocked. +* We return with mmap_lock still held, but pte unmapped and unlocked. */ static vm_fault_t do_wp_page(struct vm_fault *vmf) __releases(vmf->ptl)
@@ -3079,11 +3079,11 @@ void unmap_mapping_range(struct address_space *mapping,EXPORT_SYMBOL (unmap_mapping_range);/* -* We enter with non-exclusive mmap_sem (to exclude vma changes, +* We enter with non-exclusive mmap_lock (to exclude vma changes, * but allow concurrent faults), and pte mapped but not yet locked. * We return with pte unmapped and unlocked. * -* We return with the mmap_sem locked or unlocked in the same cases +* We return with the mmap_lock locked or unlocked in the same cases * as does filemap_fault(). */ vm_fault_t do_swap_page (struct vm_fault *vmf)
@@ -3301,9 +3301,9 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) }/* -* We enter with non-exclusive mmap_sem (to exclude vma changes, +* We enter with non-exclusive mmap_lock (to exclude vma changes, * but allow concurrent faults), and pte mapped but not yet locked. -* We return with mmap_sem still held, but pte unmapped and unlocked. +* We return with mmap_lock still held, but pte unmapped and unlocked. */ static vm_fault_t do_anonymous_page (struct vm_fault *vmf) {
@@ -3416,7 +3416,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) }/* -* The mmap_sem must have been held on entry, and may have been +* The mmap_lock must have been held on entry, and may have been * released depending on flags and vma->vm_ops->fault() return value. * See filemap_fault() and __lock_page_retry(). */
@@ -3929,11 +3929,11 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) }/* -* We enter with non-exclusive mmap_sem (to exclude vma changes, +* We enter with non-exclusive mmap_lock (to exclude vma changes, * but allow concurrent faults). -* The mmap_sem may have been released depending on flags and our +* The mmap_lock may have been released depending on flags and our * return value. See filemap_fault() and __lock_page_or_retry(). -* If mmap_sem is released, vma may become invalid (for example +* If mmap_lock is released, vma may become invalid (for example * by other thread calling munmap()). */ static vm_fault_t do_fault (struct vm_fault *vmf)
@@ -4162,10 +4162,10 @@ static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud)* with external mmu caches can use to update those (ie the Sparc or * PowerPC hashed page tables that act as extended TLBs). * -* We enter with non-exclusive mmap_sem (to exclude vma changes, but allow +* We enter with non-exclusive mmap_lock (to exclude vma changes, but allow * concurrent faults). * -* The mmap_sem may have been released depending on flags and our return value. +* The mmap_lock may have been released depending on flags and our return value. * See filemap_fault() and __lock_page_or_retry(). */ static vm_fault_t handle_pte_fault (struct vm_fault *vmf)
@@ -4187,7 +4187,7 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)/* * A regular pmd is established and it can't morph into a huge * pmd from under us anymore at this point because we hold the -* mmap_sem read mode and khugepaged takes it in write mode. +* mmap_lock read mode and khugepaged takes it in write mode. * So now it's safe to run pte_offset_map(). */ vmf->pte =pte_offset_map (vmf->pmd, vmf->address);
@@ -4253,7 +4253,7 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)/* * By the time we get here, we already hold the mm semaphore * -* The mmap_sem may have been released depending on flags and our +* The mmap_lock may have been released depending on flags and our * return value. See filemap_fault() and __lock_page_or_retry(). */ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,
@@ -4348,7 +4348,7 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,/* * By the time we get here, we already hold the mm semaphore * -* The mmap_sem may have been released depending on flags and our +* The mmap_lock may have been released depending on flags and our * return value. See filemap_fault() and __lock_page_or_retry(). */ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
@@ -4800,7 +4800,7 @@ void __might_fault(const char *file, int line) {/* * Some code (nfs/sunrpc) uses socket ops on kernel memory while -* holding the mmap_sem, this is safe because kernel memory doesn't +* holding the mmap_lock, this is safe because kernel memory doesn't * get paged out, therefore we'll never actually fault, and the * below annotations will generate false positives. */
mm/mempolicy.c +6 -6
@@ -224,7 +224,7 @@ static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)* handle an empty nodemask with MPOL_PREFERRED here. * * Must be called holding task's alloc_lock to protect task's mems_allowed -* and mempolicy. May also be called holding the mmap_semaphore for write. +* and mempolicy. May also be called holding the mmap_lockaphore for write. */ static int mpol_set_nodemask (struct mempolicy *pol,const nodemask_t *nodes,struct nodemask_scratch *nsc)
@@ -368,7 +368,7 @@ static void mpol_rebind_preferred(struct mempolicy *pol,/* * mpol_rebind_policy - Migrate a policy to a different set of nodes * -* Per-vma policies are protected by mmap_sem. Allocations using per-task +* Per-vma policies are protected by mmap_lock. Allocations using per-task * policies are protected by task->mems_allowed_seq to prevent a premature * OOM/allocation failure due to parallel nodemask modification. */
@@ -398,7 +398,7 @@ void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new)/* * Rebind each vma in mm to new nodemask. * -* Call holding a reference to mm. Takes mm->mmap_sem during call. +* Call holding a reference to mm. Takes mm->mmap_lock during call. */ void mpol_rebind_mm (struct mm_struct *mm,nodemask_t *new)
@@ -764,7 +764,7 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,/* * Apply policy to a single VMA -* This must be called with the mmap_sem held for writing. +* This must be called with the mmap_lock held for writing. */ static int vma_replace_policy (struct vm_area_struct *vma,struct mempolicy *pol)
@@ -789,7 +789,7 @@ static int vma_replace_policy(struct vm_area_struct *vma, } old = vma->vm_policy; - vma->vm_policy = new;/* protected by mmap_sem */ + vma->vm_policy = new;/* protected by mmap_lock */ mpol_put (old);return 0 ;
@@ -988,7 +988,7 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,if (flags &MPOL_F_ADDR ) {/* * Take a refcount on the mpol, lookup_node() -* wil drop the mmap_sem, so after calling +* wil drop the mmap_lock, so after calling * lookup_node() only "pol" remains valid, "vma" * is stale. */
mm/migrate.c +2 -2
@@ -2119,7 +2119,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,* pmd before doing set_pmd_at(), nor to flush the TLB after * set_pmd_at(). Clearing the pmd here would introduce a race * condition against MADV_DONTNEED, because MADV_DONTNEED only holds the -* mmap_sem for reading. If the pmd is set to NULL at any given time, +* mmap_lock for reading. If the pmd is set to NULL at any given time, * MADV_DONTNEED won't wait on the pmd lock and it'll skip clearing this * pmd. */
@@ -2674,7 +2674,7 @@ static void migrate_vma_unmap(struct migrate_vma *migrate)* have the MIGRATE_PFN_MIGRATE flag set for their src array entry. * * It is safe to update device page table after migrate_vma_pages() because -* both destination and source page are still locked, and the mmap_sem is held +* both destination and source page are still locked, and the mmap_lock is held * in read mode (hence no one can unmap the range being migrated). * * Once the caller is done cleaning up things and updating its page table (if it
mm/mlock.c +3 -3
@@ -49,7 +49,7 @@ EXPORT_SYMBOL(can_do_mlock);* When lazy mlocking via vmscan, it is important to ensure that the * vma's VM_LOCKED status is not concurrently being modified, otherwise we * may have mlocked a page that is being munlocked. So lazy mlock must take -* the mmap_sem for read, and verify that the vma really is locked +* the mmap_lock for read, and verify that the vma really is locked * (see mm/rmap.c). */
@@ -381,7 +381,7 @@ static unsigned long __munlock_pagevec_fill(struct pagevec *pvec,/* * Initialize pte walk starting at the already pinned page where we * are sure that there is a pte, as it was pinned under the same -* mmap_sem write op. +* mmap_lock write op. */ pte =get_locked_pte (vma->vm_mm, start, &ptl);/* Make sure we do not cross the page table boundary */
@@ -565,7 +565,7 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, mm->locked_vm += nr_pages;/* -* vm_flags is protected by the mmap_sem held in write mode. +* vm_flags is protected by the mmap_lock held in write mode. * It's okay if try_to_unmap_one unmaps a page just after we * set VM_LOCKED, populate_vma_page_range will bring it back. */
mm/mmap.c +18 -18
@@ -132,7 +132,7 @@ void vma_set_page_prot(struct vm_area_struct *vma) vm_flags &= ~VM_SHARED ; vm_page_prot =vm_pgprot_modify (vm_page_prot, vm_flags); } -/* remove_protection_ptes reads vma->vm_page_prot without mmap_sem */ +/* remove_protection_ptes reads vma->vm_page_prot without mmap_lock */ WRITE_ONCE (vma->vm_page_prot, vm_page_prot); }
@@ -238,14 +238,14 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)/* * Always allow shrinking brk. -* __do_munmap() may downgrade mmap_sem to read. +* __do_munmap() may downgrade mmap_lock to read. */ if (brk <= mm->brk) {int ret;/* -* mm->brk must to be protected by write mmap_sem so update it -* before downgrading mmap_sem. When __do_munmap() fails, +* mm->brk must to be protected by write mmap_lock so update it +* before downgrading mmap_lock. When __do_munmap() fails, * mm->brk will be restored from origbrk. */ mm->brk = brk;
@@ -505,7 +505,7 @@ static __always_inline void vma_rb_erase(struct vm_area_struct *vma,* After the update, the vma will be reinserted using * anon_vma_interval_tree_post_update_vma(). * -* The entire update must be protected by exclusive mmap_sem and by +* The entire update must be protected by exclusive mmap_lock and by * the root anon_vma's mutex. */ static inline void
@@ -2371,7 +2371,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)/* * vma->vm_start/vm_end cannot change under us because the caller -* is required to hold the mmap_sem in read mode. We need the +* is required to hold the mmap_lock in read mode. We need the * anon_vma lock to serialize against concurrent expand_stacks. */ anon_vma_lock_write (vma->anon_vma);
@@ -2389,7 +2389,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)if (!error) {/* * vma_gap_update() doesn't support concurrent -* updates, but we only hold a shared mmap_sem +* updates, but we only hold a shared mmap_lock * lock here, so we need to protect against * concurrent vma expansions. * anon_vma_lock_write() doesn't help here, as
@@ -2451,7 +2451,7 @@ int expand_downwards(struct vm_area_struct *vma,/* * vma->vm_start/vm_end cannot change under us because the caller -* is required to hold the mmap_sem in read mode. We need the +* is required to hold the mmap_lock in read mode. We need the * anon_vma lock to serialize against concurrent expand_stacks. */ anon_vma_lock_write (vma->anon_vma);
@@ -2469,7 +2469,7 @@ int expand_downwards(struct vm_area_struct *vma,if (!error) {/* * vma_gap_update() doesn't support concurrent -* updates, but we only hold a shared mmap_sem +* updates, but we only hold a shared mmap_lock * lock here, so we need to protect against * concurrent vma expansions. * anon_vma_lock_write() doesn't help here, as
@@ -2855,7 +2855,7 @@ static int __vm_munmap(unsigned long start, size_t len, bool downgrade) ret =__do_munmap (mm, start, len, &uf, downgrade);/* -* Returning 1 indicates mmap_sem is downgraded. +* Returning 1 indicates mmap_lock is downgraded. * But 1 is not legal return value of vm_munmap() and munmap(), reset * it to 0 before return. */
@@ -3107,12 +3107,12 @@ void exit_mmap(struct mm_struct *mm)/* * Manually reap the mm to free as much memory as possible. * Then, as the oom reaper does, set MMF_OOM_SKIP to disregard -* this mm from further consideration. Taking mm->mmap_sem for +* this mm from further consideration. Taking mm->mmap_lock for * write after setting MMF_OOM_SKIP will guarantee that the oom -* reaper will not run on this mm again after mmap_sem is +* reaper will not run on this mm again after mmap_lock is * dropped. * -* Nothing can be holding mm->mmap_sem here and the above call +* Nothing can be holding mm->mmap_lock here and the above call * to mmu_notifier_release(mm) ensures mmu notifier callbacks in * __oom_reap_task_mm() will not block. *
@@ -3437,7 +3437,7 @@ bool vma_is_special_mapping(const struct vm_area_struct *vma, }/* -* Called with mm->mmap_sem held for writing. +* Called with mm->mmap_lock held for writing. * Insert a new vma covering the given region, with the given flags. * Its pages are supplied by the given array of struct page *. * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
@@ -3513,11 +3513,11 @@ static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping)* operations that could ever happen on a certain mm. This includes * vmtruncate, try_to_unmap, and all page faults. * -* The caller must take the mmap_sem in write mode before calling +* The caller must take the mmap_lock in write mode before calling * mm_take_all_locks(). The caller isn't allowed to release the -* mmap_sem until mm_drop_all_locks() returns. +* mmap_lock until mm_drop_all_locks() returns. * -* mmap_sem in write mode is required in order to block all operations +* mmap_lock in write mode is required in order to block all operations * that could modify pagetables and free pages without need of * altering the vma layout. It's also needed in write mode to avoid new * anon_vmas to be associated with existing vmas.
@@ -3622,7 +3622,7 @@ static void vm_unlock_mapping(struct address_space *mapping) }/* -* The mmap_sem cannot be released by the caller until +* The mmap_lock cannot be released by the caller until * mm_drop_all_locks() returns. */ void mm_drop_all_locks (struct mm_struct *mm)
mm/mmu_gather.c +1 -1
@@ -301,7 +301,7 @@ void tlb_finish_mmu(struct mmu_gather *tlb, {/* * If there are parallel threads are doing PTE changes on same range -* under non-exclusive lock (e.g., mmap_sem read-side) but defer TLB +* under non-exclusive lock (e.g., mmap_lock read-side) but defer TLB * flush by batching, one thread may end up seeing inconsistent PTEs * and result in having stale TLB entries. So flush TLB forcefully * if we detect parallel PTE batching threads.
mm/mmu_notifier.c +5 -5
@@ -599,7 +599,7 @@ void __mmu_notifier_invalidate_range(struct mm_struct *mm, }/* -* Same as mmu_notifier_register but here the caller must hold the mmap_sem in +* Same as mmu_notifier_register but here the caller must hold the mmap_lock in * write mode. A NULL mn signals the notifier is being registered for itree * mode. */
@@ -623,7 +623,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,/* * kmalloc cannot be called under mm_take_all_locks(), but we * know that mm->notifier_subscriptions can't change while we -* hold the write side of the mmap_sem. +* hold the write side of the mmap_lock. */ subscriptions =kzalloc (sizeof (struct mmu_notifier_subscriptions ),GFP_KERNEL );
@@ -655,7 +655,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,* readers. acquire can only be used while holding the mmgrab or * mmget, and is safe because once created the * mmu_notifier_subscriptions is not freed until the mm is destroyed. -* As above, users holding the mmap_sem or one of the +* As above, users holding the mmap_lock or one of the * mm_take_all_locks() do not need to use acquire semantics. */ if (subscriptions)
@@ -689,7 +689,7 @@ EXPORT_SYMBOL_GPL(__mmu_notifier_register);* @mn: The notifier to attach * @mm: The mm to attach the notifier to * -* Must not hold mmap_sem nor any other VM related lock when calling +* Must not hold mmap_lock nor any other VM related lock when calling * this registration function. Must also ensure mm_users can't go down * to zero while this runs to avoid races with mmu_notifier_release, * so mm has to be current->mm or the mm should be pinned safely such
@@ -750,7 +750,7 @@ find_get_mmu_notifier(struct mm_struct *mm, const struct mmu_notifier_ops *ops)* are the same. * * Each call to mmu_notifier_get() must be paired with a call to -* mmu_notifier_put(). The caller must hold the write side of mm->mmap_sem. +* mmu_notifier_put(). The caller must hold the write side of mm->mmap_lock. * * While the caller has a mmu_notifier get the mm pointer will remain valid, * and can be converted to an active mm pointer via mmget_not_zero().
mm/mprotect.c +4 -4
@@ -49,7 +49,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,bool uffd_wp_resolve = cp_flags &MM_CP_UFFD_WP_RESOLVE ;/* -* Can be called with only the mmap_sem for reading by +* Can be called with only the mmap_lock for reading by * prot_numa so we must check the pmd isn't constantly * changing from under us from pmd_none to pmd_trans_huge * and/or the other way around.
@@ -59,7 +59,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,/* * The pmd points to a regular pte so the pmd can't change -* from under us even if the mmap_sem is only hold for +* from under us even if the mmap_lock is only hold for * reading. */ pte =pte_offset_map_lock (vma->vm_mm, pmd, addr, &ptl);
@@ -228,7 +228,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, next =pmd_addr_end (addr, end);/* -* Automatic NUMA balancing walks the tables with mmap_sem +* Automatic NUMA balancing walks the tables with mmap_lock * held for read. It's possible a parallel update to occur * between pmd_trans_huge() and a pmd_none_or_clear_bad() * check leading to a false positive and clearing.
@@ -477,7 +477,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev, success:/* -* vm_flags and vm_page_prot are protected by the mmap_sem +* vm_flags and vm_page_prot are protected by the mmap_lock * held in write mode. */ vma->vm_flags = newflags;
mm/mremap.c +4 -4
@@ -146,7 +146,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,/* * We don't have to worry about the ordering of src and dst -* pte locks because exclusive mmap_sem prevents deadlock. +* pte locks because exclusive mmap_lock prevents deadlock. */ old_pte =pte_offset_map_lock (mm, old_pmd, old_addr, &old_ptl); new_pte =pte_offset_map (new_pmd, new_addr);
@@ -213,7 +213,7 @@ static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr,/* * We don't have to worry about the ordering of src and dst -* ptlocks because exclusive mmap_sem prevents deadlock. +* ptlocks because exclusive mmap_lock prevents deadlock. */ old_ptl =pmd_lock (vma->vm_mm, old_pmd); new_ptl =pmd_lockptr (mm, new_pmd);
@@ -710,7 +710,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,* Always allow a shrinking remap: that just unmaps * the unnecessary pages.. * __do_munmap does all the needed commit accounting, and -* downgrades mmap_sem to read if so directed. +* downgrades mmap_lock to read if so directed. */ if (old_len >= new_len) {int retval;
@@ -720,7 +720,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,if (retval <0 && old_len != new_len) { ret = retval; goto out; -/* Returning 1 indicates mmap_sem is downgraded to read. */ +/* Returning 1 indicates mmap_lock is downgraded to read. */ }else if (retval ==1 ) downgraded = true; ret = addr;
mm/nommu.c +3 -3
@@ -592,7 +592,7 @@ static void put_nommu_region(struct vm_region *region)* add a VMA into a process's mm_struct in the appropriate place in the list * and tree and add to the address space's page tree also if not an anonymous * page -* - should be called with mm->mmap_sem held writelocked +* - should be called with mm->mmap_lock held writelocked */ static void add_vma_to_mm (struct mm_struct *mm,struct vm_area_struct *vma) {
@@ -706,7 +706,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)/* * look up the first VMA in which addr resides, NULL if none -* - should be called with mm->mmap_sem at least held readlocked +* - should be called with mm->mmap_lock at least held readlocked */ struct vm_area_struct *find_vma (struct mm_struct *mm,unsigned long addr) {
@@ -752,7 +752,7 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address)/* * look up the first VMA exactly that exactly matches addr -* - should be called with mm->mmap_sem at least held readlocked +* - should be called with mm->mmap_lock at least held readlocked */ static struct vm_area_struct *find_vma_exact(struct mm_struct *mm, unsigned long addr,
mm/oom_kill.c +1 -1
@@ -898,7 +898,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)/* * Kill all user processes sharing victim->mm in other thread groups, if * any. They don't get access to memory reserves, though, to avoid -* depletion of all memory. This prevents mm->mmap_sem livelock when an +* depletion of all memory. This prevents mm->mmap_lock livelock when an * oom killed thread cannot exit because it requires the semaphore and * its contended by another thread trying to allocate memory itself. * That thread will now get access to memory reserves since it has a
mm/pagewalk.c +3 -3
@@ -373,7 +373,7 @@ static int __walk_page_range(unsigned long start, unsigned long end,* caller-specific data to callbacks, @private should be helpful. * * Locking: -* Callers of walk_page_range() and walk_page_vma() should hold @mm->mmap_sem, +* Callers of walk_page_range() and walk_page_vma() should hold @mm->mmap_lock, * because these function traverse vma list and/or access to vma's data. */ int walk_page_range(struct mm_struct *mm, unsigned long start,
@@ -498,11 +498,11 @@ int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,* Also see walk_page_range() for additional information. * * Locking: -* This function can't require that the struct mm_struct::mmap_sem is held, +* This function can't require that the struct mm_struct::mmap_lock is held, * since @mapping may be mapped by multiple processes. Instead * @mapping->i_mmap_rwsem must be held. This might have implications in the * callbacks, and it's up tho the caller to ensure that the -* struct mm_struct::mmap_sem is not needed. +* struct mm_struct::mmap_lock is not needed. * * Also this means that a caller can't rely on the struct * vm_area_struct::vm_flags to be constant across a call,
mm/rmap.c +6 -6
@@ -21,7 +21,7 @@* Lock ordering in mm: * * inode->i_mutex (while writing or truncating, not reading or faulting) -* mm->mmap_sem +* mm->mmap_lock * page->flags PG_locked (lock_page) * (see huegtlbfs below) * hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share) * mapping->i_mmap_rwsem
@@ -177,7 +177,7 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,* to do any locking for the common case of already having * an anon_vma. * -* This must be called with the mmap_sem held for reading. +* This must be called with the mmap_lock held for reading. */ int __anon_vma_prepare (struct vm_area_struct *vma) {
@@ -1433,7 +1433,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,if (!PageTransCompound (page)) {/* * Holding pte lock, we do *not* need -* mmap_sem here +* mmap_lock here */ mlock_vma_page (page); }
@@ -1806,7 +1806,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page,/* * Note: remove_migration_ptes() cannot use page_lock_anon_vma_read() * because that depends on page_mapped(); but not all its usages -* are holding mmap_sem. Users without mmap_sem are required to +* are holding mmap_lock. Users without mmap_lock are required to * take a reference count to prevent the anon_vma disappearing */ anon_vma =page_anon_vma (page);
@@ -1826,7 +1826,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page,* Find all the mappings of a page using the mapping pointer and the vma chains * contained in the anon_vma struct it points to. * -* When called from try_to_munlock(), the mmap_sem of the mm containing the vma +* When called from try_to_munlock(), the mmap_lock of the mm containing the vma * where the page was found will be held for write. So, we won't recheck * vm_flags for that VMA. That should be OK, because that vma shouldn't be * LOCKED.
@@ -1878,7 +1878,7 @@ static void rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc,* Find all the mappings of a page using the mapping pointer and the vma chains * contained in the address_space struct it points to. * -* When called from try_to_munlock(), the mmap_sem of the mm containing the vma +* When called from try_to_munlock(), the mmap_lock of the mm containing the vma * where the page was found will be held for write. So, we won't recheck * vm_flags for that VMA. That should be OK, because that vma shouldn't be * LOCKED.
mm/shmem.c +2 -2
@@ -2338,7 +2338,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, PAGE_SIZE);kunmap_atomic (page_kaddr); -/* fallback to copy_from_user outside mmap_sem */ +/* fallback to copy_from_user outside mmap_lock */ if (unlikely (ret)) { *pagep = page;shmem_inode_unacct_blocks (inode,1 );
@@ -4163,7 +4163,7 @@ int shmem_zero_setup(struct vm_area_struct *vma)loff_t size = vma->vm_end - vma->vm_start;/* -* Cloning a new file under mmap_sem leads to a lock ordering conflict +* Cloning a new file under mmap_lock leads to a lock ordering conflict * between XFS directory reading and selinux: since this file is only * accessible to the user through its mapping, use S_PRIVATE flag to * bypass file security, in the same way as shmem_kernel_file_setup().
mm/swap_state.c +2 -2
@@ -534,7 +534,7 @@ static unsigned long swapin_nr_pages(unsigned long offset)* This has been extended to use the NUMA policies from the mm triggering * the readahead. * -* Caller must hold read mmap_sem if vmf->vma is not NULL. +* Caller must hold read mmap_lock if vmf->vma is not NULL. */ struct page *swap_cluster_readahead (swp_entry_t entry,gfp_t gfp_mask,struct vm_fault *vmf)
@@ -716,7 +716,7 @@ static void swap_ra_info(struct vm_fault *vmf,* Primitive swap readahead code. We simply read in a few pages whoes * virtual addresses are around the fault address in the same vma. * -* Caller must hold read mmap_sem if vmf->vma is not NULL. +* Caller must hold read mmap_lock if vmf->vma is not NULL. * */ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
mm/userfaultfd.c +4 -4
@@ -77,7 +77,7 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm, PAGE_SIZE);kunmap_atomic (page_kaddr); -/* fallback to copy_from_user outside mmap_sem */ +/* fallback to copy_from_user outside mmap_lock */ if (unlikely (ret)) { ret = -ENOENT ; *pagep = page;
@@ -203,7 +203,7 @@ static pmd_t *mm_alloc_pmd(struct mm_struct *mm, unsigned long address)#ifdef CONFIG_HUGETLB_PAGE /* * __mcopy_atomic processing for HUGETLB vmas. Note that this routine is -* called with mmap_sem held, it will release mmap_sem before returning. +* called with mmap_lock held, it will release mmap_lock before returning. */ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma,
@@ -250,7 +250,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, retry:/* -* On routine entry dst_vma is set. If we had to drop mmap_sem and +* On routine entry dst_vma is set. If we had to drop mmap_lock and * retry, dst_vma will be set to NULL and we must lookup again. */ if (!dst_vma) {
@@ -360,7 +360,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,* private and shared mappings. See the routine * restore_reserve_on_error for details. Unfortunately, we * can not call restore_reserve_on_error now as it would -* require holding mmap_sem. +* require holding mmap_lock. * * If a reservation for the page existed in the reservation * map of a private mapping, the map was modified to indicate
mm/util.c +1 -1
@@ -425,7 +425,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)* @bypass_rlim: %true if checking RLIMIT_MEMLOCK should be skipped * * Assumes @task and @mm are valid (i.e. at least one reference on each), and -* that mmap_sem is held as writer. +* that mmap_lock is held as writer. * * Return: * * 0 on success
security/keys/keyctl.c +1 -1
@@ -878,7 +878,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)* * Allocating a temporary buffer to hold the keys before * transferring them to user buffer to avoid potential -* deadlock involving page fault and mmap_sem. +* deadlock involving page fault and mmap_lock. * * key_data_len = (buflen <= PAGE_SIZE) * ? buflen : actual length of key data
sound/core/oss/pcm_oss.c +1 -1
@@ -2876,7 +2876,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)if (runtime->oss.params) {/* use mutex_trylock() for params_lock for avoiding a deadlock -* between mmap_sem and params_lock taken by +* between mmap_lock and params_lock taken by * copy_from/to_user() in snd_pcm_oss_write/read() */ err =snd_pcm_oss_change_params (substream, true);
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
Andrew Morton
maintainerRe: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
Quoted 1 line · On Tue, 19 May 2020 22:29:08 -0700 Michel Lespinasse <[email protected]> wrote:
Convert comments that reference
mmap_semto referencemmap_lockinstead.
This may not be complete..
From: Andrew Morton <[email protected]>
Subject: mmap-locking-api-convert-mmap_sem-comments-fix
fix up linux-next leftovers
---
arch/powerpc/mm/fault.c | 2 +- include/linux/pgtable.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/mm/fault.c renamed from arch/powerpc/mm/fault.c~mmap-locking-api-convert-mmap_sem-comments-fix +1 -1
@@ -138,7 +138,7 @@ static noinline int bad_access_pkey(stru* 2. T1 : set AMR to deny access to pkey=4, touches, page * 3. T1 : faults... * 4. T2: mprotect_key(foo, PAGE_SIZE, pkey=5); -* 5. T1 : enters fault handler, takes mmap_sem, etc... +* 5. T1 : enters fault handler, takes mmap_lock, etc... * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really * faulted on a pte with its pkey=4. */
include/linux/pgtable.h renamed from include/linux/pgtable.h~mmap-locking-api-convert-mmap_sem-comments-fix +3 -3
@@ -1101,11 +1101,11 @@ static inline pmd_t pmd_read_atomic(pmd_#endif /* * This function is meant to be used by sites walking pagetables with -* the mmap_sem hold in read mode to protect against MADV_DONTNEED and +* the mmap_lock held in read mode to protect against MADV_DONTNEED and * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd * into a null pmd and the transhuge page fault can convert a null pmd * into an hugepmd or into a regular pmd (if the hugepage allocation -* fails). While holding the mmap_sem in read mode the pmd becomes +* fails). While holding the mmap_lock in read mode the pmd becomes * stable and stops changing under us only if it's not null and not a * transhuge pmd. When those races occurs and this function makes a * difference vs the standard pmd_none_or_clear_bad, the result is
@@ -1115,7 +1115,7 @@ static inline pmd_t pmd_read_atomic(pmd_* * For 32bit kernels with a 64bit large pmd_t this automatically takes * care of reading the pmd atomically to avoid SMP race conditions -* against pmd_populate() when the mmap_sem is hold for reading by the +* against pmd_populate() when the mmap_lock is hold for reading by the * caller (a special atomic read not done by "gcc" as in the generic * version above, is also needed when THP is disabled because the page * fault can populate the pmd from under us).
_
Michel Lespinasse
Reviewed-byRe: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
Looks good, thanks !
Quoted 10 lines · Andrew Morton
Quoted 1 line · On Tue, 19 May 2020 22:29:08 -0700 Michel Lespinasse <[email protected]> wrote:
Convert comments that reference
mmap_semto referencemmap_lockinstead.This may not be complete..
From: Andrew Morton <[email protected]>
Subject: mmap-locking-api-convert-mmap_sem-comments-fixfix up linux-next leftovers
Quoted 15 lines
Cc Daniel Jordan <[email protected]>Cc Davidlohr Bueso <[email protected]>Cc David Rientjes <[email protected]>Cc Hugh Dickins <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Jerome Glisse <[email protected]>Cc John Hubbard <[email protected]>Cc Laurent Dufour <[email protected]>Cc Liam Howlett <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Michel Lespinasse <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Ying Han <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Re: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
In reply to Michel LespinasseQuoted 3 lines · Michel Lespinasse
Convert comments that reference
mmap_semto referencemmap_lockinstead.Signed-off-by Michel Lespinasse <[email protected]>
But:
mm/mempolicy.c static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes) · line 230
Quoted 13 lines
mm/mempolicy.c +1
-1@@ -224,7 +224,7 @@ static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)* handle an empty nodemask with MPOL_PREFERRED here. * * Must be called holding task's alloc_lock to protect task's mems_allowed -* and mempolicy. May also be called holding the mmap_semaphore for write. +* and mempolicy. May also be called holding the mmap_lockaphore for write. */ static int mpol_set_nodemask (struct mempolicy *pol,const nodemask_t *nodes,struct nodemask_scratch *nsc)
:)
Re: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
Quoted 9 lines · Vlastimil Babka
Quoted 3 lines · Michel Lespinasse
Convert comments that reference
mmap_semto referencemmap_lockinstead.Signed-off-by Michel Lespinasse <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>But:
Quoted 15 lines
mm/mempolicy.c static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes) · line 230
Quoted 13 lines
mm/mempolicy.c +1
-1@@ -224,7 +224,7 @@ static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)* handle an empty nodemask with MPOL_PREFERRED here. * * Must be called holding task's alloc_lock to protect task's mems_allowed -* and mempolicy. May also be called holding the mmap_semaphore for write. +* and mempolicy. May also be called holding the mmap_lockaphore for write. */ static int mpol_set_nodemask (struct mempolicy *pol,const nodemask_t *nodes,struct nodemask_scratch *nsc):)
Haha, good catch !
Signature · 2 lines
Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.
Andrew Morton
maintainerRe: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
Quoted 10 lines · On Thu, 21 May 2020 00:50:56 -0700 Michel Lespinasse <[email protected]> wrote:
Quoted 8 lines
Quoted 6 lines
* Must be called holding task's
alloc_lockto protect task'smems_allowed
- * and mempolicy. May also be called holding themmap_semaphorefor write.
+ * and mempolicy. May also be called holding themmap_lockaphorefor write. */
static int mpol_set_nodemask(struct mempolicy *pol,
constnodemask_t*nodes, structnodemask_scratch*nsc):)
Haha, good catch !
aww, you're all so cruel. The world would be a better place if Linux had lockaphores!
Re: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Thu, 21 May 2020 00:50:56 -0700 Michel Lespinasse <[email protected]> wrote:
Quoted 7 lines
Quoted 6 lines
* Must be called holding task's
alloc_lockto protect task'smems_allowed
- * and mempolicy. May also be called holding themmap_semaphorefor write.
+ * and mempolicy. May also be called holding themmap_lockaphorefor write. */
static int mpol_set_nodemask(struct mempolicy *pol,
constnodemask_t*nodes, structnodemask_scratch*nsc)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
:)
Haha, good catch !
aww, you're all so cruel. The world would be a better place if Linux had lockaphores!
Heh, in fact it does have them, but they are called "btrfs extent buffer locks", see (or perhaps rather not) fs/btrfs/locking.c :)
Re: [PATCH v6 12/12] mmap locking API: convert mmap_sem comments
In reply to Michel LespinasseQuoted 3 lines · Michel Lespinasse
Convert comments that reference
mmap_semto referencemmap_lockinstead.Signed-off-by Michel Lespinasse <[email protected]>
Not opposed to leaving lockaphores in :)
Hi,
Quoted 13 lines · Michel Lespinasse
Reposting this patch series on top of v5.7-rc6. I think this is ready for inclusion into the -mm tree; however there were some minor points of feedback to address and also it was easier to regenerate a full version after the v5.5 (only updating patches 09/10 and 10/10) caused some confusion.
This patch series adds a new mmap locking API replacing the existing
mmap_semlock and unlocks. Initially the API is just implemente in terms of inlined rwsem calls, so it doesn't provide any new functionality.There are two justifications for the new API:
Quoted 8 lines
- At first, it provides an easy hooking point to instrument
mmap_semlocking latencies independently of any other rwsems.- In the future, it may be a starting point for replacing the rwsem implementation with a different one, such as range locks. This is something that is being explored, even though there is no wide concensus about this possible direction yet.
(see https://patchwork.kernel.org/cover/11401483/)
Sorry that I am jumping late to the game.
Even though I hoped that the new API would somehow start using a concept of address ranges, because I believe this is a fundamental lock granularity for this mmap_sem, this is definitely a step in the right direction. Getting rid of all direct usage of mmap_sem is an improvement in itself.
Feel free to add
Thanks!
Signature · 2 lines
Michal Hocko SUSE Labs