include/linux/hugetlb.h
Source file repositories/reference/linux-study-clean/include/linux/hugetlb.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/hugetlb.h- Extension
.h- Size
- 37794 bytes
- Lines
- 1371
- 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/mm.hlinux/mm_types.hlinux/mmdebug.hlinux/fs.hlinux/hugetlb_inline.hlinux/cgroup.hlinux/page_ref.hlinux/list.hlinux/kref.hlinux/pgtable.hlinux/gfp.hlinux/userfaultfd_k.hlinux/nodemask.hlinux/pagemap.hlinux/shm.hasm/tlbflush.hasm/hugetlb.h
Detected Declarations
struct mmu_gatherstruct nodestruct hugepage_subpoolstruct resv_mapstruct file_regionstruct hugetlb_vma_lockstruct hugetlbfs_sb_infostruct hugetlbfs_inode_infostruct hstatestruct cmastruct huge_bootmem_pagestruct hstateenum hugetlb_page_flagsfunction pte_offset_hugefunction hugetlb_zap_beginfunction hugetlb_zap_endfunction hugetlb_dup_vma_privatefunction huge_pmd_unsharefunction huge_pmd_unshare_flushfunction move_hugetlb_page_tablesfunction hugetlb_report_meminfofunction hugetlb_show_meminfo_nodefunction hugetlb_vma_assert_lockedfunction hugetlb_mfill_atomic_ptefunction folio_isolate_hugetlbfunction get_hwpoison_hugetlb_foliofunction folio_putback_hugetlbfunction __unmap_hugepage_rangefunction hugetlb_faultfunction hugetlb_unshare_all_pmdsfunction is_file_hugepagesfunction hugetlb_file_setupfunction hugetlb_set_folio_subpoolfunction huge_page_sizefunction huge_page_maskfunction huge_page_orderfunction huge_page_shiftfunction hugetlb_linear_page_indexfunction order_is_giganticfunction hstate_is_giganticfunction pages_per_huge_pagefunction blocks_per_huge_pagefunction is_hugepage_only_rangefunction arch_clear_hugetlb_flagsfunction arch_has_huge_bootmem_allocfunction hstate_index_to_shiftfunction hstate_indexfunction folio_clear_hugetlb_hwpoison
Annotated Snippet
struct hugepage_subpool {
spinlock_t lock;
long count;
long max_hpages; /* Maximum huge pages or -1 if no maximum. */
long used_hpages; /* Used count against maximum, includes */
/* both allocated and reserved pages. */
struct hstate *hstate;
long min_hpages; /* Minimum huge pages or -1 if no minimum. */
long rsv_hpages; /* Pages reserved against global pool to */
/* satisfy minimum size. */
};
struct resv_map {
struct kref refs;
spinlock_t lock;
struct list_head regions;
long adds_in_progress;
struct list_head region_cache;
long region_cache_count;
struct rw_semaphore rw_sema;
#ifdef CONFIG_CGROUP_HUGETLB
/*
* On private mappings, the counter to uncharge reservations is stored
* here. If these fields are 0, then either the mapping is shared, or
* cgroup accounting is disabled for this resv_map.
*/
struct page_counter *reservation_counter;
unsigned long pages_per_hpage;
struct cgroup_subsys_state *css;
#endif
};
/*
* Region tracking -- allows tracking of reservations and instantiated pages
* across the pages in a mapping.
*
* The region data structures are embedded into a resv_map and protected
* by a resv_map's lock. The set of regions within the resv_map represent
* reservations for huge pages, or huge pages that have already been
* instantiated within the map. The from and to elements are huge page
* indices into the associated mapping. from indicates the starting index
* of the region. to represents the first index past the end of the region.
*
* For example, a file region structure with from == 0 and to == 4 represents
* four huge pages in a mapping. It is important to note that the to element
* represents the first element past the end of the region. This is used in
* arithmetic as 4(to) - 0(from) = 4 huge pages in the region.
*
* Interval notation of the form [from, to) will be used to indicate that
* the endpoint from is inclusive and to is exclusive.
*/
struct file_region {
struct list_head link;
long from;
long to;
#ifdef CONFIG_CGROUP_HUGETLB
/*
* On shared mappings, each reserved region appears as a struct
* file_region in resv_map. These fields hold the info needed to
* uncharge each reservation.
*/
struct page_counter *reservation_counter;
struct cgroup_subsys_state *css;
#endif
};
struct hugetlb_vma_lock {
struct kref refs;
struct rw_semaphore rw_sema;
struct vm_area_struct *vma;
};
extern struct resv_map *resv_map_alloc(void);
void resv_map_release(struct kref *ref);
extern spinlock_t hugetlb_lock;
extern int hugetlb_max_hstate __read_mostly;
#define for_each_hstate(h) \
for ((h) = hstates; (h) < &hstates[hugetlb_max_hstate]; (h)++)
struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages,
long min_hpages);
void hugepage_put_subpool(struct hugepage_subpool *spool);
void hugetlb_dup_vma_private(struct vm_area_struct *vma);
void clear_vma_resv_huge_pages(struct vm_area_struct *vma);
int move_hugetlb_page_tables(struct vm_area_struct *vma,
struct vm_area_struct *new_vma,
unsigned long old_addr, unsigned long new_addr,
unsigned long len);
Annotation
- Immediate include surface: `linux/mm.h`, `linux/mm_types.h`, `linux/mmdebug.h`, `linux/fs.h`, `linux/hugetlb_inline.h`, `linux/cgroup.h`, `linux/page_ref.h`, `linux/list.h`.
- Detected declarations: `struct mmu_gather`, `struct node`, `struct hugepage_subpool`, `struct resv_map`, `struct file_region`, `struct hugetlb_vma_lock`, `struct hugetlbfs_sb_info`, `struct hugetlbfs_inode_info`, `struct hstate`, `struct cma`.
- 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.