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