Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/khugepaged: rename hpage_collapse_* to collapse_*

The hpage_collapse functions describe functions used by madvise_collapse
and khugepaged. remove the unnecessary hpage prefix to shorten the
function name.

Link: https://lkml.kernel.org/r/20260325114022.444081-5-npache@redhat.com
Signed-off-by: Nico Pache <npache@redhat.com>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Rafael Aquini <raquini@redhat.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shivank Garg <shivankg@amd.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Takashi Iwai (SUSE) <tiwai@suse.de>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Cc: Yang Shi <yang@os.amperecomputing.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Nico Pache and committed by
Andrew Morton
ff7e03a8 36da8a88

+30 -32
+29 -31
mm/khugepaged.c
··· 395 395 kmem_cache_destroy(mm_slot_cache); 396 396 } 397 397 398 - static inline int hpage_collapse_test_exit(struct mm_struct *mm) 398 + static inline int collapse_test_exit(struct mm_struct *mm) 399 399 { 400 400 return atomic_read(&mm->mm_users) == 0; 401 401 } 402 402 403 - static inline int hpage_collapse_test_exit_or_disable(struct mm_struct *mm) 403 + static inline int collapse_test_exit_or_disable(struct mm_struct *mm) 404 404 { 405 - return hpage_collapse_test_exit(mm) || 405 + return collapse_test_exit(mm) || 406 406 mm_flags_test(MMF_DISABLE_THP_COMPLETELY, mm); 407 407 } 408 408 ··· 436 436 int wakeup; 437 437 438 438 /* __khugepaged_exit() must not run from under us */ 439 - VM_BUG_ON_MM(hpage_collapse_test_exit(mm), mm); 439 + VM_BUG_ON_MM(collapse_test_exit(mm), mm); 440 440 if (unlikely(mm_flags_test_and_set(MMF_VM_HUGEPAGE, mm))) 441 441 return; 442 442 ··· 490 490 } else if (slot) { 491 491 /* 492 492 * This is required to serialize against 493 - * hpage_collapse_test_exit() (which is guaranteed to run 493 + * collapse_test_exit() (which is guaranteed to run 494 494 * under mmap sem read mode). Stop here (after we return all 495 495 * pagetables will be destroyed) until khugepaged has finished 496 496 * working on the pagetables under the mmap_lock. ··· 589 589 goto out; 590 590 } 591 591 592 - /* See hpage_collapse_scan_pmd(). */ 592 + /* See collapse_scan_pmd(). */ 593 593 if (folio_maybe_mapped_shared(folio)) { 594 594 ++shared; 595 595 if (cc->is_khugepaged && ··· 840 840 .is_khugepaged = true, 841 841 }; 842 842 843 - static bool hpage_collapse_scan_abort(int nid, struct collapse_control *cc) 843 + static bool collapse_scan_abort(int nid, struct collapse_control *cc) 844 844 { 845 845 int i; 846 846 ··· 875 875 } 876 876 877 877 #ifdef CONFIG_NUMA 878 - static int hpage_collapse_find_target_node(struct collapse_control *cc) 878 + static int collapse_find_target_node(struct collapse_control *cc) 879 879 { 880 880 int nid, target_node = 0, max_value = 0; 881 881 ··· 894 894 return target_node; 895 895 } 896 896 #else 897 - static int hpage_collapse_find_target_node(struct collapse_control *cc) 897 + static int collapse_find_target_node(struct collapse_control *cc) 898 898 { 899 899 return 0; 900 900 } ··· 913 913 enum tva_type type = cc->is_khugepaged ? TVA_KHUGEPAGED : 914 914 TVA_FORCED_COLLAPSE; 915 915 916 - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) 916 + if (unlikely(collapse_test_exit_or_disable(mm))) 917 917 return SCAN_ANY_PROCESS; 918 918 919 919 *vmap = vma = find_vma(mm, address); ··· 984 984 985 985 /* 986 986 * Bring missing pages in from swap, to complete THP collapse. 987 - * Only done if hpage_collapse_scan_pmd believes it is worthwhile. 987 + * Only done if khugepaged_scan_pmd believes it is worthwhile. 988 988 * 989 989 * Called and returns without pte mapped or spinlocks held. 990 990 * Returns result: if not SCAN_SUCCEED, mmap_lock has been released. ··· 1070 1070 { 1071 1071 gfp_t gfp = (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() : 1072 1072 GFP_TRANSHUGE); 1073 - int node = hpage_collapse_find_target_node(cc); 1073 + int node = collapse_find_target_node(cc); 1074 1074 struct folio *folio; 1075 1075 1076 1076 folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); ··· 1248 1248 return result; 1249 1249 } 1250 1250 1251 - static enum scan_result hpage_collapse_scan_pmd(struct mm_struct *mm, 1251 + static enum scan_result collapse_scan_pmd(struct mm_struct *mm, 1252 1252 struct vm_area_struct *vma, unsigned long start_addr, 1253 1253 bool *mmap_locked, struct collapse_control *cc) 1254 1254 { ··· 1373 1373 * hit record. 1374 1374 */ 1375 1375 node = folio_nid(folio); 1376 - if (hpage_collapse_scan_abort(node, cc)) { 1376 + if (collapse_scan_abort(node, cc)) { 1377 1377 result = SCAN_SCAN_ABORT; 1378 1378 goto out_unmap; 1379 1379 } ··· 1439 1439 1440 1440 lockdep_assert_held(&khugepaged_mm_lock); 1441 1441 1442 - if (hpage_collapse_test_exit(mm)) { 1442 + if (collapse_test_exit(mm)) { 1443 1443 /* free mm_slot */ 1444 1444 hash_del(&slot->hash); 1445 1445 list_del(&slot->mm_node); ··· 1794 1794 if (find_pmd_or_thp_or_none(mm, addr, &pmd) != SCAN_SUCCEED) 1795 1795 continue; 1796 1796 1797 - if (hpage_collapse_test_exit(mm)) 1797 + if (collapse_test_exit(mm)) 1798 1798 continue; 1799 1799 1800 1800 if (!file_backed_vma_is_retractable(vma)) ··· 2310 2310 return result; 2311 2311 } 2312 2312 2313 - static enum scan_result hpage_collapse_scan_file(struct mm_struct *mm, 2313 + static enum scan_result collapse_scan_file(struct mm_struct *mm, 2314 2314 unsigned long addr, struct file *file, pgoff_t start, 2315 2315 struct collapse_control *cc) 2316 2316 { ··· 2363 2363 } 2364 2364 2365 2365 node = folio_nid(folio); 2366 - if (hpage_collapse_scan_abort(node, cc)) { 2366 + if (collapse_scan_abort(node, cc)) { 2367 2367 result = SCAN_SCAN_ABORT; 2368 2368 folio_put(folio); 2369 2369 break; ··· 2417 2417 return result; 2418 2418 } 2419 2419 2420 - static void khugepaged_scan_mm_slot(unsigned int progress_max, 2420 + static void collapse_scan_mm_slot(unsigned int progress_max, 2421 2421 enum scan_result *result, struct collapse_control *cc) 2422 2422 __releases(&khugepaged_mm_lock) 2423 2423 __acquires(&khugepaged_mm_lock) ··· 2451 2451 goto breakouterloop_mmap_lock; 2452 2452 2453 2453 cc->progress++; 2454 - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) 2454 + if (unlikely(collapse_test_exit_or_disable(mm))) 2455 2455 goto breakouterloop; 2456 2456 2457 2457 vma_iter_init(&vmi, mm, khugepaged_scan.address); ··· 2459 2459 unsigned long hstart, hend; 2460 2460 2461 2461 cond_resched(); 2462 - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) { 2462 + if (unlikely(collapse_test_exit_or_disable(mm))) { 2463 2463 cc->progress++; 2464 2464 break; 2465 2465 } ··· 2481 2481 bool mmap_locked = true; 2482 2482 2483 2483 cond_resched(); 2484 - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) 2484 + if (unlikely(collapse_test_exit_or_disable(mm))) 2485 2485 goto breakouterloop; 2486 2486 2487 2487 VM_BUG_ON(khugepaged_scan.address < hstart || ··· 2494 2494 2495 2495 mmap_read_unlock(mm); 2496 2496 mmap_locked = false; 2497 - *result = hpage_collapse_scan_file(mm, 2497 + *result = collapse_scan_file(mm, 2498 2498 khugepaged_scan.address, file, pgoff, cc); 2499 2499 fput(file); 2500 2500 if (*result == SCAN_PTE_MAPPED_HUGEPAGE) { 2501 2501 mmap_read_lock(mm); 2502 - if (hpage_collapse_test_exit_or_disable(mm)) 2502 + if (collapse_test_exit_or_disable(mm)) 2503 2503 goto breakouterloop; 2504 2504 *result = try_collapse_pte_mapped_thp(mm, 2505 2505 khugepaged_scan.address, false); ··· 2508 2508 mmap_read_unlock(mm); 2509 2509 } 2510 2510 } else { 2511 - *result = hpage_collapse_scan_pmd(mm, vma, 2511 + *result = collapse_scan_pmd(mm, vma, 2512 2512 khugepaged_scan.address, &mmap_locked, cc); 2513 2513 } 2514 2514 ··· 2540 2540 * Release the current mm_slot if this mm is about to die, or 2541 2541 * if we scanned all vmas of this mm, or THP got disabled. 2542 2542 */ 2543 - if (hpage_collapse_test_exit_or_disable(mm) || !vma) { 2543 + if (collapse_test_exit_or_disable(mm) || !vma) { 2544 2544 /* 2545 2545 * Make sure that if mm_users is reaching zero while 2546 2546 * khugepaged runs here, khugepaged_exit will find ··· 2593 2593 pass_through_head++; 2594 2594 if (khugepaged_has_work() && 2595 2595 pass_through_head < 2) 2596 - khugepaged_scan_mm_slot(progress_max, &result, cc); 2596 + collapse_scan_mm_slot(progress_max, &result, cc); 2597 2597 else 2598 2598 cc->progress = progress_max; 2599 2599 spin_unlock(&khugepaged_mm_lock); ··· 2838 2838 mmap_read_unlock(mm); 2839 2839 mmap_locked = false; 2840 2840 *lock_dropped = true; 2841 - result = hpage_collapse_scan_file(mm, addr, file, pgoff, 2842 - cc); 2841 + result = collapse_scan_file(mm, addr, file, pgoff, cc); 2843 2842 2844 2843 if (result == SCAN_PAGE_DIRTY_OR_WRITEBACK && !triggered_wb && 2845 2844 mapping_can_writeback(file->f_mapping)) { ··· 2852 2853 } 2853 2854 fput(file); 2854 2855 } else { 2855 - result = hpage_collapse_scan_pmd(mm, vma, addr, 2856 - &mmap_locked, cc); 2856 + result = collapse_scan_pmd(mm, vma, addr, &mmap_locked, cc); 2857 2857 } 2858 2858 if (!mmap_locked) 2859 2859 *lock_dropped = true;
+1 -1
mm/mremap.c
··· 244 244 goto out; 245 245 } 246 246 /* 247 - * Now new_pte is none, so hpage_collapse_scan_file() path can not find 247 + * Now new_pte is none, so collapse_scan_file() path can not find 248 248 * this by traversing file->f_mapping, so there is no concurrency with 249 249 * retract_page_tables(). In addition, we already hold the exclusive 250 250 * mmap_lock, so this new_pte page is stable, so there is no need to get