1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_HUGETLB_H
3 #define _LINUX_HUGETLB_H
5 #include <linux/mm_types.h>
6 #include <linux/mmdebug.h>
8 #include <linux/hugetlb_inline.h>
9 #include <linux/cgroup.h>
10 #include <linux/page_ref.h>
11 #include <linux/list.h>
12 #include <linux/kref.h>
13 #include <linux/pgtable.h>
14 #include <linux/gfp.h>
21 typedef struct { unsigned long pd; } hugepd_t;
22 #define is_hugepd(hugepd) (0)
23 #define __hugepd(x) ((hugepd_t) { (x) })
26 #ifdef CONFIG_HUGETLB_PAGE
28 #include <linux/mempolicy.h>
29 #include <linux/shm.h>
30 #include <asm/tlbflush.h>
32 struct hugepage_subpool {
35 long max_hpages; /* Maximum huge pages or -1 if no maximum. */
36 long used_hpages; /* Used count against maximum, includes */
37 /* both alloced and reserved pages. */
38 struct hstate *hstate;
39 long min_hpages; /* Minimum huge pages or -1 if no minimum. */
40 long rsv_hpages; /* Pages reserved against global pool to */
41 /* sasitfy minimum size. */
47 struct list_head regions;
48 long adds_in_progress;
49 struct list_head region_cache;
50 long region_cache_count;
51 #ifdef CONFIG_CGROUP_HUGETLB
53 * On private mappings, the counter to uncharge reservations is stored
54 * here. If these fields are 0, then either the mapping is shared, or
55 * cgroup accounting is disabled for this resv_map.
57 struct page_counter *reservation_counter;
58 unsigned long pages_per_hpage;
59 struct cgroup_subsys_state *css;
64 * Region tracking -- allows tracking of reservations and instantiated pages
65 * across the pages in a mapping.
67 * The region data structures are embedded into a resv_map and protected
68 * by a resv_map's lock. The set of regions within the resv_map represent
69 * reservations for huge pages, or huge pages that have already been
70 * instantiated within the map. The from and to elements are huge page
71 * indicies into the associated mapping. from indicates the starting index
72 * of the region. to represents the first index past the end of the region.
74 * For example, a file region structure with from == 0 and to == 4 represents
75 * four huge pages in a mapping. It is important to note that the to element
76 * represents the first element past the end of the region. This is used in
77 * arithmetic as 4(to) - 0(from) = 4 huge pages in the region.
79 * Interval notation of the form [from, to) will be used to indicate that
80 * the endpoint from is inclusive and to is exclusive.
83 struct list_head link;
86 #ifdef CONFIG_CGROUP_HUGETLB
88 * On shared mappings, each reserved region appears as a struct
89 * file_region in resv_map. These fields hold the info needed to
90 * uncharge each reservation.
92 struct page_counter *reservation_counter;
93 struct cgroup_subsys_state *css;
97 extern struct resv_map *resv_map_alloc(void);
98 void resv_map_release(struct kref *ref);
100 extern spinlock_t hugetlb_lock;
101 extern int hugetlb_max_hstate __read_mostly;
102 #define for_each_hstate(h) \
103 for ((h) = hstates; (h) < &hstates[hugetlb_max_hstate]; (h)++)
105 struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages,
107 void hugepage_put_subpool(struct hugepage_subpool *spool);
109 void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
110 int hugetlb_sysctl_handler(struct ctl_table *, int, void *, size_t *, loff_t *);
111 int hugetlb_overcommit_handler(struct ctl_table *, int, void *, size_t *,
113 int hugetlb_treat_movable_handler(struct ctl_table *, int, void *, size_t *,
115 int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int, void *, size_t *,
118 int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
119 long follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *,
120 struct page **, struct vm_area_struct **,
121 unsigned long *, unsigned long *, long, unsigned int,
123 void unmap_hugepage_range(struct vm_area_struct *,
124 unsigned long, unsigned long, struct page *);
125 void __unmap_hugepage_range_final(struct mmu_gather *tlb,
126 struct vm_area_struct *vma,
127 unsigned long start, unsigned long end,
128 struct page *ref_page);
129 void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
130 unsigned long start, unsigned long end,
131 struct page *ref_page);
132 void hugetlb_report_meminfo(struct seq_file *);
133 int hugetlb_report_node_meminfo(char *buf, int len, int nid);
134 void hugetlb_show_meminfo(void);
135 unsigned long hugetlb_total_pages(void);
136 vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
137 unsigned long address, unsigned int flags);
138 int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte,
139 struct vm_area_struct *dst_vma,
140 unsigned long dst_addr,
141 unsigned long src_addr,
142 struct page **pagep);
143 bool hugetlb_reserve_pages(struct inode *inode, long from, long to,
144 struct vm_area_struct *vma,
145 vm_flags_t vm_flags);
146 long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
148 int isolate_hugetlb(struct page *page, struct list_head *list);
149 void putback_active_hugepage(struct page *page);
150 void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason);
151 void free_huge_page(struct page *page);
152 void hugetlb_fix_reserve_counts(struct inode *inode);
153 extern struct mutex *hugetlb_fault_mutex_table;
154 u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx);
156 pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
158 struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage);
160 extern int sysctl_hugetlb_shm_group;
161 extern struct list_head huge_boot_pages;
165 pte_t *huge_pte_alloc(struct mm_struct *mm,
166 unsigned long addr, unsigned long sz);
167 pte_t *huge_pte_offset(struct mm_struct *mm,
168 unsigned long addr, unsigned long sz);
169 int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,
170 unsigned long *addr, pte_t *ptep);
171 void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
172 unsigned long *start, unsigned long *end);
173 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
175 struct page *follow_huge_pd(struct vm_area_struct *vma,
176 unsigned long address, hugepd_t hpd,
177 int flags, int pdshift);
178 struct page *follow_huge_pmd_pte(struct vm_area_struct *vma, unsigned long address,
180 struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address,
181 pud_t *pud, int flags);
182 struct page *follow_huge_pgd(struct mm_struct *mm, unsigned long address,
183 pgd_t *pgd, int flags);
185 int pmd_huge(pmd_t pmd);
186 int pud_huge(pud_t pud);
187 unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
188 unsigned long address, unsigned long end, pgprot_t newprot);
190 bool is_hugetlb_entry_migration(pte_t pte);
192 #else /* !CONFIG_HUGETLB_PAGE */
194 static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
198 static inline unsigned long hugetlb_total_pages(void)
203 static inline struct address_space *hugetlb_page_mapping_lock_write(
209 static inline int huge_pmd_unshare(struct mm_struct *mm,
210 struct vm_area_struct *vma,
211 unsigned long *addr, pte_t *ptep)
216 static inline void adjust_range_if_pmd_sharing_possible(
217 struct vm_area_struct *vma,
218 unsigned long *start, unsigned long *end)
222 static inline long follow_hugetlb_page(struct mm_struct *mm,
223 struct vm_area_struct *vma, struct page **pages,
224 struct vm_area_struct **vmas, unsigned long *position,
225 unsigned long *nr_pages, long i, unsigned int flags,
232 static inline struct page *follow_huge_addr(struct mm_struct *mm,
233 unsigned long address, int write)
235 return ERR_PTR(-EINVAL);
238 static inline int copy_hugetlb_page_range(struct mm_struct *dst,
239 struct mm_struct *src, struct vm_area_struct *vma)
245 static inline void hugetlb_report_meminfo(struct seq_file *m)
249 static inline int hugetlb_report_node_meminfo(char *buf, int len, int nid)
254 static inline void hugetlb_show_meminfo(void)
258 static inline struct page *follow_huge_pd(struct vm_area_struct *vma,
259 unsigned long address, hugepd_t hpd, int flags,
265 static inline struct page *follow_huge_pmd_pte(struct vm_area_struct *vma,
266 unsigned long address, int flags)
271 static inline struct page *follow_huge_pud(struct mm_struct *mm,
272 unsigned long address, pud_t *pud, int flags)
277 static inline struct page *follow_huge_pgd(struct mm_struct *mm,
278 unsigned long address, pgd_t *pgd, int flags)
283 static inline int prepare_hugepage_range(struct file *file,
284 unsigned long addr, unsigned long len)
289 static inline int pmd_huge(pmd_t pmd)
294 static inline int pud_huge(pud_t pud)
299 static inline int is_hugepage_only_range(struct mm_struct *mm,
300 unsigned long addr, unsigned long len)
305 static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
306 unsigned long addr, unsigned long end,
307 unsigned long floor, unsigned long ceiling)
312 static inline int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
314 struct vm_area_struct *dst_vma,
315 unsigned long dst_addr,
316 unsigned long src_addr,
323 static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,
329 static inline int isolate_hugetlb(struct page *page, struct list_head *list)
334 static inline void putback_active_hugepage(struct page *page)
338 static inline void move_hugetlb_state(struct page *oldpage,
339 struct page *newpage, int reason)
343 static inline unsigned long hugetlb_change_protection(
344 struct vm_area_struct *vma, unsigned long address,
345 unsigned long end, pgprot_t newprot)
350 static inline void __unmap_hugepage_range_final(struct mmu_gather *tlb,
351 struct vm_area_struct *vma, unsigned long start,
352 unsigned long end, struct page *ref_page)
357 static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
358 struct vm_area_struct *vma, unsigned long start,
359 unsigned long end, struct page *ref_page)
364 static inline vm_fault_t hugetlb_fault(struct mm_struct *mm,
365 struct vm_area_struct *vma, unsigned long address,
372 #endif /* !CONFIG_HUGETLB_PAGE */
374 * hugepages at page global directory. If arch support
375 * hugepages at pgd level, they need to define this.
378 #define pgd_huge(x) 0
381 #define p4d_huge(x) 0
385 static inline int pgd_write(pgd_t pgd)
392 #define HUGETLB_ANON_FILE "anon_hugepage"
396 * The file will be used as an shm file so shmfs accounting rules
399 HUGETLB_SHMFS_INODE = 1,
401 * The file is being created on the internal vfs mount and shmfs
402 * accounting rules do not apply
404 HUGETLB_ANONHUGE_INODE = 2,
407 #ifdef CONFIG_HUGETLBFS
408 struct hugetlbfs_sb_info {
409 long max_inodes; /* inodes allowed */
410 long free_inodes; /* inodes free */
411 spinlock_t stat_lock;
412 struct hstate *hstate;
413 struct hugepage_subpool *spool;
419 static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
421 return sb->s_fs_info;
424 struct hugetlbfs_inode_info {
425 struct shared_policy policy;
426 struct inode vfs_inode;
430 static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
432 return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
435 extern const struct file_operations hugetlbfs_file_operations;
436 extern const struct vm_operations_struct hugetlb_vm_ops;
437 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
438 struct user_struct **user, int creat_flags,
441 static inline bool is_file_hugepages(struct file *file)
443 if (file->f_op == &hugetlbfs_file_operations)
446 return is_file_shm_hugepages(file);
449 static inline struct hstate *hstate_inode(struct inode *i)
451 return HUGETLBFS_SB(i->i_sb)->hstate;
453 #else /* !CONFIG_HUGETLBFS */
455 #define is_file_hugepages(file) false
456 static inline struct file *
457 hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
458 struct user_struct **user, int creat_flags,
461 return ERR_PTR(-ENOSYS);
464 static inline struct hstate *hstate_inode(struct inode *i)
468 #endif /* !CONFIG_HUGETLBFS */
470 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
471 unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
472 unsigned long len, unsigned long pgoff,
473 unsigned long flags);
474 #endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */
476 #ifdef CONFIG_HUGETLB_PAGE
478 #define HSTATE_NAME_LEN 32
479 /* Defines one hugetlb page size */
481 int next_nid_to_alloc;
482 int next_nid_to_free;
485 unsigned long max_huge_pages;
486 unsigned long nr_huge_pages;
487 unsigned long free_huge_pages;
488 unsigned long resv_huge_pages;
489 unsigned long surplus_huge_pages;
490 unsigned long nr_overcommit_huge_pages;
491 struct list_head hugepage_activelist;
492 struct list_head hugepage_freelists[MAX_NUMNODES];
493 unsigned int nr_huge_pages_node[MAX_NUMNODES];
494 unsigned int free_huge_pages_node[MAX_NUMNODES];
495 unsigned int surplus_huge_pages_node[MAX_NUMNODES];
496 #ifdef CONFIG_CGROUP_HUGETLB
497 /* cgroup control files */
498 struct cftype cgroup_files_dfl[7];
499 struct cftype cgroup_files_legacy[9];
501 char name[HSTATE_NAME_LEN];
504 struct huge_bootmem_page {
505 struct list_head list;
506 struct hstate *hstate;
509 struct page *alloc_huge_page(struct vm_area_struct *vma,
510 unsigned long addr, int avoid_reserve);
511 struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid,
512 nodemask_t *nmask, gfp_t gfp_mask);
513 struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
514 unsigned long address);
515 int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
519 int __init __alloc_bootmem_huge_page(struct hstate *h);
520 int __init alloc_bootmem_huge_page(struct hstate *h);
522 void __init hugetlb_add_hstate(unsigned order);
523 bool __init arch_hugetlb_valid_size(unsigned long size);
524 struct hstate *size_to_hstate(unsigned long size);
526 #ifndef HUGE_MAX_HSTATE
527 #define HUGE_MAX_HSTATE 1
530 extern struct hstate hstates[HUGE_MAX_HSTATE];
531 extern unsigned int default_hstate_idx;
533 #define default_hstate (hstates[default_hstate_idx])
535 static inline struct hstate *hstate_file(struct file *f)
537 return hstate_inode(file_inode(f));
540 static inline struct hstate *hstate_sizelog(int page_size_log)
543 return &default_hstate;
545 if (page_size_log < BITS_PER_LONG)
546 return size_to_hstate(1UL << page_size_log);
551 static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
553 return hstate_file(vma->vm_file);
556 static inline unsigned long huge_page_size(struct hstate *h)
558 return (unsigned long)PAGE_SIZE << h->order;
561 extern unsigned long vma_kernel_pagesize(struct vm_area_struct *vma);
563 extern unsigned long vma_mmu_pagesize(struct vm_area_struct *vma);
565 static inline unsigned long huge_page_mask(struct hstate *h)
570 static inline unsigned int huge_page_order(struct hstate *h)
575 static inline unsigned huge_page_shift(struct hstate *h)
577 return h->order + PAGE_SHIFT;
580 static inline bool hstate_is_gigantic(struct hstate *h)
582 return huge_page_order(h) >= MAX_ORDER;
585 static inline unsigned int pages_per_huge_page(struct hstate *h)
587 return 1 << h->order;
590 static inline unsigned int blocks_per_huge_page(struct hstate *h)
592 return huge_page_size(h) / 512;
595 #include <asm/hugetlb.h>
597 #ifndef is_hugepage_only_range
598 static inline int is_hugepage_only_range(struct mm_struct *mm,
599 unsigned long addr, unsigned long len)
603 #define is_hugepage_only_range is_hugepage_only_range
606 #ifndef arch_clear_hugepage_flags
607 static inline void arch_clear_hugepage_flags(struct page *page) { }
608 #define arch_clear_hugepage_flags arch_clear_hugepage_flags
611 #ifndef arch_make_huge_pte
612 static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
613 struct page *page, int writable)
619 static inline struct hstate *page_hstate(struct page *page)
621 VM_BUG_ON_PAGE(!PageHuge(page), page);
622 return size_to_hstate(page_size(page));
625 static inline unsigned hstate_index_to_shift(unsigned index)
627 return hstates[index].order + PAGE_SHIFT;
630 static inline int hstate_index(struct hstate *h)
635 extern int dissolve_free_huge_page(struct page *page);
636 extern int dissolve_free_huge_pages(unsigned long start_pfn,
637 unsigned long end_pfn);
639 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
640 #ifndef arch_hugetlb_migration_supported
641 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
643 if ((huge_page_shift(h) == PMD_SHIFT) ||
644 (huge_page_shift(h) == PUD_SHIFT) ||
645 (huge_page_shift(h) == PGDIR_SHIFT))
652 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
658 static inline bool hugepage_migration_supported(struct hstate *h)
660 return arch_hugetlb_migration_supported(h);
664 * Movability check is different as compared to migration check.
665 * It determines whether or not a huge page should be placed on
666 * movable zone or not. Movability of any huge page should be
667 * required only if huge page size is supported for migration.
668 * There wont be any reason for the huge page to be movable if
669 * it is not migratable to start with. Also the size of the huge
670 * page should be large enough to be placed under a movable zone
671 * and still feasible enough to be migratable. Just the presence
672 * in movable zone does not make the migration feasible.
674 * So even though large huge page sizes like the gigantic ones
675 * are migratable they should not be movable because its not
676 * feasible to migrate them from movable zone.
678 static inline bool hugepage_movable_supported(struct hstate *h)
680 if (!hugepage_migration_supported(h))
683 if (hstate_is_gigantic(h))
688 /* Movability of hugepages depends on migration support. */
689 static inline gfp_t htlb_alloc_mask(struct hstate *h)
691 if (hugepage_movable_supported(h))
692 return GFP_HIGHUSER_MOVABLE;
697 static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)
699 gfp_t modified_mask = htlb_alloc_mask(h);
701 /* Some callers might want to enforce node */
702 modified_mask |= (gfp_mask & __GFP_THISNODE);
704 modified_mask |= (gfp_mask & __GFP_NOWARN);
706 return modified_mask;
709 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
710 struct mm_struct *mm, pte_t *pte)
712 if (huge_page_size(h) == PMD_SIZE)
713 return pmd_lockptr(mm, (pmd_t *) pte);
714 VM_BUG_ON(huge_page_size(h) == PAGE_SIZE);
715 return &mm->page_table_lock;
718 #ifndef hugepages_supported
720 * Some platform decide whether they support huge pages at boot
721 * time. Some of them, such as powerpc, set HPAGE_SHIFT to 0
722 * when there is no such support
724 #define hugepages_supported() (HPAGE_SHIFT != 0)
727 void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm);
729 static inline void hugetlb_count_init(struct mm_struct *mm)
731 atomic_long_set(&mm->hugetlb_usage, 0);
734 static inline void hugetlb_count_add(long l, struct mm_struct *mm)
736 atomic_long_add(l, &mm->hugetlb_usage);
739 static inline void hugetlb_count_sub(long l, struct mm_struct *mm)
741 atomic_long_sub(l, &mm->hugetlb_usage);
744 #ifndef set_huge_swap_pte_at
745 static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr,
746 pte_t *ptep, pte_t pte, unsigned long sz)
748 set_huge_pte_at(mm, addr, ptep, pte);
752 #ifndef huge_ptep_modify_prot_start
753 #define huge_ptep_modify_prot_start huge_ptep_modify_prot_start
754 static inline pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,
755 unsigned long addr, pte_t *ptep)
757 return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
761 #ifndef huge_ptep_modify_prot_commit
762 #define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit
763 static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
764 unsigned long addr, pte_t *ptep,
765 pte_t old_pte, pte_t pte)
767 set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
771 void set_page_huge_active(struct page *page);
773 #else /* CONFIG_HUGETLB_PAGE */
776 static inline struct page *alloc_huge_page(struct vm_area_struct *vma,
783 static inline struct page *
784 alloc_huge_page_nodemask(struct hstate *h, int preferred_nid,
785 nodemask_t *nmask, gfp_t gfp_mask)
790 static inline struct page *alloc_huge_page_vma(struct hstate *h,
791 struct vm_area_struct *vma,
792 unsigned long address)
797 static inline int __alloc_bootmem_huge_page(struct hstate *h)
802 static inline struct hstate *hstate_file(struct file *f)
807 static inline struct hstate *hstate_sizelog(int page_size_log)
812 static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
817 static inline struct hstate *page_hstate(struct page *page)
822 static inline unsigned long huge_page_size(struct hstate *h)
827 static inline unsigned long huge_page_mask(struct hstate *h)
832 static inline unsigned long vma_kernel_pagesize(struct vm_area_struct *vma)
837 static inline unsigned long vma_mmu_pagesize(struct vm_area_struct *vma)
842 static inline unsigned int huge_page_order(struct hstate *h)
847 static inline unsigned int huge_page_shift(struct hstate *h)
852 static inline bool hstate_is_gigantic(struct hstate *h)
857 static inline unsigned int pages_per_huge_page(struct hstate *h)
862 static inline unsigned hstate_index_to_shift(unsigned index)
867 static inline int hstate_index(struct hstate *h)
872 static inline int dissolve_free_huge_page(struct page *page)
877 static inline int dissolve_free_huge_pages(unsigned long start_pfn,
878 unsigned long end_pfn)
883 static inline bool hugepage_migration_supported(struct hstate *h)
888 static inline bool hugepage_movable_supported(struct hstate *h)
893 static inline gfp_t htlb_alloc_mask(struct hstate *h)
898 static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)
903 static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
904 struct mm_struct *mm, pte_t *pte)
906 return &mm->page_table_lock;
909 static inline void hugetlb_count_init(struct mm_struct *mm)
913 static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m)
917 static inline void hugetlb_count_sub(long l, struct mm_struct *mm)
921 static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr,
922 pte_t *ptep, pte_t pte, unsigned long sz)
925 #endif /* CONFIG_HUGETLB_PAGE */
927 static inline spinlock_t *huge_pte_lock(struct hstate *h,
928 struct mm_struct *mm, pte_t *pte)
932 ptl = huge_pte_lockptr(h, mm, pte);
937 #if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA)
938 extern void __init hugetlb_cma_reserve(int order);
939 extern void __init hugetlb_cma_check(void);
941 static inline __init void hugetlb_cma_reserve(int order)
944 static inline __init void hugetlb_cma_check(void)
949 #ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
950 static inline bool hugetlb_pmd_shared(pte_t *pte)
952 return page_count(virt_to_page(pte)) > 1;
955 static inline bool hugetlb_pmd_shared(pte_t *pte)
961 #endif /* _LINUX_HUGETLB_H */