arch/powerpc/mm/hugetlbpage.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/hugetlbpage.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/hugetlbpage.c- Extension
.c- Size
- 4785 bytes
- Lines
- 215
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mm.hlinux/io.hlinux/slab.hlinux/hugetlb.hlinux/export.hlinux/of_fdt.hlinux/memblock.hlinux/moduleparam.hlinux/swap.hlinux/swapops.hlinux/kmemleak.hasm/pgalloc.hasm/tlb.hasm/setup.hasm/hugetlb.hasm/pte-walk.hasm/firmware.h
Detected Declarations
function __builtin_ffsfunction pseries_add_gpagefunction pseries_alloc_bootmem_huge_pagefunction hugetlb_node_alloc_supportedfunction alloc_bootmem_huge_pagefunction arch_hugetlb_valid_sizefunction add_huge_page_sizefunction hugetlbpage_initfunction arch_hugetlb_cma_order
Annotated Snippet
if (IS_ENABLED(CONFIG_PPC_8xx)) {
int i;
for (i = 0; i < sz / PMD_SIZE; i++) {
if (!pte_alloc_huge(mm, pmd + i, addr))
return NULL;
}
}
return (pte_t *)pmd;
}
return pte_alloc_huge(mm, pmd, addr);
}
#ifdef CONFIG_PPC_BOOK3S_64
/*
* Tracks gpages after the device tree is scanned and before the
* huge_boot_pages list is ready on pseries.
*/
#define MAX_NUMBER_GPAGES 1024
__initdata static u64 gpage_freearray[MAX_NUMBER_GPAGES];
__initdata static unsigned nr_gpages;
/*
* Build list of addresses of gigantic pages. This function is used in early
* boot before the buddy allocator is setup.
*/
void __init pseries_add_gpage(u64 addr, u64 page_size, unsigned long number_of_pages)
{
if (!addr)
return;
while (number_of_pages > 0) {
gpage_freearray[nr_gpages] = addr;
nr_gpages++;
number_of_pages--;
addr += page_size;
}
}
static int __init pseries_alloc_bootmem_huge_page(struct hstate *hstate)
{
struct huge_bootmem_page *m;
if (nr_gpages == 0)
return 0;
m = phys_to_virt(gpage_freearray[--nr_gpages]);
gpage_freearray[nr_gpages] = 0;
list_add(&m->list, &huge_boot_pages[0]);
m->hstate = hstate;
m->flags = 0;
return 1;
}
bool __init hugetlb_node_alloc_supported(void)
{
return false;
}
#endif
int __init alloc_bootmem_huge_page(struct hstate *h, int nid)
{
#ifdef CONFIG_PPC_BOOK3S_64
if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled())
return pseries_alloc_bootmem_huge_page(h);
#endif
return __alloc_bootmem_huge_page(h, nid);
}
bool __init arch_hugetlb_valid_size(unsigned long size)
{
int shift = __ffs(size);
int mmu_psize;
/* Check that it is a page size supported by the hardware and
* that it fits within pagetable and slice limits. */
if (size <= PAGE_SIZE || !is_power_of_2(size))
return false;
mmu_psize = check_and_get_huge_psize(shift);
if (mmu_psize < 0)
return false;
BUG_ON(mmu_psize_defs[mmu_psize].shift != shift);
return true;
}
static int __init add_huge_page_size(unsigned long long size)
{
Annotation
- Immediate include surface: `linux/mm.h`, `linux/io.h`, `linux/slab.h`, `linux/hugetlb.h`, `linux/export.h`, `linux/of_fdt.h`, `linux/memblock.h`, `linux/moduleparam.h`.
- Detected declarations: `function __builtin_ffs`, `function pseries_add_gpage`, `function pseries_alloc_bootmem_huge_page`, `function hugetlb_node_alloc_supported`, `function alloc_bootmem_huge_page`, `function arch_hugetlb_valid_size`, `function add_huge_page_size`, `function hugetlbpage_init`, `function arch_hugetlb_cma_order`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.