hugetlb.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_pgtables(tlb, prev, start, end) do { } while (0)
  34. #endif
  35. #ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
  36. #define prepare_hugepage_range(addr, len) \
  37. is_aligned_hugepage_range(addr, len)
  38. #else
  39. int prepare_hugepage_range(unsigned long addr, unsigned long len);
  40. #endif
  41. #else /* !CONFIG_HUGETLB_PAGE */
  42. static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
  43. {
  44. return 0;
  45. }
  46. static inline unsigned long hugetlb_total_pages(void)
  47. {
  48. return 0;
  49. }
  50. #define follow_hugetlb_page(m,v,p,vs,a,b,i) ({ BUG(); 0; })
  51. #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
  52. #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
  53. #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; })
  54. #define zap_hugepage_range(vma, start, len) BUG()
  55. #define unmap_hugepage_range(vma, start, end) BUG()
  56. #define is_hugepage_mem_enough(size) 0
  57. #define hugetlb_report_meminfo(buf) 0
  58. #define hugetlb_report_node_meminfo(n, buf) 0
  59. #define follow_huge_pmd(mm, addr, pmd, write) NULL
  60. #define is_aligned_hugepage_range(addr, len) 0
  61. #define prepare_hugepage_range(addr, len) (-EINVAL)
  62. #define pmd_huge(x) 0
  63. #define is_hugepage_only_range(mm, addr, len) 0
  64. #define hugetlb_free_pgtables(tlb, prev, start, end) do { } while (0)
  65. #define alloc_huge_page() ({ NULL; })
  66. #define free_huge_page(p) ({ (void)(p); BUG(); })
  67. #ifndef HPAGE_MASK
  68. #define HPAGE_MASK 0 /* Keep the compiler happy */
  69. #define HPAGE_SIZE 0
  70. #endif
  71. #endif /* !CONFIG_HUGETLB_PAGE */
  72. #ifdef CONFIG_HUGETLBFS
  73. struct hugetlbfs_config {
  74. uid_t uid;
  75. gid_t gid;
  76. umode_t mode;
  77. long nr_blocks;
  78. long nr_inodes;
  79. };
  80. struct hugetlbfs_sb_info {
  81. long max_blocks; /* blocks allowed */
  82. long free_blocks; /* blocks free */
  83. long max_inodes; /* inodes allowed */
  84. long free_inodes; /* inodes free */
  85. spinlock_t stat_lock;
  86. };
  87. struct hugetlbfs_inode_info {
  88. struct shared_policy policy;
  89. struct inode vfs_inode;
  90. };
  91. static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
  92. {
  93. return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
  94. }
  95. static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
  96. {
  97. return sb->s_fs_info;
  98. }
  99. extern struct file_operations hugetlbfs_file_operations;
  100. extern struct vm_operations_struct hugetlb_vm_ops;
  101. struct file *hugetlb_zero_setup(size_t);
  102. int hugetlb_get_quota(struct address_space *mapping);
  103. void hugetlb_put_quota(struct address_space *mapping);
  104. static inline int is_file_hugepages(struct file *file)
  105. {
  106. return file->f_op == &hugetlbfs_file_operations;
  107. }
  108. static inline void set_file_hugepages(struct file *file)
  109. {
  110. file->f_op = &hugetlbfs_file_operations;
  111. }
  112. #else /* !CONFIG_HUGETLBFS */
  113. #define is_file_hugepages(file) 0
  114. #define set_file_hugepages(file) BUG()
  115. #define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
  116. #endif /* !CONFIG_HUGETLBFS */
  117. #endif /* _LINUX_HUGETLB_H */