Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
71e3aac0 AA |
2 | #ifndef _LINUX_HUGE_MM_H |
3 | #define _LINUX_HUGE_MM_H | |
4 | ||
16981d76 | 5 | #include <linux/sched/coredump.h> |
226ab561 | 6 | #include <linux/mm_types.h> |
16981d76 | 7 | |
baabda26 DW |
8 | #include <linux/fs.h> /* only for vma_is_dax() */ |
9 | ||
ebfe1b8f RC |
10 | vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf); |
11 | 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, | |
8f34f1ea | 13 | struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma); |
5db4f15c | 14 | void huge_pmd_set_accessed(struct vm_fault *vmf); |
ebfe1b8f RC |
15 | 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); | |
a00cc7d9 MW |
18 | |
19 | #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD | |
ebfe1b8f | 20 | void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud); |
a00cc7d9 MW |
21 | #else |
22 | static inline void huge_pud_set_accessed(struct vm_fault *vmf, pud_t orig_pud) | |
23 | { | |
24 | } | |
25 | #endif | |
26 | ||
5db4f15c | 27 | vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf); |
ebfe1b8f RC |
28 | bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, |
29 | pmd_t *pmd, unsigned long addr, unsigned long next); | |
30 | int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, | |
31 | unsigned long addr); | |
32 | int zap_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma, pud_t *pud, | |
33 | unsigned long addr); | |
34 | bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, | |
35 | unsigned long new_addr, pmd_t *old_pmd, pmd_t *new_pmd); | |
4a18419f NA |
36 | int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, |
37 | pmd_t *pmd, unsigned long addr, pgprot_t newprot, | |
38 | unsigned long cp_flags); | |
9a9731b1 | 39 | |
7b806d22 LS |
40 | vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); |
41 | vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); | |
9a9731b1 | 42 | |
71e3aac0 | 43 | enum transparent_hugepage_flag { |
3c556d24 | 44 | TRANSPARENT_HUGEPAGE_UNSUPPORTED, |
71e3aac0 AA |
45 | TRANSPARENT_HUGEPAGE_FLAG, |
46 | TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, | |
444eb2a4 MG |
47 | TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, |
48 | TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, | |
21440d7e | 49 | TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, |
71e3aac0 | 50 | TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, |
ba76149f | 51 | TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG, |
79da5407 | 52 | TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG, |
71e3aac0 AA |
53 | }; |
54 | ||
b46e756f KS |
55 | struct kobject; |
56 | struct kobj_attribute; | |
57 | ||
ebfe1b8f RC |
58 | ssize_t single_hugepage_flag_store(struct kobject *kobj, |
59 | struct kobj_attribute *attr, | |
60 | const char *buf, size_t count, | |
61 | enum transparent_hugepage_flag flag); | |
62 | ssize_t single_hugepage_flag_show(struct kobject *kobj, | |
63 | struct kobj_attribute *attr, char *buf, | |
64 | enum transparent_hugepage_flag flag); | |
5a6e75f8 KS |
65 | extern struct kobj_attribute shmem_enabled_attr; |
66 | ||
3485b883 | 67 | /* |
19eaf449 RR |
68 | * Mask of all large folio orders supported for anonymous THP; all orders up to |
69 | * and including PMD_ORDER, except order-0 (which is not "huge") and order-1 | |
70 | * (which is a limitation of the THP implementation). | |
3485b883 | 71 | */ |
19eaf449 | 72 | #define THP_ORDERS_ALL_ANON ((BIT(PMD_ORDER + 1) - 1) & ~(BIT(0) | BIT(1))) |
3485b883 RR |
73 | |
74 | /* | |
75 | * Mask of all large folio orders supported for file THP. | |
76 | */ | |
77 | #define THP_ORDERS_ALL_FILE (BIT(PMD_ORDER) | BIT(PUD_ORDER)) | |
78 | ||
79 | /* | |
80 | * Mask of all large folio orders supported for THP. | |
81 | */ | |
82 | #define THP_ORDERS_ALL (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE) | |
83 | ||
84 | #define thp_vma_allowable_order(vma, vm_flags, smaps, in_pf, enforce_sysfs, order) \ | |
85 | (!!thp_vma_allowable_orders(vma, vm_flags, smaps, in_pf, enforce_sysfs, BIT(order))) | |
86 | ||
b979db16 | 87 | #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES |
fde52796 | 88 | #define HPAGE_PMD_SHIFT PMD_SHIFT |
b979db16 PX |
89 | #define HPAGE_PUD_SHIFT PUD_SHIFT |
90 | #else | |
91 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) | |
92 | #define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; }) | |
93 | #endif | |
94 | ||
95 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) | |
96 | #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) | |
fde52796 | 97 | #define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1)) |
b979db16 | 98 | #define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) |
71e3aac0 | 99 | |
b979db16 PX |
100 | #define HPAGE_PUD_ORDER (HPAGE_PUD_SHIFT-PAGE_SHIFT) |
101 | #define HPAGE_PUD_NR (1<<HPAGE_PUD_ORDER) | |
a00cc7d9 | 102 | #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) |
b979db16 PX |
103 | #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) |
104 | ||
105 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | |
a00cc7d9 | 106 | |
16981d76 | 107 | extern unsigned long transparent_hugepage_flags; |
3485b883 RR |
108 | extern unsigned long huge_anon_orders_always; |
109 | extern unsigned long huge_anon_orders_madvise; | |
110 | extern unsigned long huge_anon_orders_inherit; | |
111 | ||
112 | static inline bool hugepage_global_enabled(void) | |
113 | { | |
114 | return transparent_hugepage_flags & | |
115 | ((1<<TRANSPARENT_HUGEPAGE_FLAG) | | |
116 | (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)); | |
117 | } | |
118 | ||
119 | static inline bool hugepage_global_always(void) | |
120 | { | |
121 | return transparent_hugepage_flags & | |
122 | (1<<TRANSPARENT_HUGEPAGE_FLAG); | |
123 | } | |
124 | ||
125 | static inline bool hugepage_flags_enabled(void) | |
126 | { | |
127 | /* | |
128 | * We cover both the anon and the file-backed case here; we must return | |
129 | * true if globally enabled, even when all anon sizes are set to never. | |
130 | * So we don't need to look at huge_anon_orders_inherit. | |
131 | */ | |
132 | return hugepage_global_enabled() || | |
133 | huge_anon_orders_always || | |
134 | huge_anon_orders_madvise; | |
135 | } | |
136 | ||
137 | static inline int highest_order(unsigned long orders) | |
138 | { | |
139 | return fls_long(orders) - 1; | |
140 | } | |
16981d76 | 141 | |
3485b883 RR |
142 | static inline int next_order(unsigned long *orders, int prev) |
143 | { | |
144 | *orders &= ~BIT(prev); | |
145 | return highest_order(*orders); | |
146 | } | |
1064026b | 147 | |
4fa6893f YS |
148 | /* |
149 | * Do the below checks: | |
150 | * - For file vma, check if the linear page offset of vma is | |
3485b883 RR |
151 | * order-aligned within the file. The hugepage is |
152 | * guaranteed to be order-aligned within the file, but we must | |
153 | * check that the order-aligned addresses in the VMA map to | |
154 | * order-aligned offsets within the file, else the hugepage will | |
155 | * not be mappable. | |
156 | * - For all vmas, check if the haddr is in an aligned hugepage | |
4fa6893f YS |
157 | * area. |
158 | */ | |
3485b883 RR |
159 | static inline bool thp_vma_suitable_order(struct vm_area_struct *vma, |
160 | unsigned long addr, int order) | |
e6be37b2 | 161 | { |
3485b883 | 162 | unsigned long hpage_size = PAGE_SIZE << order; |
c453d8c7 YS |
163 | unsigned long haddr; |
164 | ||
e6be37b2 ML |
165 | /* Don't have to check pgoff for anonymous vma */ |
166 | if (!vma_is_anonymous(vma)) { | |
167 | if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, | |
3485b883 | 168 | hpage_size >> PAGE_SHIFT)) |
e6be37b2 ML |
169 | return false; |
170 | } | |
171 | ||
3485b883 | 172 | haddr = ALIGN_DOWN(addr, hpage_size); |
e6be37b2 | 173 | |
3485b883 | 174 | if (haddr < vma->vm_start || haddr + hpage_size > vma->vm_end) |
e6be37b2 ML |
175 | return false; |
176 | return true; | |
177 | } | |
178 | ||
3485b883 RR |
179 | /* |
180 | * Filter the bitfield of input orders to the ones suitable for use in the vma. | |
181 | * See thp_vma_suitable_order(). | |
182 | * All orders that pass the checks are returned as a bitfield. | |
183 | */ | |
184 | static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma, | |
185 | unsigned long addr, unsigned long orders) | |
186 | { | |
187 | int order; | |
188 | ||
189 | /* | |
190 | * Iterate over orders, highest to lowest, removing orders that don't | |
191 | * meet alignment requirements from the set. Exit loop at first order | |
192 | * that meets requirements, since all lower orders must also meet | |
193 | * requirements. | |
194 | */ | |
195 | ||
196 | order = highest_order(orders); | |
197 | ||
198 | while (orders) { | |
199 | if (thp_vma_suitable_order(vma, addr, order)) | |
200 | break; | |
201 | order = next_order(&orders, order); | |
202 | } | |
203 | ||
204 | return orders; | |
205 | } | |
206 | ||
78d12c19 YS |
207 | static inline bool file_thp_enabled(struct vm_area_struct *vma) |
208 | { | |
209 | struct inode *inode; | |
210 | ||
211 | if (!vma->vm_file) | |
212 | return false; | |
213 | ||
214 | inode = vma->vm_file->f_inode; | |
215 | ||
216 | return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && | |
78d12c19 YS |
217 | !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); |
218 | } | |
219 | ||
3485b883 RR |
220 | unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, |
221 | unsigned long vm_flags, bool smaps, | |
222 | bool in_pf, bool enforce_sysfs, | |
223 | unsigned long orders); | |
224 | ||
225 | /** | |
226 | * thp_vma_allowable_orders - determine hugepage orders that are allowed for vma | |
227 | * @vma: the vm area to check | |
228 | * @vm_flags: use these vm_flags instead of vma->vm_flags | |
229 | * @smaps: whether answer will be used for smaps file | |
230 | * @in_pf: whether answer will be used by page fault handler | |
231 | * @enforce_sysfs: whether sysfs config should be taken into account | |
232 | * @orders: bitfield of all orders to consider | |
233 | * | |
234 | * Calculates the intersection of the requested hugepage orders and the allowed | |
235 | * hugepage orders for the provided vma. Permitted orders are encoded as a set | |
236 | * bit at the corresponding bit position (bit-2 corresponds to order-2, bit-3 | |
237 | * corresponds to order-3, etc). Order-0 is never considered a hugepage order. | |
238 | * | |
239 | * Return: bitfield of orders allowed for hugepage in the vma. 0 if no hugepage | |
240 | * orders are allowed. | |
241 | */ | |
242 | static inline | |
243 | unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma, | |
244 | unsigned long vm_flags, bool smaps, | |
245 | bool in_pf, bool enforce_sysfs, | |
246 | unsigned long orders) | |
247 | { | |
248 | /* Optimization to check if required orders are enabled early. */ | |
249 | if (enforce_sysfs && vma_is_anonymous(vma)) { | |
250 | unsigned long mask = READ_ONCE(huge_anon_orders_always); | |
251 | ||
252 | if (vm_flags & VM_HUGEPAGE) | |
253 | mask |= READ_ONCE(huge_anon_orders_madvise); | |
254 | if (hugepage_global_always() || | |
255 | ((vm_flags & VM_HUGEPAGE) && hugepage_global_enabled())) | |
256 | mask |= READ_ONCE(huge_anon_orders_inherit); | |
257 | ||
258 | orders &= mask; | |
259 | if (!orders) | |
260 | return 0; | |
261 | } | |
262 | ||
263 | return __thp_vma_allowable_orders(vma, vm_flags, smaps, in_pf, | |
264 | enforce_sysfs, orders); | |
265 | } | |
43675e6f | 266 | |
ec33687c BS |
267 | enum mthp_stat_item { |
268 | MTHP_STAT_ANON_FAULT_ALLOC, | |
269 | MTHP_STAT_ANON_FAULT_FALLBACK, | |
270 | MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, | |
d0f048ac BS |
271 | MTHP_STAT_ANON_SWPOUT, |
272 | MTHP_STAT_ANON_SWPOUT_FALLBACK, | |
ec33687c BS |
273 | __MTHP_STAT_COUNT |
274 | }; | |
275 | ||
276 | struct mthp_stat { | |
277 | unsigned long stats[ilog2(MAX_PTRS_PER_PTE) + 1][__MTHP_STAT_COUNT]; | |
278 | }; | |
279 | ||
280 | DECLARE_PER_CPU(struct mthp_stat, mthp_stats); | |
281 | ||
282 | static inline void count_mthp_stat(int order, enum mthp_stat_item item) | |
283 | { | |
284 | if (order <= 0 || order > PMD_ORDER) | |
285 | return; | |
286 | ||
287 | this_cpu_inc(mthp_stats.stats[order][item]); | |
288 | } | |
289 | ||
79da5407 KS |
290 | #define transparent_hugepage_use_zero_page() \ |
291 | (transparent_hugepage_flags & \ | |
292 | (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG)) | |
71e3aac0 | 293 | |
ebfe1b8f RC |
294 | unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, |
295 | unsigned long len, unsigned long pgoff, unsigned long flags); | |
ed48e87c RE |
296 | unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr, |
297 | unsigned long len, unsigned long pgoff, unsigned long flags, | |
298 | vm_flags_t vm_flags); | |
74d2fad1 | 299 | |
d4b4084a | 300 | bool can_split_folio(struct folio *folio, int *pextra_pins); |
c010d47f ZY |
301 | int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, |
302 | unsigned int new_order); | |
e9b61f19 KS |
303 | static inline int split_huge_page(struct page *page) |
304 | { | |
c010d47f | 305 | return split_huge_page_to_list_to_order(page, NULL, 0); |
e9b61f19 | 306 | } |
f158ed61 | 307 | void deferred_split_folio(struct folio *folio); |
eef1b3ba KS |
308 | |
309 | void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | |
af28a988 | 310 | unsigned long address, bool freeze, struct folio *folio); |
eef1b3ba KS |
311 | |
312 | #define split_huge_pmd(__vma, __pmd, __address) \ | |
313 | do { \ | |
314 | pmd_t *____pmd = (__pmd); \ | |
84c3fc4e | 315 | if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd) \ |
5c7fb56e | 316 | || pmd_devmap(*____pmd)) \ |
fec89c10 | 317 | __split_huge_pmd(__vma, __pmd, __address, \ |
33f4751e | 318 | false, NULL); \ |
eef1b3ba | 319 | } while (0) |
ad0bed24 | 320 | |
2a52bcbc | 321 | |
fec89c10 | 322 | void split_huge_pmd_address(struct vm_area_struct *vma, unsigned long address, |
af28a988 | 323 | bool freeze, struct folio *folio); |
2a52bcbc | 324 | |
a00cc7d9 MW |
325 | void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud, |
326 | unsigned long address); | |
327 | ||
328 | #define split_huge_pud(__vma, __pud, __address) \ | |
329 | do { \ | |
330 | pud_t *____pud = (__pud); \ | |
331 | if (pud_trans_huge(*____pud) \ | |
332 | || pud_devmap(*____pud)) \ | |
333 | __split_huge_pud(__vma, __pud, __address); \ | |
334 | } while (0) | |
335 | ||
ebfe1b8f RC |
336 | int hugepage_madvise(struct vm_area_struct *vma, unsigned long *vm_flags, |
337 | int advice); | |
7d8faaf1 ZK |
338 | int madvise_collapse(struct vm_area_struct *vma, |
339 | struct vm_area_struct **prev, | |
340 | unsigned long start, unsigned long end); | |
ebfe1b8f RC |
341 | void vma_adjust_trans_huge(struct vm_area_struct *vma, unsigned long start, |
342 | unsigned long end, long adjust_next); | |
343 | spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma); | |
344 | spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma); | |
84c3fc4e ZY |
345 | |
346 | static inline int is_swap_pmd(pmd_t pmd) | |
347 | { | |
348 | return !pmd_none(pmd) && !pmd_present(pmd); | |
349 | } | |
350 | ||
c1e8d7c6 | 351 | /* mmap_lock must be held on entry */ |
b6ec57f4 KS |
352 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, |
353 | struct vm_area_struct *vma) | |
025c5b24 | 354 | { |
84c3fc4e | 355 | if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) |
b6ec57f4 | 356 | return __pmd_trans_huge_lock(pmd, vma); |
025c5b24 | 357 | else |
969e8d7e | 358 | return NULL; |
025c5b24 | 359 | } |
a00cc7d9 MW |
360 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, |
361 | struct vm_area_struct *vma) | |
362 | { | |
a00cc7d9 MW |
363 | if (pud_trans_huge(*pud) || pud_devmap(*pud)) |
364 | return __pud_trans_huge_lock(pud, vma); | |
365 | else | |
366 | return NULL; | |
367 | } | |
6ffbb458 | 368 | |
5bf34d7c MWO |
369 | /** |
370 | * folio_test_pmd_mappable - Can we map this folio with a PMD? | |
371 | * @folio: The folio to test | |
372 | */ | |
373 | static inline bool folio_test_pmd_mappable(struct folio *folio) | |
374 | { | |
375 | return folio_order(folio) >= HPAGE_PMD_ORDER; | |
376 | } | |
377 | ||
a00cc7d9 | 378 | struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr, |
df06b37f | 379 | pmd_t *pmd, int flags, struct dev_pagemap **pgmap); |
a00cc7d9 | 380 | |
5db4f15c | 381 | vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf); |
d10e63f2 | 382 | |
5691753d | 383 | extern struct folio *huge_zero_folio; |
3b77e8c8 | 384 | extern unsigned long huge_zero_pfn; |
56873f43 | 385 | |
5beaee54 MWO |
386 | static inline bool is_huge_zero_folio(const struct folio *folio) |
387 | { | |
5691753d | 388 | return READ_ONCE(huge_zero_folio) == folio; |
5beaee54 MWO |
389 | } |
390 | ||
fc437044 MW |
391 | static inline bool is_huge_zero_pmd(pmd_t pmd) |
392 | { | |
3ce4fee4 | 393 | return pmd_present(pmd) && READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd); |
fc437044 MW |
394 | } |
395 | ||
a00cc7d9 MW |
396 | static inline bool is_huge_zero_pud(pud_t pud) |
397 | { | |
398 | return false; | |
399 | } | |
400 | ||
5691753d | 401 | struct folio *mm_get_huge_zero_folio(struct mm_struct *mm); |
632230ff | 402 | void mm_put_huge_zero_folio(struct mm_struct *mm); |
5691753d | 403 | |
10102459 KS |
404 | #define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot)) |
405 | ||
9c670ea3 NH |
406 | static inline bool thp_migration_supported(void) |
407 | { | |
408 | return IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION); | |
409 | } | |
410 | ||
71e3aac0 | 411 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ |
a00cc7d9 | 412 | |
5bf34d7c MWO |
413 | static inline bool folio_test_pmd_mappable(struct folio *folio) |
414 | { | |
415 | return false; | |
416 | } | |
417 | ||
3485b883 RR |
418 | static inline bool thp_vma_suitable_order(struct vm_area_struct *vma, |
419 | unsigned long addr, int order) | |
43675e6f YS |
420 | { |
421 | return false; | |
422 | } | |
423 | ||
3485b883 RR |
424 | static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma, |
425 | unsigned long addr, unsigned long orders) | |
e6be37b2 | 426 | { |
3485b883 RR |
427 | return 0; |
428 | } | |
429 | ||
430 | static inline unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma, | |
431 | unsigned long vm_flags, bool smaps, | |
432 | bool in_pf, bool enforce_sysfs, | |
433 | unsigned long orders) | |
434 | { | |
435 | return 0; | |
e6be37b2 ML |
436 | } |
437 | ||
71e3aac0 | 438 | #define transparent_hugepage_flags 0UL |
74d2fad1 TK |
439 | |
440 | #define thp_get_unmapped_area NULL | |
441 | ||
ed48e87c RE |
442 | static inline unsigned long |
443 | thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr, | |
444 | unsigned long len, unsigned long pgoff, | |
445 | unsigned long flags, vm_flags_t vm_flags) | |
446 | { | |
447 | return 0; | |
448 | } | |
449 | ||
b8f593cd | 450 | static inline bool |
d4b4084a | 451 | can_split_folio(struct folio *folio, int *pextra_pins) |
b8f593cd | 452 | { |
b8f593cd HY |
453 | return false; |
454 | } | |
5bc7b8ac | 455 | static inline int |
c010d47f ZY |
456 | split_huge_page_to_list_to_order(struct page *page, struct list_head *list, |
457 | unsigned int new_order) | |
5bc7b8ac SL |
458 | { |
459 | return 0; | |
460 | } | |
71e3aac0 AA |
461 | static inline int split_huge_page(struct page *page) |
462 | { | |
463 | return 0; | |
464 | } | |
f158ed61 | 465 | static inline void deferred_split_folio(struct folio *folio) {} |
78ddc534 | 466 | #define split_huge_pmd(__vma, __pmd, __address) \ |
e180377f | 467 | do { } while (0) |
2a52bcbc | 468 | |
fd60775a | 469 | static inline void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, |
af28a988 | 470 | unsigned long address, bool freeze, struct folio *folio) {} |
2a52bcbc | 471 | static inline void split_huge_pmd_address(struct vm_area_struct *vma, |
af28a988 | 472 | unsigned long address, bool freeze, struct folio *folio) {} |
2a52bcbc | 473 | |
a00cc7d9 MW |
474 | #define split_huge_pud(__vma, __pmd, __address) \ |
475 | do { } while (0) | |
476 | ||
60ab3244 AA |
477 | static inline int hugepage_madvise(struct vm_area_struct *vma, |
478 | unsigned long *vm_flags, int advice) | |
0af4e98b | 479 | { |
7d8faaf1 | 480 | return -EINVAL; |
0af4e98b | 481 | } |
7d8faaf1 ZK |
482 | |
483 | static inline int madvise_collapse(struct vm_area_struct *vma, | |
484 | struct vm_area_struct **prev, | |
485 | unsigned long start, unsigned long end) | |
486 | { | |
487 | return -EINVAL; | |
488 | } | |
489 | ||
94fcc585 AA |
490 | static inline void vma_adjust_trans_huge(struct vm_area_struct *vma, |
491 | unsigned long start, | |
492 | unsigned long end, | |
493 | long adjust_next) | |
494 | { | |
495 | } | |
84c3fc4e ZY |
496 | static inline int is_swap_pmd(pmd_t pmd) |
497 | { | |
498 | return 0; | |
499 | } | |
b6ec57f4 KS |
500 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, |
501 | struct vm_area_struct *vma) | |
025c5b24 | 502 | { |
b6ec57f4 | 503 | return NULL; |
025c5b24 | 504 | } |
a00cc7d9 MW |
505 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, |
506 | struct vm_area_struct *vma) | |
507 | { | |
508 | return NULL; | |
509 | } | |
d10e63f2 | 510 | |
5db4f15c | 511 | static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) |
d10e63f2 | 512 | { |
4daae3b4 | 513 | return 0; |
d10e63f2 MG |
514 | } |
515 | ||
5beaee54 MWO |
516 | static inline bool is_huge_zero_folio(const struct folio *folio) |
517 | { | |
518 | return false; | |
519 | } | |
520 | ||
3b77e8c8 HD |
521 | static inline bool is_huge_zero_pmd(pmd_t pmd) |
522 | { | |
523 | return false; | |
524 | } | |
525 | ||
a00cc7d9 MW |
526 | static inline bool is_huge_zero_pud(pud_t pud) |
527 | { | |
528 | return false; | |
529 | } | |
530 | ||
632230ff | 531 | static inline void mm_put_huge_zero_folio(struct mm_struct *mm) |
aa88b68c | 532 | { |
6fcb52a5 | 533 | return; |
aa88b68c | 534 | } |
3565fce3 DW |
535 | |
536 | static inline struct page *follow_devmap_pmd(struct vm_area_struct *vma, | |
df06b37f | 537 | unsigned long addr, pmd_t *pmd, int flags, struct dev_pagemap **pgmap) |
3565fce3 DW |
538 | { |
539 | return NULL; | |
540 | } | |
a00cc7d9 | 541 | |
9c670ea3 NH |
542 | static inline bool thp_migration_supported(void) |
543 | { | |
544 | return false; | |
545 | } | |
71e3aac0 AA |
546 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
547 | ||
c010d47f ZY |
548 | static inline int split_folio_to_list_to_order(struct folio *folio, |
549 | struct list_head *list, int new_order) | |
346cf613 | 550 | { |
c010d47f | 551 | return split_huge_page_to_list_to_order(&folio->page, list, new_order); |
346cf613 MWO |
552 | } |
553 | ||
c010d47f | 554 | static inline int split_folio_to_order(struct folio *folio, int new_order) |
d788f5b3 | 555 | { |
c010d47f | 556 | return split_folio_to_list_to_order(folio, NULL, new_order); |
d788f5b3 MWO |
557 | } |
558 | ||
c010d47f ZY |
559 | #define split_folio_to_list(f, l) split_folio_to_list_to_order(f, l, 0) |
560 | #define split_folio(f) split_folio_to_order(f, 0) | |
561 | ||
71e3aac0 | 562 | #endif /* _LINUX_HUGE_MM_H */ |