xref: /linux-6.15/include/linux/huge_mm.h (revision 0c3beacf)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_HUGE_MM_H
3 #define _LINUX_HUGE_MM_H
4 
5 #include <linux/mm_types.h>
6 
7 #include <linux/fs.h> /* only for vma_is_dax() */
8 #include <linux/kobject.h>
9 
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,
13 		  struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma);
14 void huge_pmd_set_accessed(struct vm_fault *vmf);
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);
18 
19 #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
20 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 
27 vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf);
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);
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);
39 
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);
42 
43 enum transparent_hugepage_flag {
44 	TRANSPARENT_HUGEPAGE_UNSUPPORTED,
45 	TRANSPARENT_HUGEPAGE_FLAG,
46 	TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,
47 	TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG,
48 	TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG,
49 	TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG,
50 	TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG,
51 	TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG,
52 	TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG,
53 };
54 
55 struct kobject;
56 struct kobj_attribute;
57 
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);
65 extern struct kobj_attribute shmem_enabled_attr;
66 extern struct kobj_attribute thpsize_shmem_enabled_attr;
67 
68 /*
69  * Mask of all large folio orders supported for anonymous THP; all orders up to
70  * and including PMD_ORDER, except order-0 (which is not "huge") and order-1
71  * (which is a limitation of the THP implementation).
72  */
73 #define THP_ORDERS_ALL_ANON	((BIT(PMD_ORDER + 1) - 1) & ~(BIT(0) | BIT(1)))
74 
75 /*
76  * Mask of all large folio orders supported for file THP. Folios in a DAX
77  * file is never split and the MAX_PAGECACHE_ORDER limit does not apply to
78  * it.  Same to PFNMAPs where there's neither page* nor pagecache.
79  */
80 #define THP_ORDERS_ALL_SPECIAL		\
81 	(BIT(PMD_ORDER) | BIT(PUD_ORDER))
82 #define THP_ORDERS_ALL_FILE_DEFAULT	\
83 	((BIT(MAX_PAGECACHE_ORDER + 1) - 1) & ~BIT(0))
84 
85 /*
86  * Mask of all large folio orders supported for THP.
87  */
88 #define THP_ORDERS_ALL	\
89 	(THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_SPECIAL | THP_ORDERS_ALL_FILE_DEFAULT)
90 
91 #define TVA_SMAPS		(1 << 0)	/* Will be used for procfs */
92 #define TVA_IN_PF		(1 << 1)	/* Page fault handler */
93 #define TVA_ENFORCE_SYSFS	(1 << 2)	/* Obey sysfs configuration */
94 
95 #define thp_vma_allowable_order(vma, vm_flags, tva_flags, order) \
96 	(!!thp_vma_allowable_orders(vma, vm_flags, tva_flags, BIT(order)))
97 
98 #define split_folio(f) split_folio_to_list(f, NULL)
99 
100 #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
101 #define HPAGE_PMD_SHIFT PMD_SHIFT
102 #define HPAGE_PUD_SHIFT PUD_SHIFT
103 #else
104 #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
105 #define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
106 #endif
107 
108 #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
109 #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
110 #define HPAGE_PMD_MASK	(~(HPAGE_PMD_SIZE - 1))
111 #define HPAGE_PMD_SIZE	((1UL) << HPAGE_PMD_SHIFT)
112 
113 #define HPAGE_PUD_ORDER (HPAGE_PUD_SHIFT-PAGE_SHIFT)
114 #define HPAGE_PUD_NR (1<<HPAGE_PUD_ORDER)
115 #define HPAGE_PUD_MASK	(~(HPAGE_PUD_SIZE - 1))
116 #define HPAGE_PUD_SIZE	((1UL) << HPAGE_PUD_SHIFT)
117 
118 enum mthp_stat_item {
119 	MTHP_STAT_ANON_FAULT_ALLOC,
120 	MTHP_STAT_ANON_FAULT_FALLBACK,
121 	MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE,
122 	MTHP_STAT_SWPOUT,
123 	MTHP_STAT_SWPOUT_FALLBACK,
124 	MTHP_STAT_SHMEM_ALLOC,
125 	MTHP_STAT_SHMEM_FALLBACK,
126 	MTHP_STAT_SHMEM_FALLBACK_CHARGE,
127 	MTHP_STAT_SPLIT,
128 	MTHP_STAT_SPLIT_FAILED,
129 	MTHP_STAT_SPLIT_DEFERRED,
130 	MTHP_STAT_NR_ANON,
131 	MTHP_STAT_NR_ANON_PARTIALLY_MAPPED,
132 	__MTHP_STAT_COUNT
133 };
134 
135 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_SYSFS)
136 struct mthp_stat {
137 	unsigned long stats[ilog2(MAX_PTRS_PER_PTE) + 1][__MTHP_STAT_COUNT];
138 };
139 
140 DECLARE_PER_CPU(struct mthp_stat, mthp_stats);
141 
142 static inline void mod_mthp_stat(int order, enum mthp_stat_item item, int delta)
143 {
144 	if (order <= 0 || order > PMD_ORDER)
145 		return;
146 
147 	this_cpu_add(mthp_stats.stats[order][item], delta);
148 }
149 
150 static inline void count_mthp_stat(int order, enum mthp_stat_item item)
151 {
152 	mod_mthp_stat(order, item, 1);
153 }
154 
155 #else
156 static inline void mod_mthp_stat(int order, enum mthp_stat_item item, int delta)
157 {
158 }
159 
160 static inline void count_mthp_stat(int order, enum mthp_stat_item item)
161 {
162 }
163 #endif
164 
165 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
166 
167 extern unsigned long transparent_hugepage_flags;
168 extern unsigned long huge_anon_orders_always;
169 extern unsigned long huge_anon_orders_madvise;
170 extern unsigned long huge_anon_orders_inherit;
171 
172 static inline bool hugepage_global_enabled(void)
173 {
174 	return transparent_hugepage_flags &
175 			((1<<TRANSPARENT_HUGEPAGE_FLAG) |
176 			(1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG));
177 }
178 
179 static inline bool hugepage_global_always(void)
180 {
181 	return transparent_hugepage_flags &
182 			(1<<TRANSPARENT_HUGEPAGE_FLAG);
183 }
184 
185 static inline int highest_order(unsigned long orders)
186 {
187 	return fls_long(orders) - 1;
188 }
189 
190 static inline int next_order(unsigned long *orders, int prev)
191 {
192 	*orders &= ~BIT(prev);
193 	return highest_order(*orders);
194 }
195 
196 /*
197  * Do the below checks:
198  *   - For file vma, check if the linear page offset of vma is
199  *     order-aligned within the file.  The hugepage is
200  *     guaranteed to be order-aligned within the file, but we must
201  *     check that the order-aligned addresses in the VMA map to
202  *     order-aligned offsets within the file, else the hugepage will
203  *     not be mappable.
204  *   - For all vmas, check if the haddr is in an aligned hugepage
205  *     area.
206  */
207 static inline bool thp_vma_suitable_order(struct vm_area_struct *vma,
208 		unsigned long addr, int order)
209 {
210 	unsigned long hpage_size = PAGE_SIZE << order;
211 	unsigned long haddr;
212 
213 	/* Don't have to check pgoff for anonymous vma */
214 	if (!vma_is_anonymous(vma)) {
215 		if (!IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
216 				hpage_size >> PAGE_SHIFT))
217 			return false;
218 	}
219 
220 	haddr = ALIGN_DOWN(addr, hpage_size);
221 
222 	if (haddr < vma->vm_start || haddr + hpage_size > vma->vm_end)
223 		return false;
224 	return true;
225 }
226 
227 /*
228  * Filter the bitfield of input orders to the ones suitable for use in the vma.
229  * See thp_vma_suitable_order().
230  * All orders that pass the checks are returned as a bitfield.
231  */
232 static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma,
233 		unsigned long addr, unsigned long orders)
234 {
235 	int order;
236 
237 	/*
238 	 * Iterate over orders, highest to lowest, removing orders that don't
239 	 * meet alignment requirements from the set. Exit loop at first order
240 	 * that meets requirements, since all lower orders must also meet
241 	 * requirements.
242 	 */
243 
244 	order = highest_order(orders);
245 
246 	while (orders) {
247 		if (thp_vma_suitable_order(vma, addr, order))
248 			break;
249 		order = next_order(&orders, order);
250 	}
251 
252 	return orders;
253 }
254 
255 unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma,
256 					 unsigned long vm_flags,
257 					 unsigned long tva_flags,
258 					 unsigned long orders);
259 
260 /**
261  * thp_vma_allowable_orders - determine hugepage orders that are allowed for vma
262  * @vma:  the vm area to check
263  * @vm_flags: use these vm_flags instead of vma->vm_flags
264  * @tva_flags: Which TVA flags to honour
265  * @orders: bitfield of all orders to consider
266  *
267  * Calculates the intersection of the requested hugepage orders and the allowed
268  * hugepage orders for the provided vma. Permitted orders are encoded as a set
269  * bit at the corresponding bit position (bit-2 corresponds to order-2, bit-3
270  * corresponds to order-3, etc). Order-0 is never considered a hugepage order.
271  *
272  * Return: bitfield of orders allowed for hugepage in the vma. 0 if no hugepage
273  * orders are allowed.
274  */
275 static inline
276 unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
277 				       unsigned long vm_flags,
278 				       unsigned long tva_flags,
279 				       unsigned long orders)
280 {
281 	/* Optimization to check if required orders are enabled early. */
282 	if ((tva_flags & TVA_ENFORCE_SYSFS) && vma_is_anonymous(vma)) {
283 		unsigned long mask = READ_ONCE(huge_anon_orders_always);
284 
285 		if (vm_flags & VM_HUGEPAGE)
286 			mask |= READ_ONCE(huge_anon_orders_madvise);
287 		if (hugepage_global_always() ||
288 		    ((vm_flags & VM_HUGEPAGE) && hugepage_global_enabled()))
289 			mask |= READ_ONCE(huge_anon_orders_inherit);
290 
291 		orders &= mask;
292 		if (!orders)
293 			return 0;
294 	}
295 
296 	return __thp_vma_allowable_orders(vma, vm_flags, tva_flags, orders);
297 }
298 
299 struct thpsize {
300 	struct kobject kobj;
301 	struct list_head node;
302 	int order;
303 };
304 
305 #define to_thpsize(kobj) container_of(kobj, struct thpsize, kobj)
306 
307 #define transparent_hugepage_use_zero_page()				\
308 	(transparent_hugepage_flags &					\
309 	 (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG))
310 
311 static inline bool vma_thp_disabled(struct vm_area_struct *vma,
312 		unsigned long vm_flags)
313 {
314 	/*
315 	 * Explicitly disabled through madvise or prctl, or some
316 	 * architectures may disable THP for some mappings, for
317 	 * example, s390 kvm.
318 	 */
319 	return (vm_flags & VM_NOHUGEPAGE) ||
320 	       test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags);
321 }
322 
323 static inline bool thp_disabled_by_hw(void)
324 {
325 	/* If the hardware/firmware marked hugepage support disabled. */
326 	return transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED);
327 }
328 
329 unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr,
330 		unsigned long len, unsigned long pgoff, unsigned long flags);
331 unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
332 		unsigned long len, unsigned long pgoff, unsigned long flags,
333 		vm_flags_t vm_flags);
334 
335 bool can_split_folio(struct folio *folio, int caller_pins, int *pextra_pins);
336 int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
337 		unsigned int new_order);
338 int min_order_for_split(struct folio *folio);
339 int split_folio_to_list(struct folio *folio, struct list_head *list);
340 static inline int split_huge_page(struct page *page)
341 {
342 	struct folio *folio = page_folio(page);
343 	int ret = min_order_for_split(folio);
344 
345 	if (ret < 0)
346 		return ret;
347 
348 	/*
349 	 * split_huge_page() locks the page before splitting and
350 	 * expects the same page that has been split to be locked when
351 	 * returned. split_folio(page_folio(page)) cannot be used here
352 	 * because it converts the page to folio and passes the head
353 	 * page to be split.
354 	 */
355 	return split_huge_page_to_list_to_order(page, NULL, ret);
356 }
357 void deferred_split_folio(struct folio *folio, bool partially_mapped);
358 
359 void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
360 		unsigned long address, bool freeze, struct folio *folio);
361 
362 #define split_huge_pmd(__vma, __pmd, __address)				\
363 	do {								\
364 		pmd_t *____pmd = (__pmd);				\
365 		if (is_swap_pmd(*____pmd) || pmd_trans_huge(*____pmd)	\
366 					|| pmd_devmap(*____pmd))	\
367 			__split_huge_pmd(__vma, __pmd, __address,	\
368 						false, NULL);		\
369 	}  while (0)
370 
371 
372 void split_huge_pmd_address(struct vm_area_struct *vma, unsigned long address,
373 		bool freeze, struct folio *folio);
374 
375 void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud,
376 		unsigned long address);
377 
378 #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
379 int change_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma,
380 		    pud_t *pudp, unsigned long addr, pgprot_t newprot,
381 		    unsigned long cp_flags);
382 #else
383 static inline int
384 change_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma,
385 		pud_t *pudp, unsigned long addr, pgprot_t newprot,
386 		unsigned long cp_flags) { return 0; }
387 #endif
388 
389 #define split_huge_pud(__vma, __pud, __address)				\
390 	do {								\
391 		pud_t *____pud = (__pud);				\
392 		if (pud_trans_huge(*____pud)				\
393 					|| pud_devmap(*____pud))	\
394 			__split_huge_pud(__vma, __pud, __address);	\
395 	}  while (0)
396 
397 int hugepage_madvise(struct vm_area_struct *vma, unsigned long *vm_flags,
398 		     int advice);
399 int madvise_collapse(struct vm_area_struct *vma,
400 		     struct vm_area_struct **prev,
401 		     unsigned long start, unsigned long end);
402 void vma_adjust_trans_huge(struct vm_area_struct *vma, unsigned long start,
403 			   unsigned long end, long adjust_next);
404 spinlock_t *__pmd_trans_huge_lock(pmd_t *pmd, struct vm_area_struct *vma);
405 spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma);
406 
407 static inline int is_swap_pmd(pmd_t pmd)
408 {
409 	return !pmd_none(pmd) && !pmd_present(pmd);
410 }
411 
412 /* mmap_lock must be held on entry */
413 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
414 		struct vm_area_struct *vma)
415 {
416 	if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd))
417 		return __pmd_trans_huge_lock(pmd, vma);
418 	else
419 		return NULL;
420 }
421 static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
422 		struct vm_area_struct *vma)
423 {
424 	if (pud_trans_huge(*pud) || pud_devmap(*pud))
425 		return __pud_trans_huge_lock(pud, vma);
426 	else
427 		return NULL;
428 }
429 
430 /**
431  * folio_test_pmd_mappable - Can we map this folio with a PMD?
432  * @folio: The folio to test
433  */
434 static inline bool folio_test_pmd_mappable(struct folio *folio)
435 {
436 	return folio_order(folio) >= HPAGE_PMD_ORDER;
437 }
438 
439 struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
440 		pmd_t *pmd, int flags, struct dev_pagemap **pgmap);
441 
442 vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf);
443 
444 extern struct folio *huge_zero_folio;
445 extern unsigned long huge_zero_pfn;
446 
447 static inline bool is_huge_zero_folio(const struct folio *folio)
448 {
449 	return READ_ONCE(huge_zero_folio) == folio;
450 }
451 
452 static inline bool is_huge_zero_pmd(pmd_t pmd)
453 {
454 	return pmd_present(pmd) && READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd);
455 }
456 
457 struct folio *mm_get_huge_zero_folio(struct mm_struct *mm);
458 void mm_put_huge_zero_folio(struct mm_struct *mm);
459 
460 #define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot))
461 
462 static inline bool thp_migration_supported(void)
463 {
464 	return IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION);
465 }
466 
467 void split_huge_pmd_locked(struct vm_area_struct *vma, unsigned long address,
468 			   pmd_t *pmd, bool freeze, struct folio *folio);
469 bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
470 			   pmd_t *pmdp, struct folio *folio);
471 
472 #else /* CONFIG_TRANSPARENT_HUGEPAGE */
473 
474 static inline bool folio_test_pmd_mappable(struct folio *folio)
475 {
476 	return false;
477 }
478 
479 static inline bool thp_vma_suitable_order(struct vm_area_struct *vma,
480 		unsigned long addr, int order)
481 {
482 	return false;
483 }
484 
485 static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma,
486 		unsigned long addr, unsigned long orders)
487 {
488 	return 0;
489 }
490 
491 static inline unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
492 					unsigned long vm_flags,
493 					unsigned long tva_flags,
494 					unsigned long orders)
495 {
496 	return 0;
497 }
498 
499 #define transparent_hugepage_flags 0UL
500 
501 #define thp_get_unmapped_area	NULL
502 
503 static inline unsigned long
504 thp_get_unmapped_area_vmflags(struct file *filp, unsigned long addr,
505 			      unsigned long len, unsigned long pgoff,
506 			      unsigned long flags, vm_flags_t vm_flags)
507 {
508 	return 0;
509 }
510 
511 static inline bool
512 can_split_folio(struct folio *folio, int caller_pins, int *pextra_pins)
513 {
514 	return false;
515 }
516 static inline int
517 split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
518 		unsigned int new_order)
519 {
520 	return 0;
521 }
522 static inline int split_huge_page(struct page *page)
523 {
524 	return 0;
525 }
526 
527 static inline int split_folio_to_list(struct folio *folio, struct list_head *list)
528 {
529 	return 0;
530 }
531 
532 static inline void deferred_split_folio(struct folio *folio, bool partially_mapped) {}
533 #define split_huge_pmd(__vma, __pmd, __address)	\
534 	do { } while (0)
535 
536 static inline void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
537 		unsigned long address, bool freeze, struct folio *folio) {}
538 static inline void split_huge_pmd_address(struct vm_area_struct *vma,
539 		unsigned long address, bool freeze, struct folio *folio) {}
540 static inline void split_huge_pmd_locked(struct vm_area_struct *vma,
541 					 unsigned long address, pmd_t *pmd,
542 					 bool freeze, struct folio *folio) {}
543 
544 static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
545 					 unsigned long addr, pmd_t *pmdp,
546 					 struct folio *folio)
547 {
548 	return false;
549 }
550 
551 #define split_huge_pud(__vma, __pmd, __address)	\
552 	do { } while (0)
553 
554 static inline int hugepage_madvise(struct vm_area_struct *vma,
555 				   unsigned long *vm_flags, int advice)
556 {
557 	return -EINVAL;
558 }
559 
560 static inline int madvise_collapse(struct vm_area_struct *vma,
561 				   struct vm_area_struct **prev,
562 				   unsigned long start, unsigned long end)
563 {
564 	return -EINVAL;
565 }
566 
567 static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
568 					 unsigned long start,
569 					 unsigned long end,
570 					 long adjust_next)
571 {
572 }
573 static inline int is_swap_pmd(pmd_t pmd)
574 {
575 	return 0;
576 }
577 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
578 		struct vm_area_struct *vma)
579 {
580 	return NULL;
581 }
582 static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
583 		struct vm_area_struct *vma)
584 {
585 	return NULL;
586 }
587 
588 static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
589 {
590 	return 0;
591 }
592 
593 static inline bool is_huge_zero_folio(const struct folio *folio)
594 {
595 	return false;
596 }
597 
598 static inline bool is_huge_zero_pmd(pmd_t pmd)
599 {
600 	return false;
601 }
602 
603 static inline void mm_put_huge_zero_folio(struct mm_struct *mm)
604 {
605 	return;
606 }
607 
608 static inline struct page *follow_devmap_pmd(struct vm_area_struct *vma,
609 	unsigned long addr, pmd_t *pmd, int flags, struct dev_pagemap **pgmap)
610 {
611 	return NULL;
612 }
613 
614 static inline bool thp_migration_supported(void)
615 {
616 	return false;
617 }
618 
619 static inline int highest_order(unsigned long orders)
620 {
621 	return 0;
622 }
623 
624 static inline int next_order(unsigned long *orders, int prev)
625 {
626 	return 0;
627 }
628 
629 static inline void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud,
630 				    unsigned long address)
631 {
632 }
633 
634 static inline int change_huge_pud(struct mmu_gather *tlb,
635 				  struct vm_area_struct *vma, pud_t *pudp,
636 				  unsigned long addr, pgprot_t newprot,
637 				  unsigned long cp_flags)
638 {
639 	return 0;
640 }
641 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
642 
643 static inline int split_folio_to_list_to_order(struct folio *folio,
644 		struct list_head *list, int new_order)
645 {
646 	return split_huge_page_to_list_to_order(&folio->page, list, new_order);
647 }
648 
649 static inline int split_folio_to_order(struct folio *folio, int new_order)
650 {
651 	return split_folio_to_list_to_order(folio, NULL, new_order);
652 }
653 
654 #endif /* _LINUX_HUGE_MM_H */
655