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