mm/internal.h
Source file repositories/reference/linux-study-clean/mm/internal.h
File Facts
- System
- Linux kernel
- Corpus path
mm/internal.h- Extension
.h- Size
- 60672 bytes
- Lines
- 1955
- Domain
- Core OS
- Bucket
- Memory Management
- 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/fs.hlinux/khugepaged.hlinux/mm.hlinux/mm_inline.hlinux/mmu_notifier.hlinux/pagemap.hlinux/pagewalk.hlinux/rmap.hlinux/swap.hlinux/leafops.hlinux/tracepoint-defs.hvma.h
Detected Declarations
struct folio_batchstruct pagetable_move_controlstruct zap_detailsstruct alloc_contextstruct compact_controlstruct capture_controlstruct cmastruct tlbflush_unmap_batchstruct migration_target_controlenum vma_operationenum fallback_resultenum mminit_levelenum ttu_flagsfunction __show_memfunction folio_swapfunction mmap_filefunction vma_closefunction get_anon_vmafunction put_anon_vmafunction anon_vma_lock_writefunction anon_vma_trylock_writefunction anon_vma_unlock_writefunction anon_vma_lock_readfunction anon_vma_trylock_readfunction anon_vma_unlock_readfunction anon_vma_preparefunction __pte_batch_clear_ignoredfunction folio_pte_batchfunction pte_move_swp_offsetfunction pte_next_swp_offsetfunction swap_pte_batchfunction acct_reclaim_writebackfunction wake_throttle_isolatedfunction vmf_anon_preparefunction pmd_nonefunction force_page_cache_readaheadfunction folio_evictablefunction set_page_refcountedfunction set_pages_refcountedfunction folio_needs_releasefunction page_zonefunction buddy_orderfunction pairfunction page_to_pfnfunction clear_zone_contiguousfunction folio_set_orderfunction folio_unqueue_deferred_splitfunction prep_compound_head
Annotated Snippet
struct pagetable_move_control {
struct vm_area_struct *old; /* Source VMA. */
struct vm_area_struct *new; /* Destination VMA. */
unsigned long old_addr; /* Address from which the move begins. */
unsigned long old_end; /* Exclusive address at which old range ends. */
unsigned long new_addr; /* Address to move page tables to. */
unsigned long len_in; /* Bytes to remap specified by user. */
bool need_rmap_locks; /* Do rmap locks need to be taken? */
bool for_stack; /* Is this an early temp stack being moved? */
};
#define PAGETABLE_MOVE(name, old_, new_, old_addr_, new_addr_, len_) \
struct pagetable_move_control name = { \
.old = old_, \
.new = new_, \
.old_addr = old_addr_, \
.old_end = (old_addr_) + (len_), \
.new_addr = new_addr_, \
.len_in = len_, \
}
/*
* The set of flags that only affect watermark checking and reclaim
* behaviour. This is used by the MM to obey the caller constraints
* about IO, FS and watermark checking while ignoring placement
* hints such as HIGHMEM usage.
*/
#define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\
__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NOFAIL|\
__GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\
__GFP_NOLOCKDEP)
/* The GFP flags allowed during early boot */
#define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_FS))
/* Control allocation cpuset and node placement constraints */
#define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)
/* Do not use these with a slab allocator */
#define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
/*
* Different from WARN_ON_ONCE(), no warning will be issued
* when we specify __GFP_NOWARN.
*/
#define WARN_ON_ONCE_GFP(cond, gfp) ({ \
static bool __section(".data..once") __warned; \
int __ret_warn_once = !!(cond); \
\
if (unlikely(!(gfp & __GFP_NOWARN) && __ret_warn_once && !__warned)) { \
__warned = true; \
WARN_ON(1); \
} \
unlikely(__ret_warn_once); \
})
void page_writeback_init(void);
/*
* If a 16GB hugetlb folio were mapped by PTEs of all of its 4kB pages,
* its nr_pages_mapped would be 0x400000: choose the ENTIRELY_MAPPED bit
* above that range, instead of 2*(PMD_SIZE/PAGE_SIZE). Hugetlb currently
* leaves nr_pages_mapped at 0, but avoid surprise if it participates later.
*/
#define ENTIRELY_MAPPED 0x800000
#define FOLIO_PAGES_MAPPED (ENTIRELY_MAPPED - 1)
/*
* Flags passed to __show_mem() and show_free_areas() to suppress output in
* various contexts.
*/
#define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */
/*
* How many individual pages have an elevated _mapcount. Excludes
* the folio's entire_mapcount.
*
* Don't use this function outside of debugging code.
*/
static inline int folio_nr_pages_mapped(const struct folio *folio)
{
if (IS_ENABLED(CONFIG_NO_PAGE_MAPCOUNT))
return -1;
return atomic_read(&folio->_nr_pages_mapped) & FOLIO_PAGES_MAPPED;
}
/*
* Retrieve the first entry of a folio based on a provided entry within the
* folio. We cannot rely on folio->swap as there is no guarantee that it has
Annotation
- Immediate include surface: `linux/fs.h`, `linux/khugepaged.h`, `linux/mm.h`, `linux/mm_inline.h`, `linux/mmu_notifier.h`, `linux/pagemap.h`, `linux/pagewalk.h`, `linux/rmap.h`.
- Detected declarations: `struct folio_batch`, `struct pagetable_move_control`, `struct zap_details`, `struct alloc_context`, `struct compact_control`, `struct capture_control`, `struct cma`, `struct tlbflush_unmap_batch`, `struct migration_target_control`, `enum vma_operation`.
- Atlas domain: Core OS / Memory Management.
- 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.