From nobody Thu Apr 2 18:59:40 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00CDC42A96 for ; Thu, 12 Feb 2026 02:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770863032; cv=none; b=GontHQ5FDaMHyTDqiJMwdk1LfupEzgCZuk1sK/cnyqTWEcqe+qAxQ+O+rnAxPt+BGGpdjL4XnYJEfuSGD0DtY9ccJI3h9OHbrOpySw0Aw/xJbIIlZ3XHssBDKSHWAoHTbj5gkYuKeb89qp1yQRijIfoBpvCgE8+nLLhoKNr1sfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770863032; c=relaxed/simple; bh=T6BErkpwsoH2GMiooOyXkPAcTNfhGoNkwDiSa9cXV40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QkMsjBePkTh3OL8bjLhn7cV3QrydYmteAE6IGMCs5QwgKs7f9TGAkzAGapOycIB4Sg8FWSWXCEbRyNQGBQaYrwB4I1qS6cyzxtoBd99ghyomNiETID6z6BEq8ilm5iYfH9lKx3ltUD7MKetXpy3N8cHrACk1LQdeACPduIPDG0s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QsjJTbwQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QsjJTbwQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770863030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=397xlPpjUxFvY954VRGPkHg8dIT/MsS+yMoqJGr/bMM=; b=QsjJTbwQ536DR3pVqC1mv37NAJo7OXp1t71YGcPTLZDoXRW4/E09wFqDkpDmBrHFFlnjJi UeRf6RN/dj3OPy/mRbqd4BY/l2npeYUFPkIFcb5srMo/msJpul5ctahfy0GZ5MXk6s0T/h 4sxTsEiTgdPSM82u2qEsCKL9lIZO7ds= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-Vd976550OfaHGN9nXINbNw-1; Wed, 11 Feb 2026 21:23:48 -0500 X-MC-Unique: Vd976550OfaHGN9nXINbNw-1 X-Mimecast-MFC-AGG-ID: Vd976550OfaHGN9nXINbNw_1770863027 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B84E318005AD; Thu, 12 Feb 2026 02:23:47 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.91]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 566751800464; Thu, 12 Feb 2026 02:23:38 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: aarcange@redhat.com, akpm@linux-foundation.org, anshuman.khandual@arm.com, apopple@nvidia.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, byungchul@sk.com, catalin.marinas@arm.com, cl@gentwo.org, corbet@lwn.net, dave.hansen@linux.intel.com, david@kernel.org, dev.jain@arm.com, gourry@gourry.net, hannes@cmpxchg.org, hughd@google.com, jackmanb@google.com, jack@suse.cz, jannh@google.com, jglisse@google.com, joshua.hahnjy@gmail.com, kas@kernel.org, lance.yang@linux.dev, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, mathieu.desnoyers@efficios.com, matthew.brost@intel.com, mhiramat@kernel.org, mhocko@suse.com, npache@redhat.com, peterx@redhat.com, pfalcato@suse.de, rakie.kim@sk.com, raquini@redhat.com, rdunlap@infradead.org, richard.weiyang@gmail.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, ryan.roberts@arm.com, shivankg@amd.com, sunnanyong@huawei.com, surenb@google.com, thomas.hellstrom@linux.intel.com, tiwai@suse.de, usamaarif642@gmail.com, vbabka@suse.cz, vishal.moola@gmail.com, wangkefeng.wang@huawei.com, will@kernel.org, willy@infradead.org, yang@os.amperecomputing.com, ying.huang@linux.alibaba.com, ziy@nvidia.com, zokeefe@google.com Subject: [PATCH mm-unstable v1 4/5] mm/khugepaged: rename hpage_collapse_* to collapse_* Date: Wed, 11 Feb 2026 19:23:28 -0700 Message-ID: <20260212022329.18892-1-npache@redhat.com> In-Reply-To: <20260212021835.17755-1-npache@redhat.com> References: <20260212021835.17755-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The hpage_collapse functions describe functions used by madvise_collapse and khugepaged. remove the unnecessary hpage prefix to shorten the function name. Reviewed-by: Wei Yang Reviewed-by: Lance Yang Reviewed-by: Liam R. Howlett Reviewed-by: Zi Yan Reviewed-by: Baolin Wang Reviewed-by: Lorenzo Stoakes Signed-off-by: Nico Pache Acked-by: David Hildenbrand (Arm) --- mm/khugepaged.c | 62 ++++++++++++++++++++++++------------------------- mm/mremap.c | 2 +- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 3dcce6018f20..fa41480f6948 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -397,14 +397,14 @@ void __init khugepaged_destroy(void) kmem_cache_destroy(mm_slot_cache); } =20 -static inline int hpage_collapse_test_exit(struct mm_struct *mm) +static inline int collapse_test_exit(struct mm_struct *mm) { return atomic_read(&mm->mm_users) =3D=3D 0; } =20 -static inline int hpage_collapse_test_exit_or_disable(struct mm_struct *mm) +static inline int collapse_test_exit_or_disable(struct mm_struct *mm) { - return hpage_collapse_test_exit(mm) || + return collapse_test_exit(mm) || mm_flags_test(MMF_DISABLE_THP_COMPLETELY, mm); } =20 @@ -438,7 +438,7 @@ void __khugepaged_enter(struct mm_struct *mm) int wakeup; =20 /* __khugepaged_exit() must not run from under us */ - VM_BUG_ON_MM(hpage_collapse_test_exit(mm), mm); + VM_BUG_ON_MM(collapse_test_exit(mm), mm); if (unlikely(mm_flags_test_and_set(MMF_VM_HUGEPAGE, mm))) return; =20 @@ -492,7 +492,7 @@ void __khugepaged_exit(struct mm_struct *mm) } else if (slot) { /* * This is required to serialize against - * hpage_collapse_test_exit() (which is guaranteed to run + * collapse_test_exit() (which is guaranteed to run * under mmap sem read mode). Stop here (after we return all * pagetables will be destroyed) until khugepaged has finished * working on the pagetables under the mmap_lock. @@ -581,7 +581,7 @@ static enum scan_result __collapse_huge_page_isolate(st= ruct vm_area_struct *vma, folio =3D page_folio(page); VM_BUG_ON_FOLIO(!folio_test_anon(folio), folio); =20 - /* See hpage_collapse_scan_pmd(). */ + /* See collapse_scan_pmd(). */ if (folio_maybe_mapped_shared(folio)) { ++shared; if (cc->is_khugepaged && @@ -832,7 +832,7 @@ static struct collapse_control khugepaged_collapse_cont= rol =3D { .is_khugepaged =3D true, }; =20 -static bool hpage_collapse_scan_abort(int nid, struct collapse_control *cc) +static bool collapse_scan_abort(int nid, struct collapse_control *cc) { int i; =20 @@ -867,7 +867,7 @@ static inline gfp_t alloc_hugepage_khugepaged_gfpmask(v= oid) } =20 #ifdef CONFIG_NUMA -static int hpage_collapse_find_target_node(struct collapse_control *cc) +static int collapse_find_target_node(struct collapse_control *cc) { int nid, target_node =3D 0, max_value =3D 0; =20 @@ -886,7 +886,7 @@ static int hpage_collapse_find_target_node(struct colla= pse_control *cc) return target_node; } #else -static int hpage_collapse_find_target_node(struct collapse_control *cc) +static int collapse_find_target_node(struct collapse_control *cc) { return 0; } @@ -905,7 +905,7 @@ static enum scan_result hugepage_vma_revalidate(struct = mm_struct *mm, unsigned l enum tva_type type =3D cc->is_khugepaged ? TVA_KHUGEPAGED : TVA_FORCED_COLLAPSE; =20 - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) + if (unlikely(collapse_test_exit_or_disable(mm))) return SCAN_ANY_PROCESS; =20 *vmap =3D vma =3D find_vma(mm, address); @@ -976,7 +976,7 @@ static enum scan_result check_pmd_still_valid(struct mm= _struct *mm, =20 /* * Bring missing pages in from swap, to complete THP collapse. - * Only done if hpage_collapse_scan_pmd believes it is worthwhile. + * Only done if khugepaged_scan_pmd believes it is worthwhile. * * Called and returns without pte mapped or spinlocks held. * Returns result: if not SCAN_SUCCEED, mmap_lock has been released. @@ -1062,7 +1062,7 @@ static enum scan_result alloc_charge_folio(struct fol= io **foliop, struct mm_stru { gfp_t gfp =3D (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() : GFP_TRANSHUGE); - int node =3D hpage_collapse_find_target_node(cc); + int node =3D collapse_find_target_node(cc); struct folio *folio; =20 folio =3D __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); @@ -1240,7 +1240,7 @@ static enum scan_result collapse_huge_page(struct mm_= struct *mm, unsigned long a return result; } =20 -static enum scan_result hpage_collapse_scan_pmd(struct mm_struct *mm, +static enum scan_result collapse_scan_pmd(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long start_addr, bool *mmap_locked, struct collapse_control *cc) { @@ -1350,7 +1350,7 @@ static enum scan_result hpage_collapse_scan_pmd(struc= t mm_struct *mm, * hit record. */ node =3D folio_nid(folio); - if (hpage_collapse_scan_abort(node, cc)) { + if (collapse_scan_abort(node, cc)) { result =3D SCAN_SCAN_ABORT; goto out_unmap; } @@ -1416,7 +1416,7 @@ static void collect_mm_slot(struct mm_slot *slot) =20 lockdep_assert_held(&khugepaged_mm_lock); =20 - if (hpage_collapse_test_exit(mm)) { + if (collapse_test_exit(mm)) { /* free mm_slot */ hash_del(&slot->hash); list_del(&slot->mm_node); @@ -1771,7 +1771,7 @@ static void retract_page_tables(struct address_space = *mapping, pgoff_t pgoff) if (find_pmd_or_thp_or_none(mm, addr, &pmd) !=3D SCAN_SUCCEED) continue; =20 - if (hpage_collapse_test_exit(mm)) + if (collapse_test_exit(mm)) continue; =20 if (!file_backed_vma_is_retractable(vma)) @@ -2289,7 +2289,7 @@ static enum scan_result collapse_file(struct mm_struc= t *mm, unsigned long addr, return result; } =20 -static enum scan_result hpage_collapse_scan_file(struct mm_struct *mm, uns= igned long addr, +static enum scan_result collapse_scan_file(struct mm_struct *mm, unsigned = long addr, struct file *file, pgoff_t start, struct collapse_control *cc) { struct folio *folio =3D NULL; @@ -2345,7 +2345,7 @@ static enum scan_result hpage_collapse_scan_file(stru= ct mm_struct *mm, unsigned } =20 node =3D folio_nid(folio); - if (hpage_collapse_scan_abort(node, cc)) { + if (collapse_scan_abort(node, cc)) { result =3D SCAN_SCAN_ABORT; folio_put(folio); break; @@ -2395,7 +2395,7 @@ static enum scan_result hpage_collapse_scan_file(stru= ct mm_struct *mm, unsigned return result; } =20 -static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_= result *result, +static unsigned int collapse_scan_mm_slot(unsigned int pages, enum scan_re= sult *result, struct collapse_control *cc) __releases(&khugepaged_mm_lock) __acquires(&khugepaged_mm_lock) @@ -2430,7 +2430,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned = int pages, enum scan_result goto breakouterloop_mmap_lock; =20 progress++; - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) + if (unlikely(collapse_test_exit_or_disable(mm))) goto breakouterloop; =20 vma_iter_init(&vmi, mm, khugepaged_scan.address); @@ -2438,7 +2438,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned = int pages, enum scan_result unsigned long hstart, hend; =20 cond_resched(); - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) { + if (unlikely(collapse_test_exit_or_disable(mm))) { progress++; break; } @@ -2460,7 +2460,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned = int pages, enum scan_result bool mmap_locked =3D true; =20 cond_resched(); - if (unlikely(hpage_collapse_test_exit_or_disable(mm))) + if (unlikely(collapse_test_exit_or_disable(mm))) goto breakouterloop; =20 VM_BUG_ON(khugepaged_scan.address < hstart || @@ -2473,12 +2473,12 @@ static unsigned int khugepaged_scan_mm_slot(unsigne= d int pages, enum scan_result =20 mmap_read_unlock(mm); mmap_locked =3D false; - *result =3D hpage_collapse_scan_file(mm, + *result =3D collapse_scan_file(mm, khugepaged_scan.address, file, pgoff, cc); fput(file); if (*result =3D=3D SCAN_PTE_MAPPED_HUGEPAGE) { mmap_read_lock(mm); - if (hpage_collapse_test_exit_or_disable(mm)) + if (collapse_test_exit_or_disable(mm)) goto breakouterloop; *result =3D try_collapse_pte_mapped_thp(mm, khugepaged_scan.address, false); @@ -2487,7 +2487,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned = int pages, enum scan_result mmap_read_unlock(mm); } } else { - *result =3D hpage_collapse_scan_pmd(mm, vma, + *result =3D collapse_scan_pmd(mm, vma, khugepaged_scan.address, &mmap_locked, cc); } =20 @@ -2520,7 +2520,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned = int pages, enum scan_result * Release the current mm_slot if this mm is about to die, or * if we scanned all vmas of this mm. */ - if (hpage_collapse_test_exit(mm) || !vma) { + if (collapse_test_exit(mm) || !vma) { /* * Make sure that if mm_users is reaching zero while * khugepaged runs here, khugepaged_exit will find @@ -2571,8 +2571,8 @@ static void khugepaged_do_scan(struct collapse_contro= l *cc) pass_through_head++; if (khugepaged_has_work() && pass_through_head < 2) - progress +=3D khugepaged_scan_mm_slot(pages - progress, - &result, cc); + progress +=3D collapse_scan_mm_slot(pages - progress, + &result, cc); else progress =3D pages; spin_unlock(&khugepaged_mm_lock); @@ -2816,8 +2816,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsi= gned long start, mmap_read_unlock(mm); mmap_locked =3D false; *lock_dropped =3D true; - result =3D hpage_collapse_scan_file(mm, addr, file, pgoff, - cc); + result =3D collapse_scan_file(mm, addr, file, pgoff, cc); =20 if (result =3D=3D SCAN_PAGE_DIRTY_OR_WRITEBACK && !triggered_wb && mapping_can_writeback(file->f_mapping)) { @@ -2831,8 +2830,7 @@ int madvise_collapse(struct vm_area_struct *vma, unsi= gned long start, } fput(file); } else { - result =3D hpage_collapse_scan_pmd(mm, vma, addr, - &mmap_locked, cc); + result =3D collapse_scan_pmd(mm, vma, addr, &mmap_locked, cc); } if (!mmap_locked) *lock_dropped =3D true; diff --git a/mm/mremap.c b/mm/mremap.c index 2be876a70cc0..eb222af91c2d 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -244,7 +244,7 @@ static int move_ptes(struct pagetable_move_control *pmc, goto out; } /* - * Now new_pte is none, so hpage_collapse_scan_file() path can not find + * Now new_pte is none, so collapse_scan_file() path can not find * this by traversing file->f_mapping, so there is no concurrency with * retract_page_tables(). In addition, we already hold the exclusive * mmap_lock, so this new_pte page is stable, so there is no need to get --=20 2.53.0