include/linux/mmap_lock.h
Source file repositories/reference/linux-study-clean/include/linux/mmap_lock.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/mmap_lock.h- Extension
.h- Size
- 19338 bytes
- Lines
- 637
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/lockdep.hlinux/mm_types.hlinux/mmdebug.hlinux/rwsem.hlinux/tracepoint-defs.hlinux/types.hlinux/cleanup.hlinux/sched/mm.h
Detected Declarations
function __mmap_lock_trace_start_lockingfunction __mmap_lock_trace_acquire_returnedfunction __mmap_lock_trace_releasedfunction __mmap_lock_trace_start_lockingfunction mmap_assert_write_lockedfunction mm_lock_seqcount_initfunction mm_lock_seqcount_beginfunction mm_lock_seqcount_endfunction mmap_lock_speculate_try_beginfunction mmap_lock_speculate_retryfunction vma_lock_initfunction __vma_are_readers_excludedfunction __vma_refcount_put_returnfunction vma_refcount_putfunction failfunction failfunction vma_end_readfunction __vma_raw_mm_seqnumfunction __is_vma_write_lockedfunction vma_start_writefunction vma_start_write_killablefunction vma_assert_write_lockedfunction vma_assert_lockedfunction vma_assert_stabilisedfunction vma_is_attachedfunction vma_assert_attachedfunction vma_assert_detachedfunction vma_mark_attachedfunction vma_mark_detachedfunction mm_lock_seqcount_initfunction mmap_lock_speculate_retryfunction vma_lock_initfunction vma_assert_write_lockedfunction vma_assert_attachedfunction vma_assert_lockedfunction vma_assert_stabilisedfunction mmap_write_lockfunction mmap_write_lock_nestedfunction mmap_write_lock_killablefunction vma_end_write_allfunction mmap_write_unlockfunction mmap_write_downgradefunction mmap_read_lockfunction mmap_read_lock_killablefunction mmap_read_trylockfunction mmap_read_unlockfunction mmap_read_lockfunction mmap_lock_is_contended
Annotated Snippet
static inline void mm_lock_seqcount_init(struct mm_struct *mm) {}
static inline void mm_lock_seqcount_begin(struct mm_struct *mm) {}
static inline void mm_lock_seqcount_end(struct mm_struct *mm) {}
static inline bool mmap_lock_speculate_try_begin(struct mm_struct *mm, unsigned int *seq)
{
return false;
}
static inline bool mmap_lock_speculate_retry(struct mm_struct *mm, unsigned int seq)
{
return true;
}
static inline void vma_lock_init(struct vm_area_struct *vma, bool reset_refcnt) {}
static inline void vma_end_read(struct vm_area_struct *vma) {}
static inline void vma_start_write(struct vm_area_struct *vma) {}
static inline __must_check
int vma_start_write_killable(struct vm_area_struct *vma) { return 0; }
static inline void vma_assert_write_locked(struct vm_area_struct *vma)
{ mmap_assert_write_locked(vma->vm_mm); }
static inline void vma_assert_attached(struct vm_area_struct *vma) {}
static inline void vma_assert_detached(struct vm_area_struct *vma) {}
static inline void vma_mark_attached(struct vm_area_struct *vma) {}
static inline void vma_mark_detached(struct vm_area_struct *vma) {}
static inline struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm,
unsigned long address)
{
return NULL;
}
static inline void vma_assert_locked(struct vm_area_struct *vma)
{
mmap_assert_locked(vma->vm_mm);
}
static inline void vma_assert_stabilised(struct vm_area_struct *vma)
{
/* If no VMA locks, then either mmap lock suffices to stabilise. */
mmap_assert_locked(vma->vm_mm);
}
#endif /* CONFIG_PER_VMA_LOCK */
static inline void mmap_write_lock(struct mm_struct *mm)
{
__mmap_lock_trace_start_locking(mm, true);
down_write(&mm->mmap_lock);
mm_lock_seqcount_begin(mm);
__mmap_lock_trace_acquire_returned(mm, true, true);
}
static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass)
{
__mmap_lock_trace_start_locking(mm, true);
down_write_nested(&mm->mmap_lock, subclass);
mm_lock_seqcount_begin(mm);
__mmap_lock_trace_acquire_returned(mm, true, true);
}
static inline int __must_check mmap_write_lock_killable(struct mm_struct *mm)
{
int ret;
__mmap_lock_trace_start_locking(mm, true);
ret = down_write_killable(&mm->mmap_lock);
if (!ret)
mm_lock_seqcount_begin(mm);
__mmap_lock_trace_acquire_returned(mm, true, ret == 0);
return ret;
}
/*
* Drop all currently-held per-VMA locks.
* This is called from the mmap_lock implementation directly before releasing
* a write-locked mmap_lock (or downgrading it to read-locked).
* This should normally NOT be called manually from other places.
* If you want to call this manually anyway, keep in mind that this will release
* *all* VMA write locks, including ones from further up the stack.
*/
static inline void vma_end_write_all(struct mm_struct *mm)
{
mmap_assert_write_locked(mm);
mm_lock_seqcount_end(mm);
}
static inline void mmap_write_unlock(struct mm_struct *mm)
{
__mmap_lock_trace_released(mm, true);
vma_end_write_all(mm);
Annotation
- Immediate include surface: `linux/lockdep.h`, `linux/mm_types.h`, `linux/mmdebug.h`, `linux/rwsem.h`, `linux/tracepoint-defs.h`, `linux/types.h`, `linux/cleanup.h`, `linux/sched/mm.h`.
- Detected declarations: `function __mmap_lock_trace_start_locking`, `function __mmap_lock_trace_acquire_returned`, `function __mmap_lock_trace_released`, `function __mmap_lock_trace_start_locking`, `function mmap_assert_write_locked`, `function mm_lock_seqcount_init`, `function mm_lock_seqcount_begin`, `function mm_lock_seqcount_end`, `function mmap_lock_speculate_try_begin`, `function mmap_lock_speculate_retry`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.