From: Kevin Brodsky <kevin.brodsky@arm.com>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Dave Hansen <dave.hansen@intel.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Russell King <linux@armlinux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
linux-arm-kernel@lists.infradead.org,
Huacai Chen <chenhuacai@kernel.org>,
loongarch@lists.linux.dev,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
Helge Deller <deller@gmx.de>,
linux-parisc@vger.kernel.org,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
linuxppc-dev@lists.ozlabs.org, Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
linux-riscv@lists.infradead.org,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
linux-s390@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
sparclinux@vger.kernel.org, Richard Weinberger <richard@nod.at>,
Anton Ivanov <anton.ivanov@cambridgegreys.com>,
Johannes Berg <johannes@sipsolutions.net>,
linux-um@lists.infradead.org, Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ning Sun <ning.sun@intel.com>,
x86@kernel.org, tboot-devel@lists.sourceforge.net,
Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
linux-efi@vger.kernel.org, Vishal Moola <vishal.moola@gmail.com>,
Alistair Popple <apopple@nvidia.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 03/22] mm: introduce MMF_KERNEL flag and set it for init_mm
Date: Thu, 16 Jul 2026 11:33:33 +0200 [thread overview]
Message-ID: <5ce00109-c0ea-43f0-881d-f58a0fda8dcb@arm.com> (raw)
In-Reply-To: <alZOs30ziqa7l_Lq@lucifer>
On 14/07/2026 17:04, Lorenzo Stoakes (ARM) wrote:
> On Tue, Jul 14, 2026 at 07:47:43AM -0700, Dave Hansen wrote:
>> On 7/14/26 07:03, Kevin Brodsky wrote:
>>> +static inline bool mm_is_kernel(const struct mm_struct *mm)
>>> +{
>>> + return mm && mm_flags_test(MMF_KERNEL, mm);
>>> +}
>> Could we give this some nice comments explaining what a kernel mm is,
>> please? Part of the problem with the init_mm checks is that they're
>> magic and it's not always clear what's special about init_mm.
Agreed, we need to define what this property means exactly, and your
comments on patch 14 show that extending it to efi_mm isn't necessarily
as benign as it appeared to me at first.
My motivation really is about how page tables are handled (in particular
whether ptlocks are used), so as you suggested on patch 19 maybe this
flag should be narrower in scope, and the naming should reflect it.
Possibly MMF_KERNEL_PGTABLES? That's at least one thing that should be
true of all of init_mm, efi_mm and tboot_mm: their page tables use
kernel permissions, not user, and should follow the same rules including
not using ptlocks.
>> Maybe start with this list?
>>
>> 1. There's only one of them.
>> 2. All kernel threads share it. tsk->mm is the same for all kernel
>> threads.
>> 3. It holds the reference copy of the kernel page tables
>> 4. Userspace can't be entered when it is the current mm
>> 5. It has different TLB flushing rules than userspace mms
>>
>> I _think_ those are universal across all architectures.
> Well point 1 isn't true of efimm or tboot_mm so we possibly need a better
> name :)
>
> "Special" is overloaded too much already. I quite like "eternal" so:
>
> static inline bool mm_is_eternal(const struct mm_struct *mm)
> {
> return mm && mm_flags_test(MMF_ETERNAL, mm);
> }
Cheeky but why not! I do wonder whether this conveys the right idea
though. The main point of this flag is that page tables are
allocated/initialised/locked differently; in principle you could have a
temporary non-user mm.
- Kevin
next prev parent reply other threads:[~2026-07-16 9:34 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 14:03 [PATCH 00/22] Simplify special kernel page table handling Kevin Brodsky
2026-07-14 14:03 ` [PATCH 01/22] mm: drop unused __mm_flags_set_mask_bits_word() Kevin Brodsky
2026-07-14 14:03 ` [PATCH 02/22] mm: move mm_flags helpers to mm_types.h Kevin Brodsky
2026-07-14 14:03 ` [PATCH 03/22] mm: introduce MMF_KERNEL flag and set it for init_mm Kevin Brodsky
2026-07-14 14:47 ` Dave Hansen
2026-07-14 15:04 ` Lorenzo Stoakes (ARM)
2026-07-16 9:33 ` Kevin Brodsky [this message]
2026-07-14 14:03 ` [PATCH 04/22] mm: use mm_is_kernel() in generic page table code Kevin Brodsky
2026-07-16 9:35 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 05/22] arm64: mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 14:03 ` [PATCH 06/22] loongarch: mm: use mm_is_kernel() in switch_mm_irqs_off() Kevin Brodsky
2026-07-14 14:03 ` [PATCH 07/22] parisc: mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 14:03 ` [PATCH 08/22] powerpc: " Kevin Brodsky
2026-07-14 14:03 ` [PATCH 09/22] s390: " Kevin Brodsky
2026-07-14 14:03 ` [PATCH 10/22] sparc: " Kevin Brodsky
2026-07-14 14:04 ` [PATCH 11/22] um: mm: use mm_is_kernel() in TLB sync Kevin Brodsky
2026-07-14 14:04 ` [PATCH 12/22] x86/mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 15:09 ` Dave Hansen
2026-07-14 14:04 ` [PATCH 13/22] mm: account page table pages when allocated Kevin Brodsky
2026-07-14 14:04 ` [PATCH 14/22] mm: set page table page type " Kevin Brodsky
2026-07-14 15:16 ` Vishal Moola
2026-07-16 9:49 ` Kevin Brodsky
2026-07-20 19:05 ` Vishal Moola
2026-07-14 14:04 ` [PATCH 15/22] mm: only initialise pt_share_count for user pgtables Kevin Brodsky
2026-07-14 14:04 ` [PATCH 16/22] efi: mark efi_mm as a kernel mm Kevin Brodsky
2026-07-14 14:04 ` [PATCH 17/22] mm: pagewalk: drop redundant address check for kernel mm walks Kevin Brodsky
2026-07-16 10:24 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 18/22] arm64: mm: drop explicit mm_is_efi() check in contpte Kevin Brodsky
2026-07-14 14:04 ` [PATCH 19/22] x86/tboot: mark tboot_mm as a kernel mm Kevin Brodsky
2026-07-14 15:19 ` Dave Hansen
2026-07-14 14:04 ` [PATCH 20/22] arm64: mm: drop ctor/dtor calls for kernel page tables Kevin Brodsky
2026-07-14 14:04 ` [PATCH 21/22] arm: mm: drop ctor call " Kevin Brodsky
2026-07-14 14:04 ` [PATCH 22/22] riscv: mm: drop ctor/dtor calls " Kevin Brodsky
2026-07-15 15:07 ` [PATCH 00/22] Simplify special kernel page table handling Kevin Brodsky
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=5ce00109-c0ea-43f0-881d-f58a0fda8dcb@arm.com \
--to=kevin.brodsky@arm.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=aou@eecs.berkeley.edu \
--cc=apopple@nvidia.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=david@kernel.org \
--cc=deller@gmx.de \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=johannes@sipsolutions.net \
--cc=liam@infradead.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljs@kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=luto@kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=ning.sun@intel.com \
--cc=palmer@dabbelt.com \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=richard@nod.at \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sparclinux@vger.kernel.org \
--cc=surenb@google.com \
--cc=tboot-devel@lists.sourceforge.net \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=vishal.moola@gmail.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=x86@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