1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/hugetlb.h> 3 #include <linux/err.h> 4 5 int pud_huge(pud_t pud) 6 { 7 return pud_leaf(pud); 8 } 9 10 int pmd_huge(pmd_t pmd) 11 { 12 return pmd_leaf(pmd); 13 } 14 15 static __init int setup_hugepagesz(char *opt) 16 { 17 unsigned long ps = memparse(opt, &opt); 18 19 if (ps == HPAGE_SIZE) { 20 hugetlb_add_hstate(HPAGE_SHIFT - PAGE_SHIFT); 21 } else if (IS_ENABLED(CONFIG_64BIT) && ps == PUD_SIZE) { 22 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); 23 } else { 24 hugetlb_bad_size(); 25 pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20); 26 return 0; 27 } 28 29 return 1; 30 } 31 __setup("hugepagesz=", setup_hugepagesz); 32 33 #ifdef CONFIG_CONTIG_ALLOC 34 static __init int gigantic_pages_init(void) 35 { 36 /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */ 37 if (IS_ENABLED(CONFIG_64BIT) && !size_to_hstate(1UL << PUD_SHIFT)) 38 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); 39 return 0; 40 } 41 arch_initcall(gigantic_pages_init); 42 #endif 43