hugetlbpage.c 659 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/hugetlb.h>
  3. #include <linux/err.h>
  4. int pud_huge(pud_t pud)
  5. {
  6. return pud_leaf(pud);
  7. }
  8. int pmd_huge(pmd_t pmd)
  9. {
  10. return pmd_leaf(pmd);
  11. }
  12. bool __init arch_hugetlb_valid_size(unsigned long size)
  13. {
  14. if (size == HPAGE_SIZE)
  15. return true;
  16. else if (IS_ENABLED(CONFIG_64BIT) && size == PUD_SIZE)
  17. return true;
  18. else
  19. return false;
  20. }
  21. #ifdef CONFIG_CONTIG_ALLOC
  22. static __init int gigantic_pages_init(void)
  23. {
  24. /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */
  25. if (IS_ENABLED(CONFIG_64BIT))
  26. hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
  27. return 0;
  28. }
  29. arch_initcall(gigantic_pages_init);
  30. #endif