From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796160417; b=nRgviMqV12hXOWgi1hrAsFb0QPmp0/akmEpgUcl0zZ44CQhjWwcijPG9zey+HqJN2bCI QZS62dH5fuxZ6yazjqwOtrJHtZs9se5OqBACcdeFgF2G6fy/7ae7NFENs6MnQ8QWXCFQ5 J9ui78ZQnFTFlUVFHJpvODuPvzsNM1yIUaGeOGzvXb2kEF0ygQXP9qby0Pl3ZBT6wkz/h 23Xvxq7Cf2kcdPQAINTt3dsUOTQQyTQyq1IZ51qy7VGkRXzdhF9yy2Q0BQcOUoCdyDjuV D9pHWKgP+BjwooohpKd2BIIkgYo7YPYvjdcUkDe1xipSq0lyxssfIIK38DyDU0wXX0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160417; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=tEUuZ7l/utOP4eI0WZtbBBk101Ru1kHfjywB1YlVpKI=; b=M5N7+V/R6spYyAF2r9eNXxK5kWBbuSWwXnuwVU45JNKeh6I/oblaYNgzxp9Yl5hTyKGb 8C948QgIPojtRFKLDCSRkYMgkFTDtkpxJuh6kX3BuLnxDHrkY67F+hyXdSwR1alSsP69V 5oN/iAzn+yoZTBlAXOLxjPy3iwEmIYj6wtYQ9YjMb6a01Qp9vh0fnxupeSXzOEMBnX4Cz wNmzn/epSTf/rTIsLsmtXsoKoqLDLlugkki+gq+FjUUn66aOcdyNNWrvjOy2/Y4PBxljD Il8H6CN8Mcq2GjHyFMQnkrRT5wiVZOlapr+9lzWqtQWpx/In1Nj0oOrN7XfakqFn91Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=PH+Fu4vm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F4A0606A31A for ; Tue, 1 Dec 2026 21:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=PH+Fu4vm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00A3D1F00898; Tue, 1 Dec 2026 21:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796160417; bh=tEUuZ7l/utOP4eI0WZtbBBk101Ru1kHfjywB1YlVpKI=; h=Date:To:From:In-Reply-To:References:Subject; b=PH+Fu4vmFe82npqyvK8GZ+zkBKwPnTG2s1c5keNYvfbDCwwtmZVofmgR/WVrg3YMp pFN/wgm7AV9TN0P/QHN4cDEeeSr6/GO9gz1PNUhWzeder8Vu7l+ZJGiPo5GvTt0/z+ 3pfSgB6FvNz8koEDd6LDpWYQs96BaUeT/PfuTpT8= Date: Tue, 01 Dec 2026 13:26:56 -0800 To: mm-commits@vger.kernel.org,rppt@kernel.org,qi.zheng@linux.dev, osalvador@suse.de,nobody@kernel.org,lance.yang@linux.dev,david@kernel.org, songmuchun@bytedance.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261201095840.3034368-4-songmuchun@bytedance.com> References: <20261201095840.3034368-4-songmuchun@bytedance.com> Subject: + mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument.patch added to mm-new branch Message-Id: <20261201212657.00A3D1F00898@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/hugetlb_vmemmap: drop the redundant hstate argument has been added to the -mm mm-new branch. Its filename is mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Muchun Song Subject: mm/hugetlb_vmemmap: drop the redundant hstate argument Date: Tue, 01 Dec 2026 17:58:37 +0800 The single-folio optimize path and the single- and multi-folio restore paths derive the vmemmap range, order, and NUMA node directly from each folio. Their hstate argument is therefore no longer used. Remove it from those paths and their internal helpers. Update the callers accordingly. Keep the hstate argument in the bulk optimize path so an ineligible hstate can be rejected before iterating and pteifying the folio list. No functional change intended. Link: https://patch.msgid.link/20261201095840.3034368-4-songmuchun@bytedance.com Signed-off-by: Muchun Song Signed-off-by: Andrew Morton Reviewed-by: Lance Yang Cc: Oscar Salvador Cc: Mike Rapoport Cc: David Hildenbrand Cc: Qi Zheng Cc: nobody mm/hugetlb.c | 12 ++++++------ mm/hugetlb_vmemmap.c | 28 +++++++++++----------------- mm/hugetlb_vmemmap.h | 18 ++++++++---------- 3 files changed, 25 insertions(+), 33 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument +++ a/mm/hugetlb.c @@ -1521,7 +1521,7 @@ static void __update_and_free_hugetlb_fo * is no longer identified as a hugetlb page. hugetlb_vmemmap_restore_folio * can only be passed hugetlb pages and will BUG otherwise. */ - if (clear_flag && hugetlb_vmemmap_restore_folio(h, folio)) { + if (clear_flag && hugetlb_vmemmap_restore_folio(folio)) { spin_lock_irq(&hugetlb_lock); /* * If we cannot allocate vmemmap pages, just refuse to free the @@ -1673,7 +1673,7 @@ static void bulk_vmemmap_restore_error(s * be freed without restoring vmemmap. */ if (folio_test_hugetlb(folio)) { - if (hugetlb_vmemmap_restore_folio(h, folio)) { + if (hugetlb_vmemmap_restore_folio(folio)) { spin_lock_irq(&hugetlb_lock); add_hugetlb_folio(h, folio, true); spin_unlock_irq(&hugetlb_lock); @@ -1703,7 +1703,7 @@ static void update_and_free_pages_bulk(s * in an effort to make forward progress. */ retry: - ret = hugetlb_vmemmap_restore_folios(h, folio_list, &non_hvo_folios); + ret = hugetlb_vmemmap_restore_folios(folio_list, &non_hvo_folios); if (ret < 0) { bulk_vmemmap_restore_error(h, folio_list, &non_hvo_folios); goto retry; @@ -1966,7 +1966,7 @@ static struct folio *alloc_fresh_hugetlb folio = only_alloc_fresh_hugetlb_folio(h, gfp_mask, nid, nmask, NULL); if (folio) - hugetlb_vmemmap_optimize_folio(h, folio); + hugetlb_vmemmap_optimize_folio(folio); return folio; } @@ -2135,7 +2135,7 @@ retry: * non-vmemmap optimized hugetlb folios. */ if (folio_test_hugetlb(folio)) { - rc = hugetlb_vmemmap_restore_folio(h, folio); + rc = hugetlb_vmemmap_restore_folio(folio); if (rc) { spin_lock_irq(&hugetlb_lock); add_hugetlb_folio(h, folio, adjust_surplus); @@ -4020,7 +4020,7 @@ static long demote_free_hugetlb_folios(s LIST_HEAD(dst_list); LIST_HEAD(ret_list); - rc = hugetlb_vmemmap_restore_folios(src, src_list, &ret_list); + rc = hugetlb_vmemmap_restore_folios(src_list, &ret_list); list_splice_init(&ret_list, src_list); /* --- a/mm/hugetlb_vmemmap.c~mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument +++ a/mm/hugetlb_vmemmap.c @@ -414,8 +414,7 @@ static int __init hugetlb_vmemmap_optimi } early_param("hugetlb_free_vmemmap", hugetlb_vmemmap_optimize_param); -static int __hugetlb_vmemmap_restore_folio(const struct hstate *h, - struct folio *folio, unsigned long flags) +static int __hugetlb_vmemmap_restore_folio(struct folio *folio, unsigned long flags) { int ret; @@ -436,20 +435,18 @@ static int __hugetlb_vmemmap_restore_fol * hugetlb_vmemmap_restore_folio - restore previously optimized (by * hugetlb_vmemmap_optimize_folio()) vmemmap pages which * will be reallocated and remapped. - * @h: struct hstate. * @folio: the folio whose vmemmap pages will be restored. * * Return: %0 if @folio's vmemmap pages have been reallocated and remapped, * negative error code otherwise. */ -int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio) +int hugetlb_vmemmap_restore_folio(struct folio *folio) { - return __hugetlb_vmemmap_restore_folio(h, folio, 0); + return __hugetlb_vmemmap_restore_folio(folio, 0); } /** * hugetlb_vmemmap_restore_folios - restore vmemmap for every folio on the list. - * @h: hstate. * @folio_list: list of folios. * @non_hvo_folios: Output list of folios for which vmemmap exists. * @@ -460,9 +457,8 @@ int hugetlb_vmemmap_restore_folio(const * encountered. The folio that experienced the error and all * non-processed folios will remain on folio_list. */ -long hugetlb_vmemmap_restore_folios(const struct hstate *h, - struct list_head *folio_list, - struct list_head *non_hvo_folios) +long hugetlb_vmemmap_restore_folios(struct list_head *folio_list, + struct list_head *non_hvo_folios) { struct folio *folio, *t_folio; long restored = 0; @@ -471,7 +467,7 @@ long hugetlb_vmemmap_restore_folios(cons list_for_each_entry_safe(folio, t_folio, folio_list, lru) { if (folio_test_hugetlb_vmemmap_optimized(folio)) { - ret = __hugetlb_vmemmap_restore_folio(h, folio, flags); + ret = __hugetlb_vmemmap_restore_folio(folio, flags); if (ret) break; restored++; @@ -488,8 +484,7 @@ long hugetlb_vmemmap_restore_folios(cons return ret; } -static int __hugetlb_vmemmap_optimize_folio(const struct hstate *h, - struct folio *folio, +static int __hugetlb_vmemmap_optimize_folio(struct folio *folio, struct list_head *vmemmap_pages, unsigned long flags) { @@ -518,7 +513,6 @@ static int __hugetlb_vmemmap_optimize_fo /** * hugetlb_vmemmap_optimize_folio - optimize @folio's vmemmap pages. - * @h: struct hstate. * @folio: the folio whose vmemmap pages will be optimized. * * This function only tries to optimize @folio's vmemmap pages and does not @@ -526,7 +520,7 @@ static int __hugetlb_vmemmap_optimize_fo * can use folio_test_hugetlb_vmemmap_optimized(@folio) to detect if @folio's * vmemmap pages have been optimized. */ -void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio) +void hugetlb_vmemmap_optimize_folio(struct folio *folio) { LIST_HEAD(vmemmap_pages); @@ -534,7 +528,7 @@ void hugetlb_vmemmap_optimize_folio(cons return; guard(rwsem_read)(&vmemmap_remap_rwsem); - __hugetlb_vmemmap_optimize_folio(h, folio, &vmemmap_pages, 0); + __hugetlb_vmemmap_optimize_folio(folio, &vmemmap_pages, 0); free_vmemmap_page_list(&vmemmap_pages); } @@ -573,7 +567,7 @@ void hugetlb_vmemmap_optimize_folios(str list_for_each_entry(folio, folio_list, lru) { int ret; - ret = __hugetlb_vmemmap_optimize_folio(h, folio, &vmemmap_pages, flags); + ret = __hugetlb_vmemmap_optimize_folio(folio, &vmemmap_pages, flags); /* * Pages to be freed may have been accumulated. If we @@ -587,7 +581,7 @@ void hugetlb_vmemmap_optimize_folios(str flush_tlb_all(); free_vmemmap_page_list(&vmemmap_pages); INIT_LIST_HEAD(&vmemmap_pages); - __hugetlb_vmemmap_optimize_folio(h, folio, &vmemmap_pages, flags); + __hugetlb_vmemmap_optimize_folio(folio, &vmemmap_pages, flags); } } --- a/mm/hugetlb_vmemmap.h~mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument +++ a/mm/hugetlb_vmemmap.h @@ -15,11 +15,10 @@ #ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP extern struct rw_semaphore vmemmap_remap_rwsem; -int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio); -long hugetlb_vmemmap_restore_folios(const struct hstate *h, - struct list_head *folio_list, - struct list_head *non_hvo_folios); -void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio); +int hugetlb_vmemmap_restore_folio(struct folio *folio); +long hugetlb_vmemmap_restore_folios(struct list_head *folio_list, + struct list_head *non_hvo_folios); +void hugetlb_vmemmap_optimize_folio(struct folio *folio); void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list); void hugetlb_vmemmap_optimize_bootmem_page(unsigned long pfn, unsigned int order); @@ -34,20 +33,19 @@ static inline void hugetlb_vmemmap_write } #else -static inline int hugetlb_vmemmap_restore_folio(const struct hstate *h, struct folio *folio) +static inline int hugetlb_vmemmap_restore_folio(struct folio *folio) { return 0; } -static inline long hugetlb_vmemmap_restore_folios(const struct hstate *h, - struct list_head *folio_list, - struct list_head *non_hvo_folios) +static inline long hugetlb_vmemmap_restore_folios(struct list_head *folio_list, + struct list_head *non_hvo_folios) { list_splice_init(folio_list, non_hvo_folios); return 0; } -static inline void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio) +static inline void hugetlb_vmemmap_optimize_folio(struct folio *folio) { } _ Patches currently in -mm which might be from songmuchun@bytedance.com are powerpc-mm-make-vmemmap_populate_compound_pages-static.patch powerpc-mm-drop-powerpc-vmemmap_can_optimize.patch mm-sparse-vmemmap-drop-vmemmap_can_optimize.patch mm-sparse-vmemmap-drop-pgmap-from-vmemmap-population-apis.patch mm-hugetlb_vmemmap-fix-hwpoison-state-races-during-optimization.patch mm-hugetlb_vmemmap-fix-pmd-split-tlb-flush-race.patch mm-hugetlb_vmemmap-fix-deadlock-during-pmd-split.patch mm-list_lru-fix-potential-infinite-loop-on-xa-node-allocation-failure.patch mm-mm_init-verify-zones-for-template-initialized-pages.patch mm-mm_init-factor-out-common-struct-page-initialization.patch mm-mm_init-simplify-zone-device-page-initialization.patch mm-mm_init-factor-out-compound-page-initialization.patch mm-hugetlb-drop-boot-time-hvo-handling-for-gigantic-folios.patch mm-hugetlb-initialize-all-struct-pages-for-bootmem-hugepages.patch mm-hugetlb-use-common-compound-page-initialization-helper.patch mm-mm_init-make-__init_single_page-static.patch mm-cma-centralize-cma-pageblock-initialization.patch mm-cma-localize-init_cma_pageblock-to-cmac.patch mm-mm_init-move-pageblock-migratetype-init-to-memmap-helpers.patch kmsan-encapsulate-per-page-metadata-access.patch mm-page_ext-fix-client-data-alignment.patch mm-page_ext-always-use-vmalloc-for-section-page-extensions.patch mm-page_ext-use-common-allocation-and-initialization-entry-points.patch mm-page_ext-allocate-page-extensions-early-for-sparsemem.patch mm-page_ext-inline-unchecked-page-extension-lookup.patch kmsan-fix-metadata-loss-during-hugetlb-struct-page-reinitialization.patch mm-hugetlb_vmemmap-remove-the-vmemmap-savings-boot-message.patch mm-hugetlb_vmemmap-fold-vmemmap_should_optimize-into-its-callers.patch mm-hugetlb_vmemmap-drop-the-redundant-hstate-argument.patch mm-hugetlb_vmemmap-open-code-free_vmemmap_page.patch mm-hugetlb_vmemmap-drop-obsolete-restore-refcount-warning.patch mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check.patch