hugetlbpage.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * arch/arm64/mm/hugetlbpage.c
  3. *
  4. * Copyright (C) 2013 Linaro Ltd.
  5. *
  6. * Based on arch/x86/mm/hugetlbpage.c.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/init.h>
  22. #include <linux/fs.h>
  23. #include <linux/mm.h>
  24. #include <linux/hugetlb.h>
  25. #include <linux/pagemap.h>
  26. #include <linux/err.h>
  27. #include <linux/sysctl.h>
  28. #include <asm/mman.h>
  29. #include <asm/tlb.h>
  30. #include <asm/tlbflush.h>
  31. #include <asm/pgalloc.h>
  32. int pmd_huge(pmd_t pmd)
  33. {
  34. return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT);
  35. }
  36. int pud_huge(pud_t pud)
  37. {
  38. #ifndef __PAGETABLE_PMD_FOLDED
  39. return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT);
  40. #else
  41. return 0;
  42. #endif
  43. }
  44. static __init int setup_hugepagesz(char *opt)
  45. {
  46. unsigned long ps = memparse(opt, &opt);
  47. if (ps == PMD_SIZE) {
  48. hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
  49. } else if (ps == PUD_SIZE) {
  50. hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
  51. } else {
  52. pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20);
  53. return 0;
  54. }
  55. return 1;
  56. }
  57. __setup("hugepagesz=", setup_hugepagesz);