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

From: Muchun Song

Date: Wed Nov 11 2026 - 01:47:20 EST




> On Nov 11, 2026, at 05:50, James Houghton <jthoughton@xxxxxxxxxx> wrote:
>
> On Fri, Nov 6, 2026 at 11:02 PM Muchun Song <muchun.song@xxxxxxxxx> wrote:
>>
>>
>>
>>> 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.
>
> Yeah, I can put arch_hugetlb_vmemmap_optimization_supported() into
> hugetlb_vmemmap_optimizable(), that will make the diffs slightly
> smaller. And yeah I can remove the print. I put it there mostly
> because it can be confusing. A command line that gets you HVO on one
> arm64 host might not give you HVO on another arm64 host, and the print
> would give a user a clue as to why.

We already have the log to indicate that, like:

pr_info("%d KiB vmemmap can be freed for a %s page\n",
hugetlb_vmemmap_optimizable_size(h) / SZ_1K, buf);

We will see **0 KiB** can be freed when hardware does not support HVO.

Thanks.