hugetlbfs: use i_mmap_rwsem for more pmd sharing synchronization
[linux-2.6-microblaze.git] / include / linux / hugetlb.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_HUGETLB_H
3 #define _LINUX_HUGETLB_H
4
5 #include <linux/mm_types.h>
6 #include <linux/mmdebug.h>
7 #include <linux/fs.h>
8 #include <linux/hugetlb_inline.h>
9 #include <linux/cgroup.h>
10 #include <linux/list.h>
11 #include <linux/kref.h>
12 #include <asm/pgtable.h>
13
14 struct ctl_table;
15 struct user_struct;
16 struct mmu_gather;
17
18 #ifndef is_hugepd
19 typedef struct { unsigned long pd; } hugepd_t;
20 #define is_hugepd(hugepd) (0)
21 #define __hugepd(x) ((hugepd_t) { (x) })
22 #endif
23
24 #ifdef CONFIG_HUGETLB_PAGE
25
26 #include <linux/mempolicy.h>
27 #include <linux/shm.h>
28 #include <asm/tlbflush.h>
29
30 struct hugepage_subpool {
31         spinlock_t lock;
32         long count;
33         long max_hpages;        /* Maximum huge pages or -1 if no maximum. */
34         long used_hpages;       /* Used count against maximum, includes */
35                                 /* both alloced and reserved pages. */
36         struct hstate *hstate;
37         long min_hpages;        /* Minimum huge pages or -1 if no minimum. */
38         long rsv_hpages;        /* Pages reserved against global pool to */
39                                 /* sasitfy minimum size. */
40 };
41
42 struct resv_map {
43         struct kref refs;
44         spinlock_t lock;
45         struct list_head regions;
46         long adds_in_progress;
47         struct list_head region_cache;
48         long region_cache_count;
49 };
50 extern struct resv_map *resv_map_alloc(void);
51 void resv_map_release(struct kref *ref);
52
53 extern spinlock_t hugetlb_lock;
54 extern int hugetlb_max_hstate __read_mostly;
55 #define for_each_hstate(h) \
56         for ((h) = hstates; (h) < &hstates[hugetlb_max_hstate]; (h)++)
57
58 struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages,
59                                                 long min_hpages);
60 void hugepage_put_subpool(struct hugepage_subpool *spool);
61
62 void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
63 int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
64 int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
65 int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
66
67 #ifdef CONFIG_NUMA
68 int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int,
69                                         void __user *, size_t *, loff_t *);
70 #endif
71
72 int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
73 long follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *,
74                          struct page **, struct vm_area_struct **,
75                          unsigned long *, unsigned long *, long, unsigned int,
76                          int *);
77 void unmap_hugepage_range(struct vm_area_struct *,
78                           unsigned long, unsigned long, struct page *);
79 void __unmap_hugepage_range_final(struct mmu_gather *tlb,
80                           struct vm_area_struct *vma,
81                           unsigned long start, unsigned long end,
82                           struct page *ref_page);
83 void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
84                                 unsigned long start, unsigned long end,
85                                 struct page *ref_page);
86 void hugetlb_report_meminfo(struct seq_file *);
87 int hugetlb_report_node_meminfo(int, char *);
88 void hugetlb_show_meminfo(void);
89 unsigned long hugetlb_total_pages(void);
90 vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
91                         unsigned long address, unsigned int flags);
92 int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte,
93                                 struct vm_area_struct *dst_vma,
94                                 unsigned long dst_addr,
95                                 unsigned long src_addr,
96                                 struct page **pagep);
97 int hugetlb_reserve_pages(struct inode *inode, long from, long to,
98                                                 struct vm_area_struct *vma,
99                                                 vm_flags_t vm_flags);
100 long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
101                                                 long freed);
102 bool isolate_huge_page(struct page *page, struct list_head *list);
103 void putback_active_hugepage(struct page *page);
104 void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason);
105 void free_huge_page(struct page *page);
106 void hugetlb_fix_reserve_counts(struct inode *inode);
107 extern struct mutex *hugetlb_fault_mutex_table;
108 u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx);
109
110 pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
111
112 struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage);
113
114 extern int sysctl_hugetlb_shm_group;
115 extern struct list_head huge_boot_pages;
116
117 /* arch callbacks */
118
119 pte_t *huge_pte_alloc(struct mm_struct *mm,
120                         unsigned long addr, unsigned long sz);
121 pte_t *huge_pte_offset(struct mm_struct *mm,
122                        unsigned long addr, unsigned long sz);
123 int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
124 void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
125                                 unsigned long *start, unsigned long *end);
126 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
127                               int write);
128 struct page *follow_huge_pd(struct vm_area_struct *vma,
129                             unsigned long address, hugepd_t hpd,
130                             int flags, int pdshift);
131 struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
132                                 pmd_t *pmd, int flags);
133 struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address,
134                                 pud_t *pud, int flags);
135 struct page *follow_huge_pgd(struct mm_struct *mm, unsigned long address,
136                              pgd_t *pgd, int flags);
137
138 int pmd_huge(pmd_t pmd);
139 int pud_huge(pud_t pud);
140 unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
141                 unsigned long address, unsigned long end, pgprot_t newprot);
142
143 bool is_hugetlb_entry_migration(pte_t pte);
144
145 #else /* !CONFIG_HUGETLB_PAGE */
146
147 static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
148 {
149 }
150
151 static inline unsigned long hugetlb_total_pages(void)
152 {
153         return 0;
154 }
155
156 static inline struct address_space *hugetlb_page_mapping_lock_write(
157                                                         struct page *hpage)
158 {
159         return NULL;
160 }
161
162 static inline int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr,
163                                         pte_t *ptep)
164 {
165         return 0;
166 }
167
168 static inline void adjust_range_if_pmd_sharing_possible(
169                                 struct vm_area_struct *vma,
170                                 unsigned long *start, unsigned long *end)
171 {
172 }
173
174 static inline long follow_hugetlb_page(struct mm_struct *mm,
175                         struct vm_area_struct *vma, struct page **pages,
176                         struct vm_area_struct **vmas, unsigned long *position,
177                         unsigned long *nr_pages, long i, unsigned int flags,
178                         int *nonblocking)
179 {
180         BUG();
181         return 0;
182 }
183
184 static inline struct page *follow_huge_addr(struct mm_struct *mm,
185                                         unsigned long address, int write)
186 {
187         return ERR_PTR(-EINVAL);
188 }
189
190 static inline int copy_hugetlb_page_range(struct mm_struct *dst,
191                         struct mm_struct *src, struct vm_area_struct *vma)
192 {
193         BUG();
194         return 0;
195 }
196
197 static inline void hugetlb_report_meminfo(struct seq_file *m)
198 {
199 }
200
201 static inline int hugetlb_report_node_meminfo(int nid, char *buf)
202 {
203         return 0;
204 }
205
206 static inline void hugetlb_show_meminfo(void)
207 {
208 }
209
210 static inline struct page *follow_huge_pd(struct vm_area_struct *vma,
211                                 unsigned long address, hugepd_t hpd, int flags,
212                                 int pdshift)
213 {
214         return NULL;
215 }
216
217 static inline struct page *follow_huge_pmd(struct mm_struct *mm,
218                                 unsigned long address, pmd_t *pmd, int flags)
219 {
220         return NULL;
221 }
222
223 static inline struct page *follow_huge_pud(struct mm_struct *mm,
224                                 unsigned long address, pud_t *pud, int flags)
225 {
226         return NULL;
227 }
228
229 static inline struct page *follow_huge_pgd(struct mm_struct *mm,
230                                 unsigned long address, pgd_t *pgd, int flags)
231 {
232         return NULL;
233 }
234
235 static inline int prepare_hugepage_range(struct file *file,
236                                 unsigned long addr, unsigned long len)
237 {
238         return -EINVAL;
239 }
240
241 static inline int pmd_huge(pmd_t pmd)
242 {
243         return 0;
244 }
245
246 static inline int pud_huge(pud_t pud)
247 {
248         return 0;
249 }
250
251 static inline int is_hugepage_only_range(struct mm_struct *mm,
252                                         unsigned long addr, unsigned long len)
253 {
254         return 0;
255 }
256
257 static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
258                                 unsigned long addr, unsigned long end,
259                                 unsigned long floor, unsigned long ceiling)
260 {
261         BUG();
262 }
263
264 static inline int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
265                                                 pte_t *dst_pte,
266                                                 struct vm_area_struct *dst_vma,
267                                                 unsigned long dst_addr,
268                                                 unsigned long src_addr,
269                                                 struct page **pagep)
270 {
271         BUG();
272         return 0;
273 }
274
275 static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,
276                                         unsigned long sz)
277 {
278         return NULL;
279 }
280
281 static inline bool isolate_huge_page(struct page *page, struct list_head *list)
282 {
283         return false;
284 }
285
286 static inline void putback_active_hugepage(struct page *page)
287 {
288 }
289
290 static inline void move_hugetlb_state(struct page *oldpage,
291                                         struct page *newpage, int reason)
292 {
293 }
294
295 static inline unsigned long hugetlb_change_protection(
296                         struct vm_area_struct *vma, unsigned long address,
297                         unsigned long end, pgprot_t newprot)
298 {
299         return 0;
300 }
301
302 static inline void __unmap_hugepage_range_final(struct mmu_gather *tlb,
303                         struct vm_area_struct *vma, unsigned long start,
304                         unsigned long end, struct page *ref_page)
305 {
306         BUG();
307 }
308
309 static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
310                         struct vm_area_struct *vma, unsigned long start,
311                         unsigned long end, struct page *ref_page)
312 {
313         BUG();
314 }
315
316 static inline vm_fault_t hugetlb_fault(struct mm_struct *mm,
317                         struct vm_area_struct *vma, unsigned long address,
318                         unsigned int flags)
319 {
320         BUG();
321         return 0;
322 }
323
324 #endif /* !CONFIG_HUGETLB_PAGE */
325 /*
326  * hugepages at page global directory. If arch support
327  * hugepages at pgd level, they need to define this.
328  */
329 #ifndef pgd_huge
330 #define pgd_huge(x)     0
331 #endif
332 #ifndef p4d_huge
333 #define p4d_huge(x)     0
334 #endif
335
336 #ifndef pgd_write
337 static inline int pgd_write(pgd_t pgd)
338 {
339         BUG();
340         return 0;
341 }
342 #endif
343
344 #define HUGETLB_ANON_FILE "anon_hugepage"
345
346 enum {
347         /*
348          * The file will be used as an shm file so shmfs accounting rules
349          * apply
350          */
351         HUGETLB_SHMFS_INODE     = 1,
352         /*
353          * The file is being created on the internal vfs mount and shmfs
354          * accounting rules do not apply
355          */
356         HUGETLB_ANONHUGE_INODE  = 2,
357 };
358
359 #ifdef CONFIG_HUGETLBFS
360 struct hugetlbfs_sb_info {
361         long    max_inodes;   /* inodes allowed */
362         long    free_inodes;  /* inodes free */
363         spinlock_t      stat_lock;
364         struct hstate *hstate;
365         struct hugepage_subpool *spool;
366         kuid_t  uid;
367         kgid_t  gid;
368         umode_t mode;
369 };
370
371 static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
372 {
373         return sb->s_fs_info;
374 }
375
376 struct hugetlbfs_inode_info {
377         struct shared_policy policy;
378         struct inode vfs_inode;
379         unsigned int seals;
380 };
381
382 static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
383 {
384         return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
385 }
386
387 extern const struct file_operations hugetlbfs_file_operations;
388 extern const struct vm_operations_struct hugetlb_vm_ops;
389 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
390                                 struct user_struct **user, int creat_flags,
391                                 int page_size_log);
392
393 static inline bool is_file_hugepages(struct file *file)
394 {
395         if (file->f_op == &hugetlbfs_file_operations)
396                 return true;
397
398         return is_file_shm_hugepages(file);
399 }
400
401
402 #else /* !CONFIG_HUGETLBFS */
403
404 #define is_file_hugepages(file)                 false
405 static inline struct file *
406 hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
407                 struct user_struct **user, int creat_flags,
408                 int page_size_log)
409 {
410         return ERR_PTR(-ENOSYS);
411 }
412
413 #endif /* !CONFIG_HUGETLBFS */
414
415 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
416 unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
417                                         unsigned long len, unsigned long pgoff,
418                                         unsigned long flags);
419 #endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */
420
421 #ifdef CONFIG_HUGETLB_PAGE
422
423 #define HSTATE_NAME_LEN 32
424 /* Defines one hugetlb page size */
425 struct hstate {
426         int next_nid_to_alloc;
427         int next_nid_to_free;
428         unsigned int order;
429         unsigned long mask;
430         unsigned long max_huge_pages;
431         unsigned long nr_huge_pages;
432         unsigned long free_huge_pages;
433         unsigned long resv_huge_pages;
434         unsigned long surplus_huge_pages;
435         unsigned long nr_overcommit_huge_pages;
436         struct list_head hugepage_activelist;
437         struct list_head hugepage_freelists[MAX_NUMNODES];
438         unsigned int nr_huge_pages_node[MAX_NUMNODES];
439         unsigned int free_huge_pages_node[MAX_NUMNODES];
440         unsigned int surplus_huge_pages_node[MAX_NUMNODES];
441 #ifdef CONFIG_CGROUP_HUGETLB
442         /* cgroup control files */
443         struct cftype cgroup_files_dfl[5];
444         struct cftype cgroup_files_legacy[5];
445 #endif
446         char name[HSTATE_NAME_LEN];
447 };
448
449 struct huge_bootmem_page {
450         struct list_head list;
451         struct hstate *hstate;
452 };
453
454 struct page *alloc_huge_page(struct vm_area_struct *vma,
455                                 unsigned long addr, int avoid_reserve);
456 struct page *alloc_huge_page_node(struct hstate *h, int nid);
457 struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid,
458                                 nodemask_t *nmask);
459 struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
460                                 unsigned long address);
461 struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
462                                      int nid, nodemask_t *nmask);
463 int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
464                         pgoff_t idx);
465
466 /* arch callback */
467 int __init __alloc_bootmem_huge_page(struct hstate *h);
468 int __init alloc_bootmem_huge_page(struct hstate *h);
469
470 void __init hugetlb_bad_size(void);
471 void __init hugetlb_add_hstate(unsigned order);
472 struct hstate *size_to_hstate(unsigned long size);
473
474 #ifndef HUGE_MAX_HSTATE
475 #define HUGE_MAX_HSTATE 1
476 #endif
477
478 extern struct hstate hstates[HUGE_MAX_HSTATE];
479 extern unsigned int default_hstate_idx;
480
481 #define default_hstate (hstates[default_hstate_idx])
482
483 static inline struct hstate *hstate_inode(struct inode *i)
484 {
485         return HUGETLBFS_SB(i->i_sb)->hstate;
486 }
487
488 static inline struct hstate *hstate_file(struct file *f)
489 {
490         return hstate_inode(file_inode(f));
491 }
492
493 static inline struct hstate *hstate_sizelog(int page_size_log)
494 {
495         if (!page_size_log)
496                 return &default_hstate;
497
498         return size_to_hstate(1UL << page_size_log);
499 }
500
501 static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
502 {
503         return hstate_file(vma->vm_file);
504 }
505
506 static inline unsigned long huge_page_size(struct hstate *h)
507 {
508         return (unsigned long)PAGE_SIZE << h->order;
509 }
510
511 extern unsigned long vma_kernel_pagesize(struct vm_area_struct *vma);
512
513 extern unsigned long vma_mmu_pagesize(struct vm_area_struct *vma);
514
515 static inline unsigned long huge_page_mask(struct hstate *h)
516 {
517         return h->mask;
518 }
519
520 static inline unsigned int huge_page_order(struct hstate *h)
521 {
522         return h->order;
523 }
524
525 static inline unsigned huge_page_shift(struct hstate *h)
526 {
527         return h->order + PAGE_SHIFT;
528 }
529
530 static inline bool hstate_is_gigantic(struct hstate *h)
531 {
532         return huge_page_order(h) >= MAX_ORDER;
533 }
534
535 static inline unsigned int pages_per_huge_page(struct hstate *h)
536 {
537         return 1 << h->order;
538 }
539
540 static inline unsigned int blocks_per_huge_page(struct hstate *h)
541 {
542         return huge_page_size(h) / 512;
543 }
544
545 #include <asm/hugetlb.h>
546
547 #ifndef arch_make_huge_pte
548 static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
549                                        struct page *page, int writable)
550 {
551         return entry;
552 }
553 #endif
554
555 static inline struct hstate *page_hstate(struct page *page)
556 {
557         VM_BUG_ON_PAGE(!PageHuge(page), page);
558         return size_to_hstate(page_size(page));
559 }
560
561 static inline unsigned hstate_index_to_shift(unsigned index)
562 {
563         return hstates[index].order + PAGE_SHIFT;
564 }
565
566 static inline int hstate_index(struct hstate *h)
567 {
568         return h - hstates;
569 }
570
571 pgoff_t __basepage_index(struct page *page);
572
573 /* Return page->index in PAGE_SIZE units */
574 static inline pgoff_t basepage_index(struct page *page)
575 {
576         if (!PageCompound(page))
577                 return page->index;
578
579         return __basepage_index(page);
580 }
581
582 extern int dissolve_free_huge_page(struct page *page);
583 extern int dissolve_free_huge_pages(unsigned long start_pfn,
584                                     unsigned long end_pfn);
585
586 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
587 #ifndef arch_hugetlb_migration_supported
588 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
589 {
590         if ((huge_page_shift(h) == PMD_SHIFT) ||
591                 (huge_page_shift(h) == PUD_SHIFT) ||
592                         (huge_page_shift(h) == PGDIR_SHIFT))
593                 return true;
594         else
595                 return false;
596 }
597 #endif
598 #else
599 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
600 {
601         return false;
602 }
603 #endif
604
605 static inline bool hugepage_migration_supported(struct hstate *h)
606 {
607         return arch_hugetlb_migration_supported(h);
608 }
609
610 /*
611  * Movability check is different as compared to migration check.
612  * It determines whether or not a huge page should be placed on
613  * movable zone or not. Movability of any huge page should be
614  * required only if huge page size is supported for migration.
615  * There wont be any reason for the huge page to be movable if
616  * it is not migratable to start with. Also the size of the huge
617  * page should be large enough to be placed under a movable zone
618  * and still feasible enough to be migratable. Just the presence
619  * in movable zone does not make the migration feasible.
620  *
621  * So even though large huge page sizes like the gigantic ones
622  * are migratable they should not be movable because its not
623  * feasible to migrate them from movable zone.
624  */
625 static inline bool hugepage_movable_supported(struct hstate *h)
626 {
627         if (!hugepage_migration_supported(h))
628                 return false;
629
630         if (hstate_is_gigantic(h))
631                 return false;
632         return true;
633 }
634
635 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
636                                            struct mm_struct *mm, pte_t *pte)
637 {
638         if (huge_page_size(h) == PMD_SIZE)
639                 return pmd_lockptr(mm, (pmd_t *) pte);
640         VM_BUG_ON(huge_page_size(h) == PAGE_SIZE);
641         return &mm->page_table_lock;
642 }
643
644 #ifndef hugepages_supported
645 /*
646  * Some platform decide whether they support huge pages at boot
647  * time. Some of them, such as powerpc, set HPAGE_SHIFT to 0
648  * when there is no such support
649  */
650 #define hugepages_supported() (HPAGE_SHIFT != 0)
651 #endif
652
653 void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm);
654
655 static inline void hugetlb_count_add(long l, struct mm_struct *mm)
656 {
657         atomic_long_add(l, &mm->hugetlb_usage);
658 }
659
660 static inline void hugetlb_count_sub(long l, struct mm_struct *mm)
661 {
662         atomic_long_sub(l, &mm->hugetlb_usage);
663 }
664
665 #ifndef set_huge_swap_pte_at
666 static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr,
667                                         pte_t *ptep, pte_t pte, unsigned long sz)
668 {
669         set_huge_pte_at(mm, addr, ptep, pte);
670 }
671 #endif
672
673 #ifndef huge_ptep_modify_prot_start
674 #define huge_ptep_modify_prot_start huge_ptep_modify_prot_start
675 static inline pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,
676                                                 unsigned long addr, pte_t *ptep)
677 {
678         return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
679 }
680 #endif
681
682 #ifndef huge_ptep_modify_prot_commit
683 #define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit
684 static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
685                                                 unsigned long addr, pte_t *ptep,
686                                                 pte_t old_pte, pte_t pte)
687 {
688         set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
689 }
690 #endif
691
692 #else   /* CONFIG_HUGETLB_PAGE */
693 struct hstate {};
694
695 static inline struct page *alloc_huge_page(struct vm_area_struct *vma,
696                                            unsigned long addr,
697                                            int avoid_reserve)
698 {
699         return NULL;
700 }
701
702 static inline struct page *alloc_huge_page_node(struct hstate *h, int nid)
703 {
704         return NULL;
705 }
706
707 static inline struct page *
708 alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, nodemask_t *nmask)
709 {
710         return NULL;
711 }
712
713 static inline struct page *alloc_huge_page_vma(struct hstate *h,
714                                                struct vm_area_struct *vma,
715                                                unsigned long address)
716 {
717         return NULL;
718 }
719
720 static inline int __alloc_bootmem_huge_page(struct hstate *h)
721 {
722         return 0;
723 }
724
725 static inline struct hstate *hstate_file(struct file *f)
726 {
727         return NULL;
728 }
729
730 static inline struct hstate *hstate_sizelog(int page_size_log)
731 {
732         return NULL;
733 }
734
735 static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
736 {
737         return NULL;
738 }
739
740 static inline struct hstate *hstate_inode(struct inode *i)
741 {
742         return NULL;
743 }
744
745 static inline struct hstate *page_hstate(struct page *page)
746 {
747         return NULL;
748 }
749
750 static inline unsigned long huge_page_size(struct hstate *h)
751 {
752         return PAGE_SIZE;
753 }
754
755 static inline unsigned long huge_page_mask(struct hstate *h)
756 {
757         return PAGE_MASK;
758 }
759
760 static inline unsigned long vma_kernel_pagesize(struct vm_area_struct *vma)
761 {
762         return PAGE_SIZE;
763 }
764
765 static inline unsigned long vma_mmu_pagesize(struct vm_area_struct *vma)
766 {
767         return PAGE_SIZE;
768 }
769
770 static inline unsigned int huge_page_order(struct hstate *h)
771 {
772         return 0;
773 }
774
775 static inline unsigned int huge_page_shift(struct hstate *h)
776 {
777         return PAGE_SHIFT;
778 }
779
780 static inline bool hstate_is_gigantic(struct hstate *h)
781 {
782         return false;
783 }
784
785 static inline unsigned int pages_per_huge_page(struct hstate *h)
786 {
787         return 1;
788 }
789
790 static inline unsigned hstate_index_to_shift(unsigned index)
791 {
792         return 0;
793 }
794
795 static inline int hstate_index(struct hstate *h)
796 {
797         return 0;
798 }
799
800 static inline pgoff_t basepage_index(struct page *page)
801 {
802         return page->index;
803 }
804
805 static inline int dissolve_free_huge_page(struct page *page)
806 {
807         return 0;
808 }
809
810 static inline int dissolve_free_huge_pages(unsigned long start_pfn,
811                                            unsigned long end_pfn)
812 {
813         return 0;
814 }
815
816 static inline bool hugepage_migration_supported(struct hstate *h)
817 {
818         return false;
819 }
820
821 static inline bool hugepage_movable_supported(struct hstate *h)
822 {
823         return false;
824 }
825
826 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
827                                            struct mm_struct *mm, pte_t *pte)
828 {
829         return &mm->page_table_lock;
830 }
831
832 static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m)
833 {
834 }
835
836 static inline void hugetlb_count_sub(long l, struct mm_struct *mm)
837 {
838 }
839
840 static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr,
841                                         pte_t *ptep, pte_t pte, unsigned long sz)
842 {
843 }
844 #endif  /* CONFIG_HUGETLB_PAGE */
845
846 static inline spinlock_t *huge_pte_lock(struct hstate *h,
847                                         struct mm_struct *mm, pte_t *pte)
848 {
849         spinlock_t *ptl;
850
851         ptl = huge_pte_lockptr(h, mm, pte);
852         spin_lock(ptl);
853         return ptl;
854 }
855
856 #endif /* _LINUX_HUGETLB_H */