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