From: Dave Hansen <dave.hansen@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,joro@8bytes.org,luto@kernel.org,peterz@infradead.org,kirill.shutemov@linux.intel.com,rick.p.edgecombe@intel.com,jgross@suse.com,Dave
Hansen <dave.hansen@linux.intel.com>
Subject: [PATCH 2/8] x86/mm: Always "broadcast" PMD setting operations
Date: Mon, 14 Apr 2025 10:32:35 -0700 [thread overview]
Message-ID: <20250414173235.F63F50D1@davehans-spike.ostc.intel.com> (raw)
In-Reply-To: <20250414173232.32444FF6@davehans-spike.ostc.intel.com>
From: Dave Hansen <dave.hansen@linux.intel.com>
Kernel PMDs can either be shared across processes or private to a
process. On 64-bit, they are always shared. 32-bit non-PAE hardware
does not have PMDs, but the kernel logically squishes them into the
PGD and treats them as private. Here are the four cases:
64-bit: Shared
32-bit: non-PAE: Private
32-bit: PAE+ PTI: Private
32-bit: PAE+noPTI: Shared
Note that 32-bit is all "Private" except for PAE+noPTI being an
oddball. The 32-bit+PAE+noPTI case will be made like the rest of
32-bit shortly.
But until that can be done, temporarily treat the 32-bit+PAE+noPTI
case as Private. This will do unnecessary walks across pgd_list and
unnecessary PTE setting but should be otherwise harmless.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---
b/arch/x86/mm/pat/set_memory.c | 4 ++--
b/arch/x86/mm/pgtable.c | 11 +++--------
2 files changed, 5 insertions(+), 10 deletions(-)
diff -puN arch/x86/mm/pat/set_memory.c~always-sync-kernel-mapping-updates arch/x86/mm/pat/set_memory.c
--- a/arch/x86/mm/pat/set_memory.c~always-sync-kernel-mapping-updates 2025-04-09 12:00:17.126319212 -0700
+++ b/arch/x86/mm/pat/set_memory.c 2025-04-09 12:53:28.082212490 -0700
@@ -889,7 +889,7 @@ static void __set_pmd_pte(pte_t *kpte, u
/* change init_mm */
set_pte_atomic(kpte, pte);
#ifdef CONFIG_X86_32
- if (!SHARED_KERNEL_PMD) {
+ {
struct page *page;
list_for_each_entry(page, &pgd_list, lru) {
@@ -1293,7 +1293,7 @@ static int collapse_pmd_page(pmd_t *pmd,
/* Queue the page table to be freed after TLB flush */
list_add(&page_ptdesc(pmd_page(old_pmd))->pt_list, pgtables);
- if (IS_ENABLED(CONFIG_X86_32) && !SHARED_KERNEL_PMD) {
+ if (IS_ENABLED(CONFIG_X86_32)) {
struct page *page;
/* Update all PGD tables to use the same large page */
diff -puN arch/x86/mm/pgtable.c~always-sync-kernel-mapping-updates arch/x86/mm/pgtable.c
--- a/arch/x86/mm/pgtable.c~always-sync-kernel-mapping-updates 2025-04-09 12:00:17.128319285 -0700
+++ b/arch/x86/mm/pgtable.c 2025-04-09 12:53:09.217519767 -0700
@@ -97,18 +97,13 @@ static void pgd_ctor(struct mm_struct *m
KERNEL_PGD_PTRS);
}
- /* list required to sync kernel mapping updates */
- if (!SHARED_KERNEL_PMD) {
- pgd_set_mm(pgd, mm);
- pgd_list_add(pgd);
- }
+ /* List used to sync kernel mapping updates */
+ pgd_set_mm(pgd, mm);
+ pgd_list_add(pgd);
}
static void pgd_dtor(pgd_t *pgd)
{
- if (SHARED_KERNEL_PMD)
- return;
-
spin_lock(&pgd_lock);
pgd_list_del(pgd);
spin_unlock(&pgd_lock);
_
next prev parent reply other threads:[~2025-04-14 17:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 17:32 [PATCH 0/8] x86/mm: Simplify PAE page table handling Dave Hansen
2025-04-14 17:32 ` [PATCH 1/8] x86/mm: Always allocate a whole page for PAE PGDs Dave Hansen
2025-04-14 17:32 ` Dave Hansen [this message]
2025-04-15 8:25 ` [PATCH 2/8] x86/mm: Always "broadcast" PMD setting operations Kirill A. Shutemov
2025-04-15 14:10 ` Dave Hansen
2025-04-14 17:32 ` [PATCH 3/8] x86/mm: Always tell core mm to sync kernel mappings Dave Hansen
2025-04-15 8:28 ` Kirill A. Shutemov
2025-04-15 14:12 ` Dave Hansen
2025-04-14 17:32 ` [PATCH 4/8] x86/mm: Simplify PAE PGD sharing macros Dave Hansen
2025-04-14 17:32 ` [PATCH 5/8] x86/mm: Fix up comments around PMD preallocation Dave Hansen
2025-04-14 17:32 ` [PATCH 6/8] x86/mm: Preallocate all PAE page tables Dave Hansen
2025-04-14 17:32 ` [PATCH 7/8] x86/mm: Remove duplicated PMD preallocation macro Dave Hansen
2025-04-14 17:32 ` [PATCH 8/8] x86/mm: Remove now unused SHARED_KERNEL_PMD Dave Hansen
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=20250414173235.F63F50D1@davehans-spike.ostc.intel.com \
--to=dave.hansen@linux.intel.com \
--cc=bp@alien8.de \
--cc=jgross@suse.com \
--cc=joro@8bytes.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®