From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Muhammad Usama Anjum <usama.anjum@arm.com>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
Zi Yan <ziy@nvidia.com>, Pedro Falcato <pfalcato@suse.de>,
Ryan Roberts <ryan.roberts@arm.com>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Mike Rapoport <rppt@kernel.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
linux-s390@vger.kernel.org
Subject: Re: mm: opaque hardware page-table entry handles
Date: Tue, 21 Jul 2026 14:40:57 +0200 [thread overview]
Message-ID: <20260721124057.2820903Adf-agordeev@linux.ibm.com> (raw)
In-Reply-To: <6110202c-057b-4701-8c04-1a76ee7bb9ab@arm.com>
On Wed, Jul 15, 2026 at 05:15:36PM +0100, Muhammad Usama Anjum wrote:
> Hi,
>
> [Moved some already involved people to To. So they can help with the plan
> details mentioned below.]
>
> On 07/07/2026 2:17 pm, David Hildenbrand (Arm) wrote:
> > [...]
> >
> >>>
> >>> typedef struct {
> >>> pte_t __pte;
> >>> } hw_pte_t;
> >>>
> >>> And then simply use
> >>>
> >>> hw_pte_t *hptep;
> >> Make sense. So you have suggested to just hide put pte_t inside a structure
> >> instead of complex structure of pointer. I've tried to implement and it reduces
> >> churn enormously.
> >
> > Right. And for most architectures we can probable leave both types be the same
> > under the hood.
> >
> > So we'd only have to convert common code first, and can then e.g., look into
> > making architectures that care about the difference (e.g., arm64) actually have
> > it be two separate types.
> It makes a lot of sense.
>
> Let's even divide the series into more parts as there are several places where
> conversion is controversial. (Xi Yan had mentioned one example earlier in this
> thread.) Most of those controversial conversions are pmd related. I propose
> that we convert pte_t first, then pmd_t and others. It'll keep the number of
> patches manageable and easier to review.
>
> I think wider agreement for this approach will be very helpful before I post the
> actual code.
>
> >
> > Just an idea to further reduce the churn and limit it only to core code (because
> > I saw some very ugly stuff in some arch code that would make such a conversion
> > harder).
> >
> > [...]
> >
> >>> Why do we need this and what would we use it for?
> >> The idea was that there should be two different functions to read value. Let's
> >> leave this out of the first initial series. It is complicating the original
> >> proposal.
> >
> > Right, let's leave that out for now. I'm currently working with Levi on an
> > approach that tries to avoid the overhead due to READ_ONCE with folded page
> > tables. [1]
> So you are referring to page folding improvements. I also stumbled upon those
> while doing a dirty implementation.
>
> >
> > We're still struggling with some bits, but looks like we can make it fly and
> > have it be fairly robust.
> >
> > With that, maybe there is no reason left to have separate pXXp_get() vs.
> > pXXp_get_once(). TBD :)
> Yeah, I was reviewing that series earlier today. I've not looked deeply, but it
> seems there are still a lot of cases where (mostly) pmd is getting dereferenced
> directly. To complete the conversion, direct dereferences need to be converted
> into an API. I've been thinking if there should be a dereference macro or we
> must always use pmdp_get() even though it ensures ordering. It may add excessive
> ordering in some functions if pmdp_get() is getting called multiple times. But
> storing its output in a tmp variable would solve this.
>
> Do you agree with converting all direct dereferences into pXXp_get()?
For the clarity (e.g. on the PTE level) is it goint to be converted to?
pte_t ptep_get(hw_pte_t *ptep);
pte_t set_pte(hw_pte_t *ptep, pte_t pte);
While variables on stack are still may be dereferenced directly via pte_t*?
What about unlinked/temporary page tables in memory?
> > [1] https://lore.kernel.org/all/08ecabe9-0664-4aea-82fb-f9cb1739f762@kernel.org/
> >
> > [...]
> >
> >>>
> >>> I'm still not sure about the _once() really, and if we need that right now. We
> >>> survived without is so far, why do we need it now?
> >> The idea is to convert all current pXXp_get() to pXXp_get_once() and convert raw
> >> dereference to pXXp_get(). Let's keep this idea separate for the other work. Let's
> >> discuss it later sometime again later.
> >
> > Sounds good.
>
> I've tried to do conversions already. Converting by call hierarchy wise is very
> difficult and error prune.
>
> Converting component by component (such as page walk, huge page) is also difficult
> as code is tangled. Some helper which is getting used in one component is also used
> in another component.
>
> I see the following way forward:
> * Add the new type
> * Identify which functions need explicitly pointer to a stack variable. These
> must not be converted. These variables must be renamed to a common name. For
> pte_t pointers on stack some functions already use ptentp, which is unique name
> if we look at generic code. So ptentp would be used for all such variables.
> * One commit per controversial change would be done at this point. We need new
> separate function for stack types. Also we can do more renaming to a name which
> will not be converted.
> * Run Coccinelle script directory-by-directory which would ignore converting any
> ptentp (and similarly for other types). Coccinelle doesn't converts in some case
> (pte_t *a. *b) which can be done by hand at this point.
> * Update any remaining functions
What is the approach to STRICT_MM_TYPECHECKS?
We would like to keep it, and I guess some other architectures too.
> --
> Thanks,
> Usama
Thanks!
next parent reply other threads:[~2026-07-21 12:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <74182e50-b54f-4d2d-a27f-3a59a538d6bc@arm.com>
[not found] ` <31d36023-d728-4eee-90f8-158c7066f565@kernel.org>
[not found] ` <e22407d8-4509-4a53-9ba4-491b9d5c5ef7@arm.com>
[not found] ` <4bfeb697-9c1f-4316-96bb-9bfd66f959df@kernel.org>
[not found] ` <6110202c-057b-4701-8c04-1a76ee7bb9ab@arm.com>
2026-07-21 12:40 ` Alexander Gordeev [this message]
2026-07-23 8:21 ` mm: opaque hardware page-table entry handles Muhammad Usama Anjum
2026-07-23 16:38 ` David Hildenbrand (Arm)
2026-07-23 17:01 ` Muhammad Usama Anjum
2026-07-24 9:30 ` Pedro Falcato
2026-07-24 10:34 ` Muhammad Usama Anjum
2026-07-24 12:57 ` Pedro Falcato
2026-07-24 6:47 ` Alexander Gordeev
2026-07-27 7:11 ` Alexander Gordeev
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=20260721124057.2820903Adf-agordeev@linux.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=pfalcato@suse.de \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=samuel.holland@sifive.com \
--cc=usama.anjum@arm.com \
--cc=will@kernel.org \
--cc=ziy@nvidia.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