Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 2 | #ifndef _LINUX_HUGE_MM_H |
| 3 | #define _LINUX_HUGE_MM_H |
| 4 | |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 5 | #include <linux/sched/coredump.h> |
Dan Williams | 226ab56 | 2018-07-13 21:49:34 -0700 | [diff] [blame] | 6 | #include <linux/mm_types.h> |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 7 | |
Dan Williams | baabda2 | 2017-07-10 15:48:25 -0700 | [diff] [blame] | 8 | #include <linux/fs.h> /* only for vma_is_dax() */ |
| 9 | |
Souptick Joarder | 2b74030 | 2018-08-23 17:01:36 -0700 | [diff] [blame] | 10 | extern vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf); |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 11 | extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, |
| 12 | pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr, |
| 13 | struct vm_area_struct *vma); |
Jan Kara | 82b0f8c | 2016-12-14 15:06:58 -0800 | [diff] [blame] | 14 | extern void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd); |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 15 | extern int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, |
| 16 | pud_t *dst_pud, pud_t *src_pud, unsigned long addr, |
| 17 | struct vm_area_struct *vma); |
| 18 | |
| 19 | #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD |
| 20 | extern void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud); |
| 21 | #else |
| 22 | static inline void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) |
| 23 | { |
| 24 | } |
| 25 | #endif |
| 26 | |
Souptick Joarder | 2b74030 | 2018-08-23 17:01:36 -0700 | [diff] [blame] | 27 | extern vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd); |
David Rientjes | b676b29 | 2012-10-08 16:34:03 -0700 | [diff] [blame] | 28 | extern struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 29 | unsigned long addr, |
| 30 | pmd_t *pmd, |
| 31 | unsigned int flags); |
Huang Ying | 319904a | 2016-07-28 15:48:03 -0700 | [diff] [blame] | 32 | extern bool madvise_free_huge_pmd(struct mmu_gather *tlb, |
Minchan Kim | b8d3c4c | 2016-01-15 16:55:42 -0800 | [diff] [blame] | 33 | struct vm_area_struct *vma, |
| 34 | pmd_t *pmd, unsigned long addr, unsigned long next); |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 35 | extern int zap_huge_pmd(struct mmu_gather *tlb, |
| 36 | struct vm_area_struct *vma, |
Shaohua Li | f21760b | 2012-01-12 17:19:16 -0800 | [diff] [blame] | 37 | pmd_t *pmd, unsigned long addr); |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 38 | extern int zap_huge_pud(struct mmu_gather *tlb, |
| 39 | struct vm_area_struct *vma, |
| 40 | pud_t *pud, unsigned long addr); |
Johannes Weiner | 0ca1634 | 2011-01-13 15:47:02 -0800 | [diff] [blame] | 41 | extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 42 | unsigned long addr, unsigned long end, |
| 43 | unsigned char *vec); |
Hugh Dickins | bf8616d | 2016-05-19 17:12:54 -0700 | [diff] [blame] | 44 | extern bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, |
Andrea Arcangeli | 37a1c49 | 2011-10-31 17:08:30 -0700 | [diff] [blame] | 45 | unsigned long new_addr, unsigned long old_end, |
Linus Torvalds | eb66ae0 | 2018-10-12 15:22:59 -0700 | [diff] [blame] | 46 | pmd_t *old_pmd, pmd_t *new_pmd); |
Johannes Weiner | cd7548a | 2011-01-13 15:47:04 -0800 | [diff] [blame] | 47 | extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
Mel Gorman | 4b10e7d | 2012-10-25 14:16:32 +0200 | [diff] [blame] | 48 | unsigned long addr, pgprot_t newprot, |
| 49 | int prot_numa); |
Dan Williams | fce86ff | 2019-05-13 17:15:33 -0700 | [diff] [blame] | 50 | vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); |
| 51 | vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 52 | enum transparent_hugepage_flag { |
| 53 | TRANSPARENT_HUGEPAGE_FLAG, |
| 54 | TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, |
Mel Gorman | 444eb2a4 | 2016-03-17 14:19:23 -0700 | [diff] [blame] | 55 | TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, |
| 56 | TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, |
David Rientjes | 21440d7 | 2017-02-22 15:45:49 -0800 | [diff] [blame] | 57 | TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 58 | TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, |
Andrea Arcangeli | ba76149 | 2011-01-13 15:46:58 -0800 | [diff] [blame] | 59 | TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG, |
Kirill A. Shutemov | 79da540 | 2012-12-12 13:51:12 -0800 | [diff] [blame] | 60 | TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG, |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 61 | #ifdef CONFIG_DEBUG_VM |
| 62 | TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG, |
| 63 | #endif |
| 64 | }; |
| 65 | |
Kirill A. Shutemov | b46e756 | 2016-07-26 15:26:24 -0700 | [diff] [blame] | 66 | struct kobject; |
| 67 | struct kobj_attribute; |
| 68 | |
| 69 | extern ssize_t single_hugepage_flag_store(struct kobject *kobj, |
| 70 | struct kobj_attribute *attr, |
| 71 | const char *buf, size_t count, |
| 72 | enum transparent_hugepage_flag flag); |
| 73 | extern ssize_t single_hugepage_flag_show(struct kobject *kobj, |
| 74 | struct kobj_attribute *attr, char *buf, |
| 75 | enum transparent_hugepage_flag flag); |
Kirill A. Shutemov | 5a6e75f | 2016-07-26 15:26:13 -0700 | [diff] [blame] | 76 | extern struct kobj_attribute shmem_enabled_attr; |
| 77 | |
Naoya Horiguchi | d8c37c4 | 2012-03-21 16:34:27 -0700 | [diff] [blame] | 78 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) |
| 79 | #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) |
| 80 | |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 81 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
Aneesh Kumar K.V | fde5279 | 2013-06-05 17:14:05 -0700 | [diff] [blame] | 82 | #define HPAGE_PMD_SHIFT PMD_SHIFT |
| 83 | #define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) |
| 84 | #define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1)) |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 85 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 86 | #define HPAGE_PUD_SHIFT PUD_SHIFT |
| 87 | #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) |
| 88 | #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) |
| 89 | |
Alex Shi | 2099597 | 2012-05-29 15:06:31 -0700 | [diff] [blame] | 90 | extern bool is_vma_temporary_stack(struct vm_area_struct *vma); |
| 91 | |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 92 | extern unsigned long transparent_hugepage_flags; |
| 93 | |
Michal Hocko | 7635d9c | 2018-12-28 00:38:21 -0800 | [diff] [blame] | 94 | /* |
| 95 | * to be used on vmas which are known to support THP. |
| 96 | * Use transparent_hugepage_enabled otherwise |
| 97 | */ |
| 98 | static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 99 | { |
| 100 | if (vma->vm_flags & VM_NOHUGEPAGE) |
| 101 | return false; |
| 102 | |
| 103 | if (is_vma_temporary_stack(vma)) |
| 104 | return false; |
| 105 | |
| 106 | if (test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags)) |
| 107 | return false; |
| 108 | |
| 109 | if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG)) |
| 110 | return true; |
| 111 | |
Dan Williams | baabda2 | 2017-07-10 15:48:25 -0700 | [diff] [blame] | 112 | if (vma_is_dax(vma)) |
| 113 | return true; |
| 114 | |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 115 | if (transparent_hugepage_flags & |
| 116 | (1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)) |
| 117 | return !!(vma->vm_flags & VM_HUGEPAGE); |
| 118 | |
| 119 | return false; |
| 120 | } |
| 121 | |
Michal Hocko | 7635d9c | 2018-12-28 00:38:21 -0800 | [diff] [blame] | 122 | bool transparent_hugepage_enabled(struct vm_area_struct *vma); |
| 123 | |
Yang Shi | 43675e6 | 2019-07-18 15:57:24 -0700 | [diff] [blame] | 124 | #define HPAGE_CACHE_INDEX_MASK (HPAGE_PMD_NR - 1) |
| 125 | |
| 126 | static inline bool transhuge_vma_suitable(struct vm_area_struct *vma, |
| 127 | unsigned long haddr) |
| 128 | { |
| 129 | /* Don't have to check pgoff for anonymous vma */ |
| 130 | if (!vma_is_anonymous(vma)) { |
| 131 | if (((vma->vm_start >> PAGE_SHIFT) & HPAGE_CACHE_INDEX_MASK) != |
| 132 | (vma->vm_pgoff & HPAGE_CACHE_INDEX_MASK)) |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | if (haddr < vma->vm_start || haddr + HPAGE_PMD_SIZE > vma->vm_end) |
| 137 | return false; |
| 138 | return true; |
| 139 | } |
| 140 | |
Kirill A. Shutemov | 79da540 | 2012-12-12 13:51:12 -0800 | [diff] [blame] | 141 | #define transparent_hugepage_use_zero_page() \ |
| 142 | (transparent_hugepage_flags & \ |
| 143 | (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG)) |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 144 | #ifdef CONFIG_DEBUG_VM |
| 145 | #define transparent_hugepage_debug_cow() \ |
| 146 | (transparent_hugepage_flags & \ |
| 147 | (1<<TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG)) |
| 148 | #else /* CONFIG_DEBUG_VM */ |
| 149 | #define transparent_hugepage_debug_cow() 0 |
| 150 | #endif /* CONFIG_DEBUG_VM */ |
| 151 | |
Toshi Kani | 74d2fad | 2016-10-07 16:59:56 -0700 | [diff] [blame] | 152 | extern unsigned long thp_get_unmapped_area(struct file *filp, |
| 153 | unsigned long addr, unsigned long len, unsigned long pgoff, |
| 154 | unsigned long flags); |
| 155 | |
Kirill A. Shutemov | 9a98225 | 2016-01-15 16:54:17 -0800 | [diff] [blame] | 156 | extern void prep_transhuge_page(struct page *page); |
| 157 | extern void free_transhuge_page(struct page *page); |
| 158 | |
Huang Ying | b8f593c | 2017-07-06 15:37:28 -0700 | [diff] [blame] | 159 | bool can_split_huge_page(struct page *page, int *pextra_pins); |
Kirill A. Shutemov | e9b61f1 | 2016-01-15 16:54:10 -0800 | [diff] [blame] | 160 | int split_huge_page_to_list(struct page *page, struct list_head *list); |
| 161 | static inline int split_huge_page(struct page *page) |
| 162 | { |
| 163 | return split_huge_page_to_list(page, NULL); |
| 164 | } |
Kirill A. Shutemov | 9a98225 | 2016-01-15 16:54:17 -0800 | [diff] [blame] | 165 | void deferred_split_huge_page(struct page *page); |
Kirill A. Shutemov | eef1b3b | 2016-01-15 16:53:53 -0800 | [diff] [blame] | 166 | |
| 167 | void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
Naoya Horiguchi | 33f4751 | 2016-07-14 12:07:32 -0700 | [diff] [blame] | 168 | unsigned long address, bool freeze, struct page *page); |
Kirill A. Shutemov | eef1b3b | 2016-01-15 16:53:53 -0800 | [diff] [blame] | 169 | |
| 170 | #define split_huge_pmd(__vma, __pmd, __address) \ |
| 171 | do { \ |
| 172 | pmd_t *____pmd = (__pmd); \ |
Zi Yan | 84c3fc4 | 2017-09-08 16:11:01 -0700 | [diff] [blame] | 173 | if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd) \ |
Dan Williams | 5c7fb56 | 2016-01-15 16:56:52 -0800 | [diff] [blame] | 174 | || pmd_devmap(*____pmd)) \ |
Kirill A. Shutemov | fec89c1 | 2016-03-17 14:20:10 -0700 | [diff] [blame] | 175 | __split_huge_pmd(__vma, __pmd, __address, \ |
Naoya Horiguchi | 33f4751 | 2016-07-14 12:07:32 -0700 | [diff] [blame] | 176 | false, NULL); \ |
Kirill A. Shutemov | eef1b3b | 2016-01-15 16:53:53 -0800 | [diff] [blame] | 177 | } while (0) |
Kirill A. Shutemov | ad0bed2 | 2016-01-15 16:52:53 -0800 | [diff] [blame] | 178 | |
Kirill A. Shutemov | 2a52bcb | 2016-03-17 14:20:04 -0700 | [diff] [blame] | 179 | |
Kirill A. Shutemov | fec89c1 | 2016-03-17 14:20:10 -0700 | [diff] [blame] | 180 | void split_huge_pmd_address(struct vm_area_struct *vma, unsigned long address, |
| 181 | bool freeze, struct page *page); |
Kirill A. Shutemov | 2a52bcb | 2016-03-17 14:20:04 -0700 | [diff] [blame] | 182 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 183 | void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud, |
| 184 | unsigned long address); |
| 185 | |
| 186 | #define split_huge_pud(__vma, __pud, __address) \ |
| 187 | do { \ |
| 188 | pud_t *____pud = (__pud); \ |
| 189 | if (pud_trans_huge(*____pud) \ |
| 190 | || pud_devmap(*____pud)) \ |
| 191 | __split_huge_pud(__vma, __pud, __address); \ |
| 192 | } while (0) |
| 193 | |
Andrea Arcangeli | 60ab324 | 2011-01-13 15:47:18 -0800 | [diff] [blame] | 194 | extern int hugepage_madvise(struct vm_area_struct *vma, |
| 195 | unsigned long *vm_flags, int advice); |
Kirill A. Shutemov | e1b9996 | 2015-09-08 14:58:37 -0700 | [diff] [blame] | 196 | extern void vma_adjust_trans_huge(struct vm_area_struct *vma, |
Andrea Arcangeli | 94fcc58 | 2011-01-13 15:47:08 -0800 | [diff] [blame] | 197 | unsigned long start, |
| 198 | unsigned long end, |
| 199 | long adjust_next); |
Kirill A. Shutemov | b6ec57f | 2016-01-21 16:40:25 -0800 | [diff] [blame] | 200 | extern spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, |
| 201 | struct vm_area_struct *vma); |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 202 | extern spinlock_t *__pud_trans_huge_lock(pud_t *pud, |
| 203 | struct vm_area_struct *vma); |
Zi Yan | 84c3fc4 | 2017-09-08 16:11:01 -0700 | [diff] [blame] | 204 | |
| 205 | static inline int is_swap_pmd(pmd_t pmd) |
| 206 | { |
| 207 | return !pmd_none(pmd) && !pmd_present(pmd); |
| 208 | } |
| 209 | |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 210 | /* mmap_sem must be held on entry */ |
Kirill A. Shutemov | b6ec57f | 2016-01-21 16:40:25 -0800 | [diff] [blame] | 211 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, |
| 212 | struct vm_area_struct *vma) |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 213 | { |
Sasha Levin | 81d1b09 | 2014-10-09 15:28:10 -0700 | [diff] [blame] | 214 | VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma); |
Zi Yan | 84c3fc4 | 2017-09-08 16:11:01 -0700 | [diff] [blame] | 215 | if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) |
Kirill A. Shutemov | b6ec57f | 2016-01-21 16:40:25 -0800 | [diff] [blame] | 216 | return __pmd_trans_huge_lock(pmd, vma); |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 217 | else |
Chen Gang | 969e8d7 | 2016-04-01 14:31:17 -0700 | [diff] [blame] | 218 | return NULL; |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 219 | } |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 220 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, |
| 221 | struct vm_area_struct *vma) |
| 222 | { |
| 223 | VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma); |
| 224 | if (pud_trans_huge(*pud) || pud_devmap(*pud)) |
| 225 | return __pud_trans_huge_lock(pud, vma); |
| 226 | else |
| 227 | return NULL; |
| 228 | } |
Rik van Riel | 2c888cf | 2011-01-13 15:47:13 -0800 | [diff] [blame] | 229 | static inline int hpage_nr_pages(struct page *page) |
| 230 | { |
| 231 | if (unlikely(PageTransHuge(page))) |
| 232 | return HPAGE_PMD_NR; |
| 233 | return 1; |
| 234 | } |
Mel Gorman | d10e63f | 2012-10-25 14:16:31 +0200 | [diff] [blame] | 235 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 236 | struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr, |
Keith Busch | df06b37 | 2018-10-26 15:10:28 -0700 | [diff] [blame] | 237 | pmd_t *pmd, int flags, struct dev_pagemap **pgmap); |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 238 | struct page *follow_devmap_pud(struct vm_area_struct *vma, unsigned long addr, |
Keith Busch | df06b37 | 2018-10-26 15:10:28 -0700 | [diff] [blame] | 239 | pud_t *pud, int flags, struct dev_pagemap **pgmap); |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 240 | |
Souptick Joarder | 2b74030 | 2018-08-23 17:01:36 -0700 | [diff] [blame] | 241 | extern vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t orig_pmd); |
Mel Gorman | d10e63f | 2012-10-25 14:16:31 +0200 | [diff] [blame] | 242 | |
Wang, Yalin | 56873f4 | 2015-02-11 15:24:51 -0800 | [diff] [blame] | 243 | extern struct page *huge_zero_page; |
| 244 | |
| 245 | static inline bool is_huge_zero_page(struct page *page) |
| 246 | { |
Mark Rutland | 6aa7de0 | 2017-10-23 14:07:29 -0700 | [diff] [blame] | 247 | return READ_ONCE(huge_zero_page) == page; |
Wang, Yalin | 56873f4 | 2015-02-11 15:24:51 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Matthew Wilcox | fc43704 | 2015-09-08 14:58:51 -0700 | [diff] [blame] | 250 | static inline bool is_huge_zero_pmd(pmd_t pmd) |
| 251 | { |
| 252 | return is_huge_zero_page(pmd_page(pmd)); |
| 253 | } |
| 254 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 255 | static inline bool is_huge_zero_pud(pud_t pud) |
| 256 | { |
| 257 | return false; |
| 258 | } |
| 259 | |
Aaron Lu | 6fcb52a | 2016-10-07 17:00:08 -0700 | [diff] [blame] | 260 | struct page *mm_get_huge_zero_page(struct mm_struct *mm); |
| 261 | void mm_put_huge_zero_page(struct mm_struct *mm); |
Matthew Wilcox | fc43704 | 2015-09-08 14:58:51 -0700 | [diff] [blame] | 262 | |
Kirill A. Shutemov | 1010245 | 2016-07-26 15:25:29 -0700 | [diff] [blame] | 263 | #define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot)) |
| 264 | |
Naoya Horiguchi | 9c670ea | 2017-09-08 16:10:53 -0700 | [diff] [blame] | 265 | static inline bool thp_migration_supported(void) |
| 266 | { |
| 267 | return IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION); |
| 268 | } |
| 269 | |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 270 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ |
Naoya Horiguchi | d8c37c4 | 2012-03-21 16:34:27 -0700 | [diff] [blame] | 271 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) |
| 272 | #define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) |
| 273 | #define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; }) |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 274 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 275 | #define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; }) |
| 276 | #define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; }) |
| 277 | #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; }) |
| 278 | |
Rik van Riel | 2c888cf | 2011-01-13 15:47:13 -0800 | [diff] [blame] | 279 | #define hpage_nr_pages(x) 1 |
| 280 | |
Michal Hocko | 7635d9c | 2018-12-28 00:38:21 -0800 | [diff] [blame] | 281 | static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) |
| 282 | { |
| 283 | return false; |
| 284 | } |
| 285 | |
Dan Williams | 16981d7 | 2017-07-10 15:48:22 -0700 | [diff] [blame] | 286 | static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) |
| 287 | { |
| 288 | return false; |
| 289 | } |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 290 | |
Yang Shi | 43675e6 | 2019-07-18 15:57:24 -0700 | [diff] [blame] | 291 | static inline bool transhuge_vma_suitable(struct vm_area_struct *vma, |
| 292 | unsigned long haddr) |
| 293 | { |
| 294 | return false; |
| 295 | } |
| 296 | |
Kirill A. Shutemov | 800d8c6 | 2016-07-26 15:26:18 -0700 | [diff] [blame] | 297 | static inline void prep_transhuge_page(struct page *page) {} |
| 298 | |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 299 | #define transparent_hugepage_flags 0UL |
Toshi Kani | 74d2fad | 2016-10-07 16:59:56 -0700 | [diff] [blame] | 300 | |
| 301 | #define thp_get_unmapped_area NULL |
| 302 | |
Huang Ying | b8f593c | 2017-07-06 15:37:28 -0700 | [diff] [blame] | 303 | static inline bool |
| 304 | can_split_huge_page(struct page *page, int *pextra_pins) |
| 305 | { |
| 306 | BUILD_BUG(); |
| 307 | return false; |
| 308 | } |
Shaohua Li | 5bc7b8a | 2013-04-29 15:08:36 -0700 | [diff] [blame] | 309 | static inline int |
| 310 | split_huge_page_to_list(struct page *page, struct list_head *list) |
| 311 | { |
| 312 | return 0; |
| 313 | } |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 314 | static inline int split_huge_page(struct page *page) |
| 315 | { |
| 316 | return 0; |
| 317 | } |
Kirill A. Shutemov | 9a98225 | 2016-01-15 16:54:17 -0800 | [diff] [blame] | 318 | static inline void deferred_split_huge_page(struct page *page) {} |
Kirill A. Shutemov | 78ddc53 | 2016-01-15 16:52:42 -0800 | [diff] [blame] | 319 | #define split_huge_pmd(__vma, __pmd, __address) \ |
Kirill A. Shutemov | e180377 | 2012-12-12 13:50:59 -0800 | [diff] [blame] | 320 | do { } while (0) |
Kirill A. Shutemov | 2a52bcb | 2016-03-17 14:20:04 -0700 | [diff] [blame] | 321 | |
David Rientjes | fd60775 | 2016-12-12 16:42:20 -0800 | [diff] [blame] | 322 | static inline void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
| 323 | unsigned long address, bool freeze, struct page *page) {} |
Kirill A. Shutemov | 2a52bcb | 2016-03-17 14:20:04 -0700 | [diff] [blame] | 324 | static inline void split_huge_pmd_address(struct vm_area_struct *vma, |
Kirill A. Shutemov | fec89c1 | 2016-03-17 14:20:10 -0700 | [diff] [blame] | 325 | unsigned long address, bool freeze, struct page *page) {} |
Kirill A. Shutemov | 2a52bcb | 2016-03-17 14:20:04 -0700 | [diff] [blame] | 326 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 327 | #define split_huge_pud(__vma, __pmd, __address) \ |
| 328 | do { } while (0) |
| 329 | |
Andrea Arcangeli | 60ab324 | 2011-01-13 15:47:18 -0800 | [diff] [blame] | 330 | static inline int hugepage_madvise(struct vm_area_struct *vma, |
| 331 | unsigned long *vm_flags, int advice) |
Andrea Arcangeli | 0af4e98 | 2011-01-13 15:46:55 -0800 | [diff] [blame] | 332 | { |
| 333 | BUG(); |
| 334 | return 0; |
| 335 | } |
Andrea Arcangeli | 94fcc58 | 2011-01-13 15:47:08 -0800 | [diff] [blame] | 336 | static inline void vma_adjust_trans_huge(struct vm_area_struct *vma, |
| 337 | unsigned long start, |
| 338 | unsigned long end, |
| 339 | long adjust_next) |
| 340 | { |
| 341 | } |
Zi Yan | 84c3fc4 | 2017-09-08 16:11:01 -0700 | [diff] [blame] | 342 | static inline int is_swap_pmd(pmd_t pmd) |
| 343 | { |
| 344 | return 0; |
| 345 | } |
Kirill A. Shutemov | b6ec57f | 2016-01-21 16:40:25 -0800 | [diff] [blame] | 346 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, |
| 347 | struct vm_area_struct *vma) |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 348 | { |
Kirill A. Shutemov | b6ec57f | 2016-01-21 16:40:25 -0800 | [diff] [blame] | 349 | return NULL; |
Naoya Horiguchi | 025c5b2 | 2012-03-21 16:33:57 -0700 | [diff] [blame] | 350 | } |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 351 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, |
| 352 | struct vm_area_struct *vma) |
| 353 | { |
| 354 | return NULL; |
| 355 | } |
Mel Gorman | d10e63f | 2012-10-25 14:16:31 +0200 | [diff] [blame] | 356 | |
Souptick Joarder | 2b74030 | 2018-08-23 17:01:36 -0700 | [diff] [blame] | 357 | static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf, |
| 358 | pmd_t orig_pmd) |
Mel Gorman | d10e63f | 2012-10-25 14:16:31 +0200 | [diff] [blame] | 359 | { |
Mel Gorman | 4daae3b | 2012-11-02 11:33:45 +0000 | [diff] [blame] | 360 | return 0; |
Mel Gorman | d10e63f | 2012-10-25 14:16:31 +0200 | [diff] [blame] | 361 | } |
| 362 | |
Wang, Yalin | 56873f4 | 2015-02-11 15:24:51 -0800 | [diff] [blame] | 363 | static inline bool is_huge_zero_page(struct page *page) |
| 364 | { |
| 365 | return false; |
| 366 | } |
| 367 | |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 368 | static inline bool is_huge_zero_pud(pud_t pud) |
| 369 | { |
| 370 | return false; |
| 371 | } |
| 372 | |
Aaron Lu | 6fcb52a | 2016-10-07 17:00:08 -0700 | [diff] [blame] | 373 | static inline void mm_put_huge_zero_page(struct mm_struct *mm) |
Kirill A. Shutemov | aa88b68 | 2016-04-28 16:18:27 -0700 | [diff] [blame] | 374 | { |
Aaron Lu | 6fcb52a | 2016-10-07 17:00:08 -0700 | [diff] [blame] | 375 | return; |
Kirill A. Shutemov | aa88b68 | 2016-04-28 16:18:27 -0700 | [diff] [blame] | 376 | } |
Dan Williams | 3565fce | 2016-01-15 16:56:55 -0800 | [diff] [blame] | 377 | |
| 378 | static inline struct page *follow_devmap_pmd(struct vm_area_struct *vma, |
Keith Busch | df06b37 | 2018-10-26 15:10:28 -0700 | [diff] [blame] | 379 | unsigned long addr, pmd_t *pmd, int flags, struct dev_pagemap **pgmap) |
Dan Williams | 3565fce | 2016-01-15 16:56:55 -0800 | [diff] [blame] | 380 | { |
| 381 | return NULL; |
| 382 | } |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 383 | |
| 384 | static inline struct page *follow_devmap_pud(struct vm_area_struct *vma, |
Keith Busch | df06b37 | 2018-10-26 15:10:28 -0700 | [diff] [blame] | 385 | unsigned long addr, pud_t *pud, int flags, struct dev_pagemap **pgmap) |
Matthew Wilcox | a00cc7d | 2017-02-24 14:57:02 -0800 | [diff] [blame] | 386 | { |
| 387 | return NULL; |
| 388 | } |
Naoya Horiguchi | 9c670ea | 2017-09-08 16:10:53 -0700 | [diff] [blame] | 389 | |
| 390 | static inline bool thp_migration_supported(void) |
| 391 | { |
| 392 | return false; |
| 393 | } |
Andrea Arcangeli | 71e3aac | 2011-01-13 15:46:52 -0800 | [diff] [blame] | 394 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
| 395 | |
| 396 | #endif /* _LINUX_HUGE_MM_H */ |