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=1796160426; b=HPk6A0Eh29oeK82SBPl63o7siibNeb+tb7VoQmrDttoUmU7YKcBGxsN3dMVLQHVvcIHZ 5pGjmQzrCMYBVix8TGo+QToKQ3nh/di6QXu44HOdzAiBmkIhMRwccSlEwKGz+OmF2F2Pw TlibJFuJ/key4JlQjQOwB3Qpi1hXMEnHNhwFUaspHdA/Cq/uiQ4BBNWLOXlNYkJSqaauL doCK+ghvILoTAY6MVU2yCwLArfEOJ6mv7rO2XZuHO8AAQuOJog42C7nEnF6rMld8+wLYV YGjd4sVa28Nty5l5t6Mf7yumF5FmG5cP8TTIbWFEJo/ZiINygOuU2qEMRPctUYwf2Xg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160426; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=AUdooNPhXgxiAb+ArRIzpJ9ducMgkD3YRDQ7RqHE0CQ=; b=Vh+V38qEyuSj4+fUdOwVKrkOT9iNke7VBUekqEKk2iHg7w7Hm3rGrPzVuYUNh6e3B6Rg EmsZurYEyxnR9vmbQXphy4RVckjpvoJ16RPoVNex2FszDKfxfIlHz04AVX+BUhykG9uho pEuB3+ZQCWksbtJh7a9TE7M2GHFxgw4NxtceJxSztY8oZ8xTsWIPNIJsFKZBxh8iLtpG6 DB1zi1GGeUM6X7PyXA2K9acEGUWuYDydiPr8l++ndiy/o2jzEm9HC6+iVNNdbQGCujnu2 rEAHGs316/iAxrirm6/6FtrGyQWIXSqloCKF7xGfzyQWwuoMB3NRrCrs1mcdtDmhjhw== 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="uEGYQAL/"; 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 8B8D1606A32F for ; Tue, 1 Dec 2026 21:27:06 +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=uEGYQAL/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0303F1F0089F; Tue, 1 Dec 2026 21:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796160426; bh=AUdooNPhXgxiAb+ArRIzpJ9ducMgkD3YRDQ7RqHE0CQ=; h=Date:To:From:In-Reply-To:References:Subject; b=uEGYQAL/Xzm9E+AMIfw+ZdU3E2hWQXfJH3OFx5xEiI20CG1aKei7//L9eql/P8C5J GxZ980M43fTf+ydcFJUgjeIZlTIlMp2S8piaXuqYpxMo7zG8VcKiLaWRc7yH1630dK PW3cl7MYmSQ3aY6x+LBfBctvSWlX+ZD/LeL3oKog= Date: Tue, 01 Dec 2026 13:27:05 -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-7-songmuchun@bytedance.com> References: <20261201095840.3034368-7-songmuchun@bytedance.com> Subject: + mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check.patch added to mm-new branch Message-Id: <20261201212706.0303F1F0089F@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/vmemmap-optimization: centralize the vmemmap optimization support check has been added to the -mm mm-new branch. Its filename is mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check.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/vmemmap-optimization: centralize the vmemmap optimization support check Date: Tue, 01 Dec 2026 17:58:40 +0800 Whether vmemmap optimization is supported depends on both the configuration and struct page having a power-of-two size. Open-coding this condition in several places makes the support contract easy to duplicate. Express this contract once in vmemmap_optimization_supported(). Make the existing checks use it. No functional change intended. Link: https://patch.msgid.link/20261201095840.3034368-7-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 include/linux/page-flags.h | 10 ++++++---- include/linux/vmemmap-optimization.h | 14 +++----------- 2 files changed, 9 insertions(+), 15 deletions(-) --- a/include/linux/page-flags.h~mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check +++ a/include/linux/page-flags.h @@ -193,6 +193,11 @@ enum pageflags { #define PAGEFLAGS_MASK ((1UL << NR_PAGEFLAGS) - 1) #ifndef __GENERATING_BOUNDS_H +static __always_inline bool vmemmap_optimization_supported(void) +{ + return IS_ENABLED(CONFIG_VMEMMAP_OPTIMIZATION) && + is_power_of_2(sizeof(struct page)); +} /* * For tail pages, if the size of struct page is power-of-2 ->compound_info @@ -210,10 +215,7 @@ static __always_inline bool compound_inf * but it requires validating that struct pages are naturally aligned * for all orders up to the MAX_FOLIO_ORDER, which can be tricky. */ - if (!IS_ENABLED(CONFIG_VMEMMAP_OPTIMIZATION)) - return false; - - return is_power_of_2(sizeof(struct page)); + return vmemmap_optimization_supported(); } static __always_inline unsigned long _compound_head(const struct page *page) --- a/include/linux/vmemmap-optimization.h~mm-vmemmap-optimization-centralize-the-vmemmap-optimization-support-check +++ a/include/linux/vmemmap-optimization.h @@ -21,9 +21,7 @@ * HVO which is only active if the size of struct page is a power of 2. */ #define MAX_FOLIO_VMEMMAP_ALIGN \ - (IS_ENABLED(CONFIG_VMEMMAP_OPTIMIZATION) && \ - is_power_of_2(sizeof(struct page)) ? \ - MAX_FOLIO_NR_PAGES * sizeof(struct page) : 0) + (vmemmap_optimization_supported() ? MAX_FOLIO_NR_PAGES * sizeof(struct page) : 0) /* The number of retained vmemmap pages with HVO enabled. */ #define VMEMMAP_OPTIMIZATION_PAGES 1 @@ -33,10 +31,7 @@ static inline bool vmemmap_optimizable_order(unsigned int order) { - if (!IS_ENABLED(CONFIG_VMEMMAP_OPTIMIZATION)) - return false; - - if (!is_power_of_2(sizeof(struct page))) + if (!vmemmap_optimization_supported()) return false; return order >= VMEMMAP_OPTIMIZATION_MIN_ORDER; @@ -115,10 +110,7 @@ static inline bool vmemmap_optimizable_p { const unsigned long nr_pages = 1UL << order; - if (!IS_ENABLED(CONFIG_VMEMMAP_OPTIMIZATION)) - return false; - - if (!is_power_of_2(sizeof(struct page))) + if (!vmemmap_optimization_supported()) return false; return (pfn & (nr_pages - 1)) >= VMEMMAP_OPTIMIZATION_NR_STRUCT_PAGES; _ 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