include/linux/rmap.h
Source file repositories/reference/linux-study-clean/include/linux/rmap.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/rmap.h- Extension
.h- Size
- 33429 bytes
- Lines
- 996
- 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.
- 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/list.hlinux/slab.hlinux/mm.hlinux/rwsem.hlinux/memcontrol.hlinux/highmem.hlinux/pagemap.hlinux/memremap.hlinux/bit_spinlock.h
Detected Declarations
struct anon_vmastruct anon_vma_chainstruct page_vma_mapped_walkstruct rmap_walk_controlenum ttu_flagsfunction folio_lock_large_mapcountfunction folio_unlock_large_mapcountfunction folio_mm_idfunction folio_set_mm_idfunction __folio_large_mapcount_sanity_checksfunction folio_set_large_mapcountfunction folio_add_return_large_mapcountfunction folio_sub_return_large_mapcountfunction mapcountfunction __folio_rmap_sanity_checksfunction folio_add_large_mapcountfunction folio_add_return_large_mapcountfunction folio_sub_large_mapcountfunction folio_sub_return_large_mapcountfunction __folio_rmap_sanity_checksfunction atomic_readfunction hugetlb_try_dup_anon_rmapfunction hugetlb_try_share_anon_rmapfunction hugetlb_add_file_rmapfunction hugetlb_remove_rmapfunction __folio_dup_file_rmapfunction folio_dup_file_rmap_ptesfunction folio_dup_file_rmap_ptefunction folio_dup_file_rmap_pmdfunction __folio_try_dup_anon_rmapfunction folio_try_dup_anon_rmap_ptesfunction folio_try_dup_anon_rmap_ptefunction folio_try_dup_anon_rmap_pmdfunction __folio_try_share_anon_rmapfunction folio_try_share_anon_rmap_ptefunction folio_try_share_anon_rmap_pmdfunction page_vma_mapped_walk_donefunction page_vma_mapped_walk_restartfunction folio_referencedfunction try_to_unmap
Annotated Snippet
struct anon_vma {
struct anon_vma *root; /* Root of this anon_vma tree */
struct rw_semaphore rwsem; /* W: modification, R: walking the list */
/*
* The refcount is taken on an anon_vma when there is no
* guarantee that the vma of page tables will exist for
* the duration of the operation. A caller that takes
* the reference is responsible for clearing up the
* anon_vma if they are the last user on release
*/
atomic_t refcount;
/*
* Count of child anon_vmas. Equals to the count of all anon_vmas that
* have ->parent pointing to this one, including itself.
*
* This counter is used for making decision about reusing anon_vma
* instead of forking new one. See comments in function anon_vma_clone.
*/
unsigned long num_children;
/* Count of VMAs whose ->anon_vma pointer points to this object. */
unsigned long num_active_vmas;
struct anon_vma *parent; /* Parent of this anon_vma */
/*
* NOTE: the LSB of the rb_root.rb_node is set by
* mm_take_all_locks() _after_ taking the above lock. So the
* rb_root must only be read/written after taking the above lock
* to be sure to see a valid next pointer. The LSB bit itself
* is serialized by a system wide lock only visible to
* mm_take_all_locks() (mm_all_locks_mutex).
*/
/* Interval tree of private "related" vmas */
struct rb_root_cached rb_root;
};
/*
* The copy-on-write semantics of fork mean that an anon_vma
* can become associated with multiple processes. Furthermore,
* each child process will have its own anon_vma, where new
* pages for that process are instantiated.
*
* This structure allows us to find the anon_vmas associated
* with a VMA, or the VMAs associated with an anon_vma.
* The "same_vma" list contains the anon_vma_chains linking
* all the anon_vmas associated with this VMA.
* The "rb" field indexes on an interval tree the anon_vma_chains
* which link all the VMAs associated with this anon_vma.
*/
struct anon_vma_chain {
struct vm_area_struct *vma;
struct anon_vma *anon_vma;
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
unsigned long cached_vma_start, cached_vma_last;
#endif
};
enum ttu_flags {
TTU_USE_SHARED_ZEROPAGE = 0x2, /* for unused pages of large folios */
TTU_SPLIT_HUGE_PMD = 0x4, /* split huge PMD if any */
TTU_IGNORE_MLOCK = 0x8, /* ignore mlock */
TTU_SYNC = 0x10, /* avoid racy checks with PVMW_SYNC */
TTU_HWPOISON = 0x20, /* do convert pte to hwpoison entry */
TTU_BATCH_FLUSH = 0x40, /* Batch TLB flushes where possible
* and caller guarantees they will
* do a final flush if necessary */
TTU_RMAP_LOCKED = 0x80, /* do not grab rmap lock:
* caller holds it */
};
#ifdef CONFIG_MMU
void anon_vma_init(void); /* create anon_vma_cachep */
#ifdef CONFIG_MM_ID
static __always_inline void folio_lock_large_mapcount(struct folio *folio)
{
bit_spin_lock(FOLIO_MM_IDS_LOCK_BITNUM, &folio->_mm_ids);
}
static __always_inline void folio_unlock_large_mapcount(struct folio *folio)
{
__bit_spin_unlock(FOLIO_MM_IDS_LOCK_BITNUM, &folio->_mm_ids);
}
Annotation
- Immediate include surface: `linux/list.h`, `linux/slab.h`, `linux/mm.h`, `linux/rwsem.h`, `linux/memcontrol.h`, `linux/highmem.h`, `linux/pagemap.h`, `linux/memremap.h`.
- Detected declarations: `struct anon_vma`, `struct anon_vma_chain`, `struct page_vma_mapped_walk`, `struct rmap_walk_control`, `enum ttu_flags`, `function folio_lock_large_mapcount`, `function folio_unlock_large_mapcount`, `function folio_mm_id`, `function folio_set_mm_id`, `function __folio_large_mapcount_sanity_checks`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source 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.