[PATCH v2 07/20] hugetlb_vmemmap: Disable HVO sysctl if arch doesn't support HVO

James Houghton jthoughton at google.com
Fri Oct 2 17:21:10 PDT 2026


Do not create the vm.hugetlb_optimize_vmemmap sysctl when the
architecture lacks support. This serves only to avoid confusion for
users.

arm64 support for HVO is conditional on certain hardware features being
enabled for all online CPUs. By the time hugetlb_vmemmap_init() runs,
all secondary CPUs will have started, and the system feature set will
have stabilized, including HVO-through-BBM, which
arch_hugetlb_vmemmap_optimization_supported() checks for.

Signed-off-by: James Houghton <jthoughton at google.com>
---
 mm/hugetlb_vmemmap.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 8596a462fee6..817ce39d4cf3 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -763,6 +763,21 @@ static int __init hugetlb_vmemmap_init(void)
 	/* HUGETLB_VMEMMAP_RESERVE_SIZE should cover all used struct pages */
 	BUILD_BUG_ON(__NR_USED_SUBPAGE > HUGETLB_VMEMMAP_RESERVE_PAGES);
 
+	/*
+	 * Architectures that need to probe CPU support for HVO have done
+	 * such probing now. arch_hugetlb_vmemmap_optimization_supported()
+	 * will return the correct value.
+	 */
+	if (!arch_hugetlb_vmemmap_optimization_supported()) {
+		if (vmemmap_optimize_enabled)
+			pr_info("vmemmap optimization not supported by hardware\n");
+		/*
+		 * Return early to avoid setting up the hugetlb vmemmap
+		 * sysctls; HVO is not usable.
+		 */
+		return 0;
+	}
+
 	for_each_hstate(h) {
 		if (hugetlb_vmemmap_optimizable(h)) {
 			register_sysctl_init("vm", hugetlb_vmemmap_sysctls);
-- 
2.56.0.rc1.315.gc6ed9934b7-goog




More information about the linux-arm-kernel mailing list