Re: [PATCH v2 07/20] hugetlb_vmemmap: Disable HVO sysctl if arch doesn't support HVO
From: Muchun Song
Date: Sat Nov 07 2026 - 02:02:23 EST
> On Oct 3, 2026, at 08:21, James Houghton <jthoughton@xxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxx>
> ---
> 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()) {
I'm wondering if we could put this architectural check into hugetlb_vmemmap_optimizable(),
> + if (vmemmap_optimize_enabled)
> + pr_info("vmemmap optimization not supported by hardware\n");
then, we do not need those code. If the current kernel does not support HVO,
then the sysctl does not exist. It's already a common case when the size of
struct page is not power of two. If users really want to know whether HVO
is enabled, they can check via this sysctl file. Therefore, we don't need to
print a log line.
Thanks,
Muchun
> + /*
> + * 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
>