Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: James Houghton <jthoughton@google.com>
Cc: Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Oscar Salvador <osalvador@suse.de>,
	Nikos Nikoleris <nikos.nikoleris@arm.com>,
	Linu Cherian <linu.cherian@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	David Hildenbrand <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ryan Roberts <ryan.roberts@arm.com>,
	Nanyong Sun <sunnanyong@huawei.com>, Yu Zhao <yuzhao@google.com>,
	Frank van der Linden <fvdl@google.com>,
	David Rientjes <rientjes@google.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH 00/18] Another attempt at HVO support on arm64
Date: Tue, 14 Jul 2026 14:40:24 +0800	[thread overview]
Message-ID: <BD3A6158-5794-49AF-A7F7-677F748D30D8@linux.dev> (raw)
In-Reply-To: <CADrL8HXZiHcwYR8Hcoje4c9HZBNSCmQcG-3y2f6AhJksYQRvhg@mail.gmail.com>



> On Jul 13, 2026, at 12:09, James Houghton <jthoughton@google.com> wrote:
> 
> On Thu, Jul 9, 2026 at 8:41 PM Muchun Song <muchun.song@linux.dev> wrote:
>> 
>>> On Jul 10, 2026, at 03:04, James Houghton <jthoughton@google.com> wrote:
>>> 
>>> On Thu, Jul 9, 2026 at 2:55 AM Muchun Song <muchun.song@linux.dev> wrote:
>>>>> On Jul 9, 2026, at 00:49, James Houghton <jthoughton@google.com> wrote:
>>>>> 
>>>>> On Wed, Jul 8, 2026 at 1:41 AM Muchun Song <muchun.song@linux.dev> wrote:
>>>>>> Do you mean that the support for AF might vary across different CPUs?
>>>>>> I'm not that familiar with arm64, so it seems a bit strange to me that
>>>>>> such basic hardware features can differ so much from one CPU to another.
>>>>> 
>>>>> Yes, hardware updates of the Access Flag is a per-CPU feature. It is
>>>>> available for a CPU to use if TCR_EL1.HA is set. TCR_EL1 is a system
>>>>> register; each CPU has its own. (Linux will always enable HW AF for a
>>>>> CPU when it is onlined[1] if support is advertised, so we simply need
>>>>> to check if support is advertised to know that it is in fact enabled.)
>>>>> 
>>>>> These days it is not uncommon for a system to have two (or more?)
>>>>> different core implementations, like with "fast" cores and "efficient"
>>>>> cores.
>>>>> 
>>>>> [1] See the CONFIG_ARM64_HW_AFDBM bits in arch/arm64/mm/proc.S
>>>> 
>>>> Thanks for your detailed explanation. When enabling HVO via the cmdline,
>>>> can we simply prevent CPUs that do not support AF from coming online?
>>>> Would implementing it this way be much simpler? In practice, developers
>>>> definitely know whether the current system is suitable for enabling HVO.
>>>> If some CPUs do not support AF, they would just need to evaluate the
>>>> trade-off between memory savings and having fewer online CPUs than expected.
>>>> 
>>>> For scenarios where HVO is enabled via sysctl, we simply need to check
>>>> if all CPUs support AF. If any do not, the system should return an error.
>>>> 
>>>> Then, we can proceed with the Pre-HVO.
>>> 
>>> I don't think it makes sense to try to implement pre-HVO.
>>> 
>>> We cannot do HVO if any boot CPUs do not support HW AF, as HW AF will
>>> be required to free the HugeTLB pages later, which we should continue
>>> to support. Pre-HVO (today anyway) happens before all boot CPUs are
>>> onlined. IMO it is not okay to prevent boot CPUs from onlining.
>> 
>> When the boot CPU starts, it first checks if the hardware (the current
>> boot CPU) supports AF (The selection of the Boot CPU is critical here
>> If the user really wants to enable HVO). If AF is supported and HVO is
>> enabled via cmdline, we perform a Pre-HVO. Subsequently, any CPUs that
>> do not support AF will be prevented from coming online.
> 
> I understand. I don't think we should do this. I think it's much
> better to always be able to start all boot CPUs[1] and simply rely on
> "normal" HVO.
> 
> [1] Just to be clear on terminology, I'm using "boot CPUs" to refer to
> all CPUs that are onlined at boot-time, not just to *the* boot CPU
> that starts the kernel.

Thanks for the clarification. We previously had different understandings
of the boot CPU, but that should be resolved now.

> 
>> 
>> If the boot CPU does not support AF, enabling HVO is not permitted—neither
>> via cmdline nor sysctl. All CPUs are allowed to be online.
>> 
>> Once the system has started, there is only one way to enable HVO, and
>> that is through sysctl. 1) If the current system includes any CPUs that do
>> not support AF, enabling HVO is not permitted (unless the user chooses to
>> take these CPUs that don't support AF offline). 2) If all online CPUs in the
>> current system support AF, then HVO can be enabled. In this case, the
>> system must also block any CPUs that do not support AF from coming online
>> in the future.
> 
> An approach similar to this is implemented in this series: if there
> are (or were) any HVOed folios, onlining a CPU without HW AF is not
> allowed. If HW AF is not supported by any onlined CPU, HVO cannot
> proceed (though it will appear to be enabled).
> 
> I probably should have integrated
> `arch_hugetlb_vmemmap_optimization_supported()` and a `hvo_status`
> check into the sysctl handler for HVO. I'll do this if it is still
> relevant in v2.
> 
>> Of course, if a user specifically wants those CPUs to be
>> allowed to come online, they can choose to disable HVO first (At the same time,
>> this means that the HVO-optimized HugeTLB must be freed first as well).
> 
> I could make it so that, if there are no HVOed pages anymore, onlining
> incompatible CPUs becomes permitted again. I don't really see the need
> to do this.
> 
>> My proposal assumes that even though the system supports different types of
>> CPUs, their support for AF (I suppose this is a very basic feature nowadays)
>> is generally the same. I believe that for servers (Only servers stand to
>> benefit more from HVO), there shouldn't be a mix of those that support AF
>> and those that don't. At the very least, such a situation would be extremely
>> uncommon. I believe this may be acceptable. That said, if we go this route,
>> is there a way to simplify the code implementation even further?. Of course,
>> this is just my personal speculation. Please let me know if I've missed
>> anything.
> 
> I agree that systems where HVO is relevant are very unlikely to have
> mixed support for HW AF.
> 
> I don't think the approach you're suggesting in this email (as I've
> understood it) simplifies this series.
> 
> I don't want to mess with the arm64 cpufeature bits more than I've
> done here; preventing boot CPUs from onlining will certainly be more
> work. :) And then your other suggestions seem to be quite similar to
> what is already in these patches.
> 
> I am happy to get rid of the "disable HVO if it is unused and a CPU
> without support is onlined" part though and replace it with something
> similar (the simplification from the other thread[2]).

Thanks for the explanation! My main goal right now is to keep the initial
implementation as simple as possible. If any of my suggestions aren't quite
on point, feel free to adjust them as you see fit.

Thanks.

> 
> [2] https://lore.kernel.org/linux-mm/674EC6D6-B1F7-447D-B462-861ECA5A99B7@linux.dev/




  reply	other threads:[~2026-07-14  6:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  3:11 [PATCH 00/18] Another attempt at HVO support on arm64 James Houghton
2026-07-08  3:11 ` [PATCH 01/18] hugetlb_vmemmap: Always flush TLB if needed upon PTE remapping James Houghton
2026-07-08  3:11 ` [PATCH 02/18] hugetlb_vmemmap: Move vmemmap_get_tail up James Houghton
2026-07-08  3:11 ` [PATCH 03/18] hugetlb_vmemmap: Leave pages partially HVOed upon restore failure James Houghton
2026-07-08  3:11 ` [PATCH 04/18] hugetlb_vmemmap: Use try_update_vmemmap_pte to update in-use PTEs James Houghton
2026-07-08  3:11 ` [PATCH 05/18] hugetlb_vmemmap: Allow architectures not to allow HVO at runtime James Houghton
2026-07-08  3:11 ` [PATCH 06/18] arm64: Rename cpu_has_hw_af to system_has_hw_af James Houghton
2026-07-08  3:11 ` [PATCH 07/18] arm64: Add system_supports_hvo James Houghton
2026-07-08  3:11 ` [PATCH 08/18] arm64: Implement try_update_vmemmap_pte using the AF trick James Houghton
2026-07-08  3:11 ` [PATCH 09/18] arm64: Prevent HVO if the HVO system feature is not enabled James Houghton
2026-07-08  3:11 ` [PATCH 10/18] arm64: Support hugetlb vmemmap optimization James Houghton
2026-07-08  3:11 ` [PATCH 11/18] hugetlb_vmemmap: Use try_populate_vmemmap_pmd for replacing in-use PMDs James Houghton
2026-07-08  3:11 ` [PATCH 12/18] arm64: Implement try_populate_vmemmap_pmd using AF trick James Houghton
2026-07-08  3:11 ` [PATCH 13/18] arm64: Drop BBML2_NOABORT requirement for HVO James Houghton
2026-07-08  3:11 ` [PATCH 14/18] hugetlb_vmemmap: Rename mm/hugetlb_vmemmap.h to mm/hugetlb_vmemmap_internal.h James Houghton
2026-07-08  3:11 ` [PATCH 15/18] hugetlb_vmemmap: Add a way to permanently disable HVO when needed James Houghton
2026-07-08  3:11 ` [PATCH 16/18] arm64: Allow "optional" CPU features to be required sometimes James Houghton
2026-07-08  3:11 ` [PATCH 17/18] arm64: Permit onlining of HVO-incompatible late CPUs if HVO is not in use James Houghton
2026-07-08  3:11 ` [PATCH 18/18] arm64: Remove user-selectable HVO Kconfig James Houghton
     [not found] ` <FC9E78F0-8FF7-44AF-A848-8401B4702488@linux.dev>
2026-07-08 16:49   ` [PATCH 00/18] Another attempt at HVO support on arm64 James Houghton
2026-07-09  9:54     ` Muchun Song
2026-07-09 19:04       ` James Houghton
2026-07-10  3:40         ` Muchun Song
2026-07-13  4:09           ` James Houghton
2026-07-14  6:40             ` Muchun Song [this message]
2026-07-11  2:22         ` Muchun Song
2026-07-13  4:09           ` James Houghton
2026-07-09  9:58 ` David Hildenbrand (Arm)
2026-07-10  4:58 ` Muchun Song
2026-07-13  4:59   ` James Houghton
2026-07-13  7:41     ` Muchun Song
2026-07-13 11:26       ` Dev Jain
2026-07-14  8:46 ` Pedro Falcato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BD3A6158-5794-49AF-A7F7-677F748D30D8@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=fvdl@google.com \
    --cc=jthoughton@google.com \
    --cc=linu.cherian@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=nikos.nikoleris@arm.com \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=ryan.roberts@arm.com \
    --cc=sunnanyong@huawei.com \
    --cc=will@kernel.org \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox