include/linux/huge_mm.h
Source file repositories/reference/linux-study-clean/include/linux/huge_mm.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/huge_mm.h- Extension
.h- Size
- 24246 bytes
- Lines
- 850
- 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.
- 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_types.hlinux/fs.hlinux/kobject.h
Detected Declarations
struct kobjectstruct kobj_attributestruct mthp_statstruct thpsizeenum transparent_hugepage_flagenum tva_typeenum mthp_stat_itemenum split_typefunction huge_pud_set_accessedfunction mod_mthp_statfunction count_mthp_statfunction mod_mthp_statfunction hugepage_global_enabledfunction hugepage_global_alwaysfunction highest_orderfunction next_orderfunction thp_vma_suitable_orderfunction thp_shmem_limit_gfp_maskfunction thp_vma_suitable_orderfunction positionfunction vma_thp_disabledfunction thp_disabled_by_hwfunction split_huge_page_to_list_to_orderfunction split_huge_page_to_orderfunction try_folio_split_to_orderfunction split_huge_pagefunction pmd_is_hugefunction change_huge_pudfunction folio_test_pmd_mappablefunction is_huge_zero_foliofunction is_huge_zero_pfnfunction is_huge_zero_pmdfunction thp_migration_supportedfunction folio_test_pmd_mappablefunction thp_vma_suitable_orderfunction thp_shmem_limit_gfp_maskfunction thp_vma_suitable_ordersfunction thp_vma_allowable_ordersfunction thp_get_unmapped_area_vmflagsfunction can_split_foliofunction split_huge_page_to_list_to_orderfunction split_huge_page_to_orderfunction split_huge_pagefunction min_order_for_splitfunction split_folio_to_listfunction try_folio_split_to_orderfunction folio_memcg_alloc_deferredfunction deferred_split_folio
Annotated Snippet
struct mthp_stat {
unsigned long stats[ilog2(MAX_PTRS_PER_PTE) + 1][__MTHP_STAT_COUNT];
};
DECLARE_PER_CPU(struct mthp_stat, mthp_stats);
static inline void mod_mthp_stat(int order, enum mthp_stat_item item, int delta)
{
if (order <= 0 || order > PMD_ORDER)
return;
this_cpu_add(mthp_stats.stats[order][item], delta);
}
static inline void count_mthp_stat(int order, enum mthp_stat_item item)
{
mod_mthp_stat(order, item, 1);
}
#else
static inline void mod_mthp_stat(int order, enum mthp_stat_item item, int delta)
{
}
static inline void count_mthp_stat(int order, enum mthp_stat_item item)
{
}
#endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern unsigned long transparent_hugepage_flags;
extern unsigned long huge_anon_orders_always;
extern unsigned long huge_anon_orders_madvise;
extern unsigned long huge_anon_orders_inherit;
static inline bool hugepage_global_enabled(void)
{
return transparent_hugepage_flags &
((1<<TRANSPARENT_HUGEPAGE_FLAG) |
(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG));
}
static inline bool hugepage_global_always(void)
{
return transparent_hugepage_flags &
(1<<TRANSPARENT_HUGEPAGE_FLAG);
}
static inline int highest_order(unsigned long orders)
{
return fls_long(orders) - 1;
}
static inline int next_order(unsigned long *orders, int prev)
{
*orders &= ~BIT(prev);
return highest_order(*orders);
}
/*
* Do the below checks:
* - For file vma, check if the linear page offset of vma is
* order-aligned within the file. The hugepage is
* guaranteed to be order-aligned within the file, but we must
* check that the order-aligned addresses in the VMA map to
* order-aligned offsets within the file, else the hugepage will
* not be mappable.
* - For all vmas, check if the haddr is in an aligned hugepage
* area.
*/
static inline bool thp_vma_suitable_order(struct vm_area_struct *vma,
unsigned long addr, int order)
{
unsigned long hpage_size = PAGE_SIZE << order;
unsigned long haddr;
/* Don't have to check pgoff for anonymous vma */
if (!vma_is_anonymous(vma)) {
if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
hpage_size >> PAGE_SHIFT))
return false;
}
haddr = ALIGN_DOWN(addr, hpage_size);
if (haddr < vma->vm_start || haddr + hpage_size > vma->vm_end)
return false;
return true;
}
Annotation
- Immediate include surface: `linux/mm_types.h`, `linux/fs.h`, `linux/kobject.h`.
- Detected declarations: `struct kobject`, `struct kobj_attribute`, `struct mthp_stat`, `struct thpsize`, `enum transparent_hugepage_flag`, `enum tva_type`, `enum mthp_stat_item`, `enum split_type`, `function huge_pud_set_accessed`, `function mod_mthp_stat`.
- 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.