hugetlbpage.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
  33. int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
  34. {
  35. return 0;
  36. }
  37. #endif
  38. struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
  39. int write)
  40. {
  41. return ERR_PTR(-EINVAL);
  42. }
  43. int pmd_huge(pmd_t pmd)
  44. {
  45. return !(pmd_val(pmd) & PMD_TABLE_BIT);
  46. }
  47. int pud_huge(pud_t pud)
  48. {
  49. return !(pud_val(pud) & PUD_TABLE_BIT);
  50. }
  51. int pmd_huge_support(void)
  52. {
  53. return 1;
  54. }
  55. static __init int setup_hugepagesz(char *opt)
  56. {
  57. unsigned long ps = memparse(opt, &opt);
  58. if (ps == PMD_SIZE) {
  59. hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
  60. } else if (ps == PUD_SIZE) {
  61. hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
  62. } else {
  63. pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20);
  64. return 0;
  65. }
  66. return 1;
  67. }
  68. __setup("hugepagesz=", setup_hugepagesz);