1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/hugetlb.h>
5 int pud_huge(pud_t pud
)
7 return pud_present(pud
) &&
8 (pud_val(pud
) & (_PAGE_READ
| _PAGE_WRITE
| _PAGE_EXEC
));
11 int pmd_huge(pmd_t pmd
)
13 return pmd_present(pmd
) &&
14 (pmd_val(pmd
) & (_PAGE_READ
| _PAGE_WRITE
| _PAGE_EXEC
));
17 static __init
int setup_hugepagesz(char *opt
)
19 unsigned long ps
= memparse(opt
, &opt
);
21 if (ps
== HPAGE_SIZE
) {
22 hugetlb_add_hstate(HPAGE_SHIFT
- PAGE_SHIFT
);
23 } else if (IS_ENABLED(CONFIG_64BIT
) && ps
== PUD_SIZE
) {
24 hugetlb_add_hstate(PUD_SHIFT
- PAGE_SHIFT
);
27 pr_err("hugepagesz: Unsupported page size %lu M\n", ps
>> 20);
33 __setup("hugepagesz=", setup_hugepagesz
);
35 #ifdef CONFIG_CONTIG_ALLOC
36 static __init
int gigantic_pages_init(void)
38 /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */
39 if (IS_ENABLED(CONFIG_64BIT
) && !size_to_hstate(1UL << PUD_SHIFT
))
40 hugetlb_add_hstate(PUD_SHIFT
- PAGE_SHIFT
);
43 arch_initcall(gigantic_pages_init
);