From: Brendan Jackman <jackmanb@google.com>
To: Mike Rapoport <rppt@kernel.org>, Brendan Jackman <jackmanb@google.com>
Cc: <lsf-pc@lists.linux-foundation.org>, <linux-mm@kvack.org>,
<owner-linux-mm@kvack.org>
Subject: Re: [LSF/MM/BPF TOPIC] A pagetable library for the kernel?
Date: Wed, 25 Feb 2026 17:06:02 +0000 [thread overview]
Message-ID: <DGO7GH6XSF27.2ZHEU51SRDLJA@google.com> (raw)
In-Reply-To: <aZw5z5Ti-gH3bDUL@kernel.org>
On Mon Feb 23, 2026 at 11:28 AM UTC, Mike Rapoport wrote:
> On Thu, Feb 19, 2026 at 05:51:09PM +0000, Brendan Jackman wrote:
>> As work on Address Space Isolation [0] trudges slowly along (next series coming
>> soon™... I promise... some details of the plan are in [0]) I've been running
>> into a common issue whenever I try to do new stuff with the kernel address
>> space: We have too many sets of pagetable manipulation routines, and yet we
>> don't have one that suits ASI's needs.
>>
>> Similarly, I'm currently working on support for efficiently unmapping
>> guest_memfd pages from the physmap (an extension to [1]) - in this case I've run
>> into very much the same issues as with ASI.
>>
>> Here are some areas of the kernel that manipulate pagetables:
>>
>> 1. The collection of APIs that are specific to userspace pagetables: mmu_gather,
>> mm/pagewalk.c, some vm_fault logic, all that good stuff.
>>
>> 2. The set_memory_* and set_direct_map_* APIs. (Which are implemented per-arch).
>>
>> 3. Some non-userspace-specific APIs in mm/memory.c, such as
>> apply_to_page_range().
>>
>> 4. mm/vmalloc.c
>>
>> 5. Highmem logic such as kmap_local_*
>>
>> 6. Boot and memory-hotplug support code (your architecture's version of
>> arch/x86/mm/init_64.c).
>>
>> 7. x86's KPTI
>>
>> 8. x86's LDT logic
>>
>> (At LPC I started enumerating these off the top of my head and multiple people
>> spoke out with more examples I hadn't thought of - please join in if you can see
>> more!)
>>
>> By and large, these components are designed completely independently from one
>> another. This is made possible by the smart design of the low-level helper API
>> (pte_present() and friends), and it does lead to nice explicit coding style.
>
> By and large, lots of functionality that deals with kernel page tables was
> added ad-hoc, like e.g. adopting set_memory() designed for DEBUG_PAGE_ALLOC
> for protecting kernel and modules code.
That makes sense.
I've also just posted an RFC that does more awkward ad-hoc manipulation:
https://lore.kernel.org/all/20260225-page_alloc-unmapped-v1-4-e8808a03cd66@google.com/
This might help illustrate the kinda thing that we could benefit from
with a more general library, besides just deduplicating code.
prev parent reply other threads:[~2026-02-25 17:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 17:51 Brendan Jackman
2026-02-23 11:28 ` Mike Rapoport
2026-02-25 17:06 ` Brendan Jackman [this message]
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=DGO7GH6XSF27.2ZHEU51SRDLJA@google.com \
--to=jackmanb@google.com \
--cc=linux-mm@kvack.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=owner-linux-mm@kvack.org \
--cc=rppt@kernel.org \
/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