hugetlb.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #ifndef _LINUX_HUGETLB_H
  2. #define _LINUX_HUGETLB_H
  3. #ifdef CONFIG_HUGETLB_PAGE
  4. #include <linux/mempolicy.h>
  5. struct ctl_table;
  6. static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
  7. {
  8. return vma->vm_flags & VM_HUGETLB;
  9. }
  10. int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
  11. int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
  12. int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int);
  13. void zap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
  14. void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
  15. int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
  16. int hugetlb_report_meminfo(char *);
  17. int hugetlb_report_node_meminfo(int, char *);
  18. int is_hugepage_mem_enough(size_t);
  19. unsigned long hugetlb_total_pages(void);
  20. struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
  21. int write);
  22. struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
  23. pmd_t *pmd, int write);
  24. int is_aligned_hugepage_range(unsigned long addr, unsigned long len);
  25. int pmd_huge(pmd_t pmd);
  26. struct page *alloc_huge_page(void);
  27. void free_huge_page(struct page *);
  28. extern unsigned long max_huge_pages;
  29. extern const unsigned long hugetlb_zero, hugetlb_infinity;
  30. extern int sysctl_hugetlb_shm_group;
  31. #ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
  32. #define is_hugepage_only_range(mm, addr, len) 0
  33. #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \
  34. do { } while (0)
  35. #endif
  36. #ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
  37. #define prepare_hugepage_range(addr, len) \
  38. is_aligned_hugepage_range(addr, len)
  39. #else
  40. int prepare_hugepage_range(unsigned long addr, unsigned long len);
  41. #endif
  42. #else /* !CONFIG_HUGETLB_PAGE */
  43. static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
  44. {
  45. return 0;
  46. }
  47. static inline unsigned long hugetlb_total_pages(void)
  48. {
  49. return 0;
  50. }
  51. #define follow_hugetlb_page(m,v,p,vs,a,b,i) ({ BUG(); 0; })
  52. #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
  53. #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
  54. #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; })
  55. #define zap_hugepage_range(vma, start, len) BUG()
  56. #define unmap_hugepage_range(vma, start, end) BUG()
  57. #define is_hugepage_mem_enough(size) 0
  58. #define hugetlb_report_meminfo(buf) 0
  59. #define hugetlb_report_node_meminfo(n, buf) 0
  60. #define follow_huge_pmd(mm, addr, pmd, write) NULL
  61. #define is_aligned_hugepage_range(addr, len) 0
  62. #define prepare_hugepage_range(addr, len) (-EINVAL)
  63. #define pmd_huge(x) 0
  64. #define is_hugepage_only_range(mm, addr, len) 0
  65. #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \
  66. do { } while (0)
  67. #define alloc_huge_page() ({ NULL; })
  68. #define free_huge_page(p) ({ (void)(p); BUG(); })
  69. #ifndef HPAGE_MASK
  70. #define HPAGE_MASK 0 /* Keep the compiler happy */
  71. #define HPAGE_SIZE 0
  72. #endif
  73. #endif /* !CONFIG_HUGETLB_PAGE */
  74. #ifdef CONFIG_HUGETLBFS
  75. struct hugetlbfs_config {
  76. uid_t uid;
  77. gid_t gid;
  78. umode_t mode;
  79. long nr_blocks;
  80. long nr_inodes;
  81. };
  82. struct hugetlbfs_sb_info {
  83. long max_blocks; /* blocks allowed */
  84. long free_blocks; /* blocks free */
  85. long max_inodes; /* inodes allowed */
  86. long free_inodes; /* inodes free */
  87. spinlock_t stat_lock;
  88. };
  89. struct hugetlbfs_inode_info {
  90. struct shared_policy policy;
  91. struct inode vfs_inode;
  92. };
  93. static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
  94. {
  95. return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
  96. }
  97. static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
  98. {
  99. return sb->s_fs_info;
  100. }
  101. extern struct file_operations hugetlbfs_file_operations;
  102. extern struct vm_operations_struct hugetlb_vm_ops;
  103. struct file *hugetlb_zero_setup(size_t);
  104. int hugetlb_get_quota(struct address_space *mapping);
  105. void hugetlb_put_quota(struct address_space *mapping);
  106. static inline int is_file_hugepages(struct file *file)
  107. {
  108. return file->f_op == &hugetlbfs_file_operations;
  109. }
  110. static inline void set_file_hugepages(struct file *file)
  111. {
  112. file->f_op = &hugetlbfs_file_operations;
  113. }
  114. #else /* !CONFIG_HUGETLBFS */
  115. #define is_file_hugepages(file) 0
  116. #define set_file_hugepages(file) BUG()
  117. #define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
  118. #endif /* !CONFIG_HUGETLBFS */
  119. #endif /* _LINUX_HUGETLB_H */