x86: update comment about pgd_list
PATCH v2 1/1 x86: update comment about pgd_list
This venerable comment got detached from its context when the code moved in commit 394158559d4c ("x86: move all the pgd_list handling to one place"). Put it back next to its context. It was originally on pgd_list_add() but it actually describes pgd_list so put it there.
While moving it, update it to strip away stale and superfluous info. pageattr.c doesn't exist any more. pgd_list is now required for all x86 architectures. Also be slightly more precise about what PGDs are in this list.
---
Changes in v2:
- Moved it next to pgd_list instead of back to old location
- Strip away stale bits from the comment
- Added note about PGDs that _aren't_ in this list
- Link to v1: https://lore.kernel.org/r/[email protected]
--- arch/x86/mm/fault.c | 6 ++++++ arch/x86/mm/pgtable.c | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-)
arch/x86/mm/fault.c +6 -0
@@ -169,6 +169,12 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr) }DEFINE_SPINLOCK (pgd_lock); +/* +* List of all process' PGD pages (excluding init_mm and some other special +* system-wide PGDs); for kernel addresses the lower level pages are mostly +* shared but the PGD itself is local to each mm. This list is mainly used to +* keep those in sync. +*/ LIST_HEAD (pgd_list);#ifdef CONFIG_X86_32
arch/x86/mm/pgtable.c +0 -11
@@ -99,17 +99,6 @@ static void pgd_dtor(pgd_t *pgd)spin_unlock (&pgd_lock); } -/* -* List of all pgd's needed for non-PAE so it can invalidate entries -* in both cached and uncached pgd's; not needed for PAE since the -* kernel pmd is shared. If PAE were not to share the pmd a similar -* tactic would be needed. This is essentially codepath-based locking -* against pageattr.c; it is the unique case in which a valid change -* of kernel pagetables can't be lazily synchronized by vmalloc faults. -* vmalloc faults work because attached pagetables are never freed. -* -- nyc -*/ -#ifdef CONFIG_X86_PAE /* * In PAE mode, we need to do a cr3 reload (=tlb flush) when
---
base-commit: 2ca26dad836fb4cd18694ef85af7a71d2878b239
change-id: 20260311-pgd_list-comment-2ee97876c552
Best regards,
Signature · 1 line
Brendan Jackman <[email protected]>
Quoted 10 lines · Brendan Jackman
This venerable comment got detached from its context when the code moved in commit
394158559d4c("x86: move all thepgd_listhandling to one place"). Put it back next to its context. It was originally onpgd_list_add()but it actually describespgd_listso put it there.While moving it, update it to strip away stale and superfluous info.
pageattr.cdoesn't exist any more.pgd_listis now required for all x86 architectures. Also be slightly more precise about what PGDs are in this list.
Quoted 7 lines
Signed-off-by Brendan Jackman <[email protected]>---
Changes in v2:
- Moved it next topgd_listinstead of back to old location
- Strip away stale bits from the comment
- Added note about PGDs that _aren't_ in this list
- Link to v1: https://lore.kernel.org/r/[email protected]
Hi Dave,
I think this is ready?
(I don't see it in tip/master, apologies if I'm looking in the wrong place).
H. Peter Anvin
reviewerQuoted 19 lines · Brendan Jackman
Quoted 10 lines · Brendan Jackman
This venerable comment got detached from its context when the code moved in commit
394158559d4c("x86: move all thepgd_listhandling to one place"). Put it back next to its context. It was originally onpgd_list_add()but it actually describespgd_listso put it there.While moving it, update it to strip away stale and superfluous info.
pageattr.cdoesn't exist any more.pgd_listis now required for all x86 architectures. Also be slightly more precise about what PGDs are in this list.Quoted 7 lines
Signed-off-by Brendan Jackman <[email protected]>---
Changes in v2:
- Moved it next topgd_listinstead of back to old location
- Strip away stale bits from the comment
- Added note about PGDs that _aren't_ in this list
- Link to v1: https://lore.kernel.org/r/[email protected]
Quoted 6 lines
Hi Dave,
I think this is ready?
(I don't see it in tip/master, apologies if I'm looking in the wrong place).
The PAE code comment should still remain.
I don't know if the 32-bit PAE code is still suffering from Xen-induced drain bramage (using a whole page to store 32 bytes), but it is nevertheless true in a fashion -- as there are a maximum of 3 kernel PDE pages, they are considered the de facto top level of the kernel page tables.
-hpa
Quoted 4 lines · H. Peter Anvin
The PAE code comment should still remain.
I don't know if the 32-bit PAE code is still suffering from Xen-induced drain bramage (using a whole page to store 32 bytes),
Actually, I think I recently spread the brain damage even further. The kmalloc()'d PGDs are completely gone now. PGDs all directly out of the page allocator. It actually simplified the 32-bit code quite a bit.
Quoted 3 lines
but it is nevertheless true in a fashion -- as there are a maximum of 3 kernel PDE pages, they are considered the de facto top level of the kernel page tables.
Here's what I ended up with:
Quoted 5 lines
+/*
+ * List of all process' PGD pages (excludinginit_mmand some other special
+ * system-wide PGDs). Mainly used to keep the kernel portion of the address
+ * space in sync across mms.
+ */
I think what you're saying is that those (max) 3 kernel PDE pages are static and all PGDs always have the same value in there. So, there's no synchronizing necessary on PAE. That was definitely true for a long time.
But we actually also moved away from that:
Quoted 1 line
PTI forced some PMD unsharing. So I just moved 32-bit over to not share kernel PMDs at all. It made the 32-bit code quite a bit simpler, although it wastes memory when PTI is disabled.
[tip: x86/mm] x86: Update comment about pgd_list
In reply to Brendan JackmanThe following commit has been merged into the x86/mm branch of tip:
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 952ac097ce98901c608cdced012f89a90367401e Gitweb: https://git.kernel.org/tip/952ac097ce98901c608cdced012f89a90367401e Author: Brendan Jackman <[email protected]> AuthorDate: Mon, 23 Mar 2026 14:25:07 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 11 May 2026 11:26:33 -07:00
x86: Update comment about pgd_list
This venerable comment got detached from its context when the code moved in commit 394158559d4c ("x86: move all the pgd_list handling to one place"). Put it back next to its context. It was originally on pgd_list_add() but it actually describes pgd_list so put it there.
While moving it, update it to strip away stale and superfluous info. pageattr.c doesn't exist any more. pgd_list is now required for all x86 architectures. Also be slightly more precise about what PGDs are in this list.
[ dhansen: tweak and trim the updated comment a bit ]
--- arch/x86/mm/fault.c | 5 +++++ arch/x86/mm/pgtable.c | 11 ----------- 2 files changed, 5 insertions(+), 11 deletions(-)
arch/x86/mm/fault.c +5 -0
@@ -169,6 +169,11 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr) }DEFINE_SPINLOCK (pgd_lock); +/* +* List of all process' PGD pages (excluding init_mm and some other special +* system-wide PGDs). Mainly used to keep the kernel portion of the address +* space in sync across mms. +*/ LIST_HEAD (pgd_list);#ifdef CONFIG_X86_32
arch/x86/mm/pgtable.c +0 -11
@@ -99,17 +99,6 @@ static void pgd_dtor(pgd_t *pgd)spin_unlock (&pgd_lock); } -/* -* List of all pgd's needed for non-PAE so it can invalidate entries -* in both cached and uncached pgd's; not needed for PAE since the -* kernel pmd is shared. If PAE were not to share the pmd a similar -* tactic would be needed. This is essentially codepath-based locking -* against pageattr.c; it is the unique case in which a valid change -* of kernel pagetables can't be lazily synchronized by vmalloc faults. -* vmalloc faults work because attached pagetables are never freed. -* -- nyc -*/ -#ifdef CONFIG_X86_PAE /* * In PAE mode, we need to do a cr3 reload (=tlb flush) when