mm/mremap.c
Source file repositories/reference/linux-study-clean/mm/mremap.c
File Facts
- System
- Linux kernel
- Corpus path
mm/mremap.c- Extension
.c- Size
- 57359 bytes
- Lines
- 2057
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: syscall or user/kernel boundary
- Status
- core 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 participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mm.hlinux/mm_inline.hlinux/hugetlb.hlinux/shm.hlinux/ksm.hlinux/mman.hlinux/swap.hlinux/capability.hlinux/fs.hlinux/leafops.hlinux/highmem.hlinux/security.hlinux/syscalls.hlinux/mmu_notifier.hlinux/uaccess.hlinux/userfaultfd_k.hlinux/mempolicy.hlinux/pgalloc.hasm/cacheflush.hasm/tlb.hinternal.h
Detected Declarations
syscall mremapstruct vma_remap_structenum mremap_typeenum pgt_entryfunction take_rmap_locksfunction drop_rmap_locksfunction move_soft_dirty_ptefunction mremap_folio_pte_batchfunction move_ptesfunction folio_mkcleanfunction arch_supports_page_table_movefunction uffd_supports_page_table_movefunction move_normal_pmdfunction move_normal_pmdfunction move_normal_pudfunction move_normal_pudfunction move_huge_pudfunction move_huge_pudfunction get_extentfunction move_pgt_entryfunction move_pgt_entryfunction can_align_downfunction can_realign_addrfunction mremapfunction pmc_donefunction pmc_nextfunction pmc_progressfunction move_page_tablesfunction vrm_set_deltafunction vrm_remap_typefunction vrm_overlapsfunction vrm_implies_new_addrfunction mmapfunction vrm_calc_chargefunction vrm_unchargefunction vrm_stat_accountfunction __check_map_count_against_splitfunction check_map_count_against_splitfunction check_map_count_against_split_earlyfunction prep_move_vmafunction unmap_source_vmafunction copy_vmafunction mremapfunction copy_vma_and_datafunction conventionfunction move_vmafunction shrunkfunction mremap_to
Annotated Snippet
SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
unsigned long, new_len, unsigned long, flags,
unsigned long, new_addr)
{
struct vm_userfaultfd_ctx uf = NULL_VM_UFFD_CTX;
LIST_HEAD(uf_unmap_early);
LIST_HEAD(uf_unmap);
/*
* There is a deliberate asymmetry here: we strip the pointer tag
* from the old address but leave the new address alone. This is
* for consistency with mmap(), where we prevent the creation of
* aliasing mappings in userspace by leaving the tag bits of the
* mapping address intact. A non-zero tag will cause the subsequent
* range checks to reject the address as invalid.
*
* See Documentation/arch/arm64/tagged-address-abi.rst for more
* information.
*/
struct vma_remap_struct vrm = {
.addr = untagged_addr(addr),
.old_len = old_len,
.new_len = new_len,
.flags = flags,
.new_addr = new_addr,
.uf = &uf,
.uf_unmap_early = &uf_unmap_early,
.uf_unmap = &uf_unmap,
.remap_type = MREMAP_INVALID, /* We set later. */
};
return do_mremap(&vrm);
}
Annotation
- Immediate include surface: `linux/mm.h`, `linux/mm_inline.h`, `linux/hugetlb.h`, `linux/shm.h`, `linux/ksm.h`, `linux/mman.h`, `linux/swap.h`, `linux/capability.h`.
- Detected declarations: `syscall mremap`, `struct vma_remap_struct`, `enum mremap_type`, `enum pgt_entry`, `function take_rmap_locks`, `function drop_rmap_locks`, `function move_soft_dirty_pte`, `function mremap_folio_pte_batch`, `function move_ptes`, `function folio_mkclean`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: core implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.