Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_HUGETLB_H |
| 2 | #define _LINUX_HUGETLB_H |
| 3 | |
Linus Torvalds | be93d8c | 2011-05-26 12:03:50 -0700 | [diff] [blame] | 4 | #include <linux/mm_types.h> |
Alexey Dobriyan | 4e950f6 | 2007-07-30 02:36:13 +0400 | [diff] [blame] | 5 | #include <linux/fs.h> |
Naoya Horiguchi | 8edf344 | 2010-05-28 09:29:15 +0900 | [diff] [blame] | 6 | #include <linux/hugetlb_inline.h> |
Alexey Dobriyan | 4e950f6 | 2007-07-30 02:36:13 +0400 | [diff] [blame] | 7 | |
Andrew Morton | e9ea0e2 | 2009-09-24 14:47:45 -0700 | [diff] [blame] | 8 | struct ctl_table; |
| 9 | struct user_struct; |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #ifdef CONFIG_HUGETLB_PAGE |
| 12 | |
| 13 | #include <linux/mempolicy.h> |
Adam Litke | 516dffd | 2007-03-01 15:46:08 -0800 | [diff] [blame] | 14 | #include <linux/shm.h> |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 15 | #include <asm/tlbflush.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
David Gibson | 9048162 | 2012-03-21 16:34:12 -0700 | [diff] [blame] | 17 | struct hugepage_subpool { |
| 18 | spinlock_t lock; |
| 19 | long count; |
| 20 | long max_hpages, used_hpages; |
| 21 | }; |
| 22 | |
| 23 | struct hugepage_subpool *hugepage_new_subpool(long nr_blocks); |
| 24 | void hugepage_put_subpool(struct hugepage_subpool *spool); |
| 25 | |
Wu Fengguang | 20a0307 | 2009-06-16 15:32:22 -0700 | [diff] [blame] | 26 | int PageHuge(struct page *page); |
| 27 | |
Mel Gorman | a1e7877 | 2008-07-23 21:27:23 -0700 | [diff] [blame] | 28 | void reset_vma_resv_huge_pages(struct vm_area_struct *vma); |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 29 | int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
| 30 | int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
| 31 | int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); |
Lee Schermerhorn | 06808b0 | 2009-12-14 17:58:21 -0800 | [diff] [blame] | 32 | |
| 33 | #ifdef CONFIG_NUMA |
| 34 | int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int, |
| 35 | void __user *, size_t *, loff_t *); |
| 36 | #endif |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *); |
Hugh Dickins | 2a15efc | 2009-09-21 17:03:27 -0700 | [diff] [blame] | 39 | int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, |
| 40 | struct page **, struct vm_area_struct **, |
| 41 | unsigned long *, int *, int, unsigned int flags); |
Mel Gorman | 04f2cbe | 2008-07-23 21:27:25 -0700 | [diff] [blame] | 42 | void unmap_hugepage_range(struct vm_area_struct *, |
| 43 | unsigned long, unsigned long, struct page *); |
| 44 | void __unmap_hugepage_range(struct vm_area_struct *, |
| 45 | unsigned long, unsigned long, struct page *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | int hugetlb_prefault(struct address_space *, struct vm_area_struct *); |
Alexey Dobriyan | e1759c2 | 2008-10-15 23:50:22 +0400 | [diff] [blame] | 47 | void hugetlb_report_meminfo(struct seq_file *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | int hugetlb_report_node_meminfo(int, char *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | unsigned long hugetlb_total_pages(void); |
Hugh Dickins | ac9b9c6 | 2005-10-20 16:24:28 +0100 | [diff] [blame] | 50 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, |
Hugh Dickins | 788c7df | 2009-06-23 13:49:05 +0100 | [diff] [blame] | 51 | unsigned long address, unsigned int flags); |
Mel Gorman | a1e7877 | 2008-07-23 21:27:23 -0700 | [diff] [blame] | 52 | int hugetlb_reserve_pages(struct inode *inode, long from, long to, |
Mel Gorman | 5a6fe12 | 2009-02-10 14:02:27 +0000 | [diff] [blame] | 53 | struct vm_area_struct *vma, |
KOSAKI Motohiro | ca16d14 | 2011-05-26 19:16:19 +0900 | [diff] [blame] | 54 | vm_flags_t vm_flags); |
Chen, Kenneth W | a43a8c3 | 2006-06-23 02:03:15 -0700 | [diff] [blame] | 55 | void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); |
Naoya Horiguchi | 6de2b1a | 2010-09-08 10:19:36 +0900 | [diff] [blame] | 56 | int dequeue_hwpoisoned_huge_page(struct page *page); |
Naoya Horiguchi | 0ebabb4 | 2010-09-08 10:19:34 +0900 | [diff] [blame] | 57 | void copy_huge_page(struct page *dst, struct page *src); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Mel Gorman | 396faf0 | 2007-07-17 04:03:13 -0700 | [diff] [blame] | 59 | extern unsigned long hugepages_treat_as_movable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern const unsigned long hugetlb_zero, hugetlb_infinity; |
| 61 | extern int sysctl_hugetlb_shm_group; |
Jon Tollefson | 53ba51d | 2008-07-23 21:27:52 -0700 | [diff] [blame] | 62 | extern struct list_head huge_boot_pages; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 64 | /* arch callbacks */ |
| 65 | |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 66 | pte_t *huge_pte_alloc(struct mm_struct *mm, |
| 67 | unsigned long addr, unsigned long sz); |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 68 | pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr); |
Chen, Kenneth W | 39dde65 | 2006-12-06 20:32:03 -0800 | [diff] [blame] | 69 | int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep); |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 70 | struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, |
| 71 | int write); |
| 72 | struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, |
| 73 | pmd_t *pmd, int write); |
Andi Kleen | ceb8687 | 2008-07-23 21:27:50 -0700 | [diff] [blame] | 74 | struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address, |
| 75 | pud_t *pud, int write); |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 76 | int pmd_huge(pmd_t pmd); |
Andi Kleen | ceb8687 | 2008-07-23 21:27:50 -0700 | [diff] [blame] | 77 | int pud_huge(pud_t pmd); |
Zhang, Yanmin | 8f86059 | 2006-03-22 00:08:50 -0800 | [diff] [blame] | 78 | void hugetlb_change_protection(struct vm_area_struct *vma, |
| 79 | unsigned long address, unsigned long end, pgprot_t newprot); |
David Gibson | 63551ae | 2005-06-21 17:14:44 -0700 | [diff] [blame] | 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #else /* !CONFIG_HUGETLB_PAGE */ |
| 82 | |
Wu Fengguang | 20a0307 | 2009-06-16 15:32:22 -0700 | [diff] [blame] | 83 | static inline int PageHuge(struct page *page) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
Mel Gorman | a1e7877 | 2008-07-23 21:27:23 -0700 | [diff] [blame] | 88 | static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma) |
| 89 | { |
| 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | static inline unsigned long hugetlb_total_pages(void) |
| 93 | { |
| 94 | return 0; |
| 95 | } |
| 96 | |
Adam Litke | 5b23dbe | 2007-11-14 16:59:33 -0800 | [diff] [blame] | 97 | #define follow_hugetlb_page(m,v,p,vs,a,b,i,w) ({ BUG(); 0; }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL) |
| 99 | #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) |
| 100 | #define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) |
Mel Gorman | 04f2cbe | 2008-07-23 21:27:25 -0700 | [diff] [blame] | 101 | #define unmap_hugepage_range(vma, start, end, page) BUG() |
Alexey Dobriyan | e1759c2 | 2008-10-15 23:50:22 +0400 | [diff] [blame] | 102 | static inline void hugetlb_report_meminfo(struct seq_file *m) |
| 103 | { |
| 104 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #define hugetlb_report_node_meminfo(n, buf) 0 |
| 106 | #define follow_huge_pmd(mm, addr, pmd, write) NULL |
Andi Kleen | ceb8687 | 2008-07-23 21:27:50 -0700 | [diff] [blame] | 107 | #define follow_huge_pud(mm, addr, pud, write) NULL |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 108 | #define prepare_hugepage_range(file, addr, len) (-EINVAL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | #define pmd_huge(x) 0 |
Andi Kleen | ceb8687 | 2008-07-23 21:27:50 -0700 | [diff] [blame] | 110 | #define pud_huge(x) 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | #define is_hugepage_only_range(mm, addr, len) 0 |
David Gibson | 9da61ae | 2006-03-22 00:08:57 -0800 | [diff] [blame] | 112 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) |
Hugh Dickins | 788c7df | 2009-06-23 13:49:05 +0100 | [diff] [blame] | 113 | #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) |
Naoya Horiguchi | 0fe6e20 | 2010-05-28 09:29:16 +0900 | [diff] [blame] | 114 | #define huge_pte_offset(mm, address) 0 |
Naoya Horiguchi | 6de2b1a | 2010-09-08 10:19:36 +0900 | [diff] [blame] | 115 | #define dequeue_hwpoisoned_huge_page(page) 0 |
Naoya Horiguchi | 0ebabb4 | 2010-09-08 10:19:34 +0900 | [diff] [blame] | 116 | static inline void copy_huge_page(struct page *dst, struct page *src) |
| 117 | { |
| 118 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Zhang, Yanmin | 8f86059 | 2006-03-22 00:08:50 -0800 | [diff] [blame] | 120 | #define hugetlb_change_protection(vma, address, end, newprot) |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | #endif /* !CONFIG_HUGETLB_PAGE */ |
| 123 | |
Eric B Munson | 4e52780 | 2009-09-21 17:03:47 -0700 | [diff] [blame] | 124 | #define HUGETLB_ANON_FILE "anon_hugepage" |
| 125 | |
Eric B Munson | 6bfde05 | 2009-09-21 17:03:43 -0700 | [diff] [blame] | 126 | enum { |
| 127 | /* |
| 128 | * The file will be used as an shm file so shmfs accounting rules |
| 129 | * apply |
| 130 | */ |
| 131 | HUGETLB_SHMFS_INODE = 1, |
Eric B Munson | 4e52780 | 2009-09-21 17:03:47 -0700 | [diff] [blame] | 132 | /* |
| 133 | * The file is being created on the internal vfs mount and shmfs |
| 134 | * accounting rules do not apply |
| 135 | */ |
| 136 | HUGETLB_ANONHUGE_INODE = 2, |
Eric B Munson | 6bfde05 | 2009-09-21 17:03:43 -0700 | [diff] [blame] | 137 | }; |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | #ifdef CONFIG_HUGETLBFS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | struct hugetlbfs_sb_info { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | long max_inodes; /* inodes allowed */ |
| 142 | long free_inodes; /* inodes free */ |
| 143 | spinlock_t stat_lock; |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 144 | struct hstate *hstate; |
David Gibson | 9048162 | 2012-03-21 16:34:12 -0700 | [diff] [blame] | 145 | struct hugepage_subpool *spool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb) |
| 149 | { |
| 150 | return sb->s_fs_info; |
| 151 | } |
| 152 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 153 | extern const struct file_operations hugetlbfs_file_operations; |
Alexey Dobriyan | f0f37e2 | 2009-09-27 22:29:37 +0400 | [diff] [blame] | 154 | extern const struct vm_operations_struct hugetlb_vm_ops; |
Steven Truelove | 40716e2 | 2012-03-21 16:34:14 -0700 | [diff] [blame] | 155 | struct file *hugetlb_file_setup(const char *name, unsigned long addr, |
| 156 | size_t size, vm_flags_t acct, |
Eric B Munson | 6bfde05 | 2009-09-21 17:03:43 -0700 | [diff] [blame] | 157 | struct user_struct **user, int creat_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | static inline int is_file_hugepages(struct file *file) |
| 160 | { |
Adam Litke | 516dffd | 2007-03-01 15:46:08 -0800 | [diff] [blame] | 161 | if (file->f_op == &hugetlbfs_file_operations) |
| 162 | return 1; |
| 163 | if (is_file_shm_hugepages(file)) |
| 164 | return 1; |
| 165 | |
| 166 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | #else /* !CONFIG_HUGETLBFS */ |
| 170 | |
Stefan Richter | 1db8508 | 2009-02-10 23:27:32 +0100 | [diff] [blame] | 171 | #define is_file_hugepages(file) 0 |
Steven Truelove | 40716e2 | 2012-03-21 16:34:14 -0700 | [diff] [blame] | 172 | static inline struct file * |
| 173 | hugetlb_file_setup(const char *name, unsigned long addr, size_t size, |
KOSAKI Motohiro | ca16d14 | 2011-05-26 19:16:19 +0900 | [diff] [blame] | 174 | vm_flags_t acctflag, struct user_struct **user, int creat_flags) |
Andrew Morton | e9ea0e2 | 2009-09-24 14:47:45 -0700 | [diff] [blame] | 175 | { |
| 176 | return ERR_PTR(-ENOSYS); |
| 177 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | #endif /* !CONFIG_HUGETLBFS */ |
| 180 | |
Adrian Bunk | d2ba27e8 | 2007-05-06 14:49:00 -0700 | [diff] [blame] | 181 | #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA |
| 182 | unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, |
| 183 | unsigned long len, unsigned long pgoff, |
| 184 | unsigned long flags); |
| 185 | #endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */ |
| 186 | |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 187 | #ifdef CONFIG_HUGETLB_PAGE |
| 188 | |
Nishanth Aravamudan | a343787 | 2008-07-23 21:27:44 -0700 | [diff] [blame] | 189 | #define HSTATE_NAME_LEN 32 |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 190 | /* Defines one hugetlb page size */ |
| 191 | struct hstate { |
Lee Schermerhorn | e8c5c82 | 2009-09-21 17:01:22 -0700 | [diff] [blame] | 192 | int next_nid_to_alloc; |
| 193 | int next_nid_to_free; |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 194 | unsigned int order; |
| 195 | unsigned long mask; |
| 196 | unsigned long max_huge_pages; |
| 197 | unsigned long nr_huge_pages; |
| 198 | unsigned long free_huge_pages; |
| 199 | unsigned long resv_huge_pages; |
| 200 | unsigned long surplus_huge_pages; |
| 201 | unsigned long nr_overcommit_huge_pages; |
| 202 | struct list_head hugepage_freelists[MAX_NUMNODES]; |
| 203 | unsigned int nr_huge_pages_node[MAX_NUMNODES]; |
| 204 | unsigned int free_huge_pages_node[MAX_NUMNODES]; |
| 205 | unsigned int surplus_huge_pages_node[MAX_NUMNODES]; |
Nishanth Aravamudan | a343787 | 2008-07-23 21:27:44 -0700 | [diff] [blame] | 206 | char name[HSTATE_NAME_LEN]; |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 207 | }; |
| 208 | |
Jon Tollefson | 53ba51d | 2008-07-23 21:27:52 -0700 | [diff] [blame] | 209 | struct huge_bootmem_page { |
| 210 | struct list_head list; |
| 211 | struct hstate *hstate; |
Becky Bruce | ee8f248 | 2011-07-25 17:11:50 -0700 | [diff] [blame] | 212 | #ifdef CONFIG_HIGHMEM |
| 213 | phys_addr_t phys; |
| 214 | #endif |
Jon Tollefson | 53ba51d | 2008-07-23 21:27:52 -0700 | [diff] [blame] | 215 | }; |
| 216 | |
Naoya Horiguchi | bf50bab | 2010-09-08 10:19:33 +0900 | [diff] [blame] | 217 | struct page *alloc_huge_page_node(struct hstate *h, int nid); |
| 218 | |
Jon Tollefson | 53ba51d | 2008-07-23 21:27:52 -0700 | [diff] [blame] | 219 | /* arch callback */ |
| 220 | int __init alloc_bootmem_huge_page(struct hstate *h); |
| 221 | |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 222 | void __init hugetlb_add_hstate(unsigned order); |
| 223 | struct hstate *size_to_hstate(unsigned long size); |
| 224 | |
| 225 | #ifndef HUGE_MAX_HSTATE |
| 226 | #define HUGE_MAX_HSTATE 1 |
| 227 | #endif |
| 228 | |
| 229 | extern struct hstate hstates[HUGE_MAX_HSTATE]; |
| 230 | extern unsigned int default_hstate_idx; |
| 231 | |
| 232 | #define default_hstate (hstates[default_hstate_idx]) |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 233 | |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 234 | static inline struct hstate *hstate_inode(struct inode *i) |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 235 | { |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 236 | struct hugetlbfs_sb_info *hsb; |
| 237 | hsb = HUGETLBFS_SB(i->i_sb); |
| 238 | return hsb->hstate; |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static inline struct hstate *hstate_file(struct file *f) |
| 242 | { |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 243 | return hstate_inode(f->f_dentry->d_inode); |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 246 | static inline struct hstate *hstate_vma(struct vm_area_struct *vma) |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 247 | { |
Andi Kleen | a137e1c | 2008-07-23 21:27:43 -0700 | [diff] [blame] | 248 | return hstate_file(vma->vm_file); |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static inline unsigned long huge_page_size(struct hstate *h) |
| 252 | { |
| 253 | return (unsigned long)PAGE_SIZE << h->order; |
| 254 | } |
| 255 | |
Mel Gorman | 08fba69 | 2009-01-06 14:38:53 -0800 | [diff] [blame] | 256 | extern unsigned long vma_kernel_pagesize(struct vm_area_struct *vma); |
| 257 | |
Mel Gorman | 3340289 | 2009-01-06 14:38:54 -0800 | [diff] [blame] | 258 | extern unsigned long vma_mmu_pagesize(struct vm_area_struct *vma); |
| 259 | |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 260 | static inline unsigned long huge_page_mask(struct hstate *h) |
| 261 | { |
| 262 | return h->mask; |
| 263 | } |
| 264 | |
| 265 | static inline unsigned int huge_page_order(struct hstate *h) |
| 266 | { |
| 267 | return h->order; |
| 268 | } |
| 269 | |
| 270 | static inline unsigned huge_page_shift(struct hstate *h) |
| 271 | { |
| 272 | return h->order + PAGE_SHIFT; |
| 273 | } |
| 274 | |
| 275 | static inline unsigned int pages_per_huge_page(struct hstate *h) |
| 276 | { |
| 277 | return 1 << h->order; |
| 278 | } |
| 279 | |
| 280 | static inline unsigned int blocks_per_huge_page(struct hstate *h) |
| 281 | { |
| 282 | return huge_page_size(h) / 512; |
| 283 | } |
| 284 | |
| 285 | #include <asm/hugetlb.h> |
| 286 | |
Andi Kleen | e5ff215 | 2008-07-23 21:27:42 -0700 | [diff] [blame] | 287 | static inline struct hstate *page_hstate(struct page *page) |
| 288 | { |
| 289 | return size_to_hstate(PAGE_SIZE << compound_order(page)); |
| 290 | } |
| 291 | |
Andi Kleen | aa50d3a | 2010-10-06 21:45:00 +0200 | [diff] [blame] | 292 | static inline unsigned hstate_index_to_shift(unsigned index) |
| 293 | { |
| 294 | return hstates[index].order + PAGE_SHIFT; |
| 295 | } |
| 296 | |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 297 | #else |
| 298 | struct hstate {}; |
Naoya Horiguchi | bf50bab | 2010-09-08 10:19:33 +0900 | [diff] [blame] | 299 | #define alloc_huge_page_node(h, nid) NULL |
Jon Tollefson | 53ba51d | 2008-07-23 21:27:52 -0700 | [diff] [blame] | 300 | #define alloc_bootmem_huge_page(h) NULL |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 301 | #define hstate_file(f) NULL |
| 302 | #define hstate_vma(v) NULL |
| 303 | #define hstate_inode(i) NULL |
| 304 | #define huge_page_size(h) PAGE_SIZE |
| 305 | #define huge_page_mask(h) PAGE_MASK |
Mel Gorman | 08fba69 | 2009-01-06 14:38:53 -0800 | [diff] [blame] | 306 | #define vma_kernel_pagesize(v) PAGE_SIZE |
Mel Gorman | 3340289 | 2009-01-06 14:38:54 -0800 | [diff] [blame] | 307 | #define vma_mmu_pagesize(v) PAGE_SIZE |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 308 | #define huge_page_order(h) 0 |
| 309 | #define huge_page_shift(h) PAGE_SHIFT |
Andrea Righi | 510a35d | 2008-07-26 15:22:27 -0700 | [diff] [blame] | 310 | static inline unsigned int pages_per_huge_page(struct hstate *h) |
| 311 | { |
| 312 | return 1; |
| 313 | } |
Andi Kleen | aa50d3a | 2010-10-06 21:45:00 +0200 | [diff] [blame] | 314 | #define hstate_index_to_shift(index) 0 |
Andi Kleen | a551643 | 2008-07-23 21:27:41 -0700 | [diff] [blame] | 315 | #endif |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #endif /* _LINUX_HUGETLB_H */ |