Convert x86 pgd_lists to ptdescs
Subsystems (4)
v2 cover Convert x86 pgd_lists to ptdescs
This continues the ptdesc conversions for x86[1]. This is a necessary step in preparation for the separate allocation of ptdescs from struct page. Once ptdescs are not wrappers, the pgd_list should be used to find our ptdesc, not page.
In fact, after patch 4 we can successfully boot a 32-bit x86 kernel that separately allocates ptdescs.
All of the patches are rather straightforward, I just kept them split up for ease of review. There are no intended functional changes as ptdescs are currently still wrappers around struct page.
[1] https://lore.kernel.org/linux-mm/[email protected]/
----------------
v2:
- Collect Review tags
- Rebase on 7.2-rc1
I've compiled and booted both 64 and 32 bit on a kernel with separately allocated ptdescs. I ensured the codepaths were hit for all the changes except Xen.
This applies cleanly to 7.2-rc1. Dave, can you please take this through the x86 mm tree?
Vishal Moola (9):
x86/mm/pat: Use IS_ENABLED() instead of ifdef x86/mm/pat: Convert __set_pmd_pte() to ptdescs x86/mm/pat: Convert collapse_pmd_page() to ptdescs x86/mm: Convert arch_sync_kernel_mappings() to ptdescs x86/mm: Convert sync_global_pgds_l5() to ptdescs x86/mm: Convert sync_global_pgds_l4() to ptdescs x86/mm: Convert pgd_page_get_mm() to ptdescs x86/xen: Convert xen_mm_pin_all() to ptdescs x86/xen: Convert xen_mm_unpin_all() to ptdescs
arch/x86/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable_types.h | 2 +- arch/x86/mm/fault.c | 8 ++++---- arch/x86/mm/init_64.c | 16 ++++++++-------- arch/x86/mm/pat/set_memory.c | 17 ++++++++--------- arch/x86/mm/pgtable.c | 4 ++-- arch/x86/xen/mmu_pv.c | 22 +++++++++++----------- 7 files changed, 35 insertions(+), 36 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/9 x86/mm/pat: Use IS_ENABLED() instead of ifdef
Use IS_ENABLED() to check if we are on 32 bit. This standardizes this check with the other 32 bit check in the file. No functional changes.
--- arch/x86/mm/pat/set_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +2 -3
@@ -888,8 +888,8 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) {/* change init_mm */ set_pte_atomic (kpte, pte); -#ifdef CONFIG_X86_32 - { + +if (IS_ENABLED (CONFIG_X86_32 )) {struct page *page;list_for_each_entry (page, &pgd_list, lru) {
@@ -905,7 +905,6 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)set_pte_atomic ((pte_t *)pmd, pte); } } -#endif }static pgprot_t pgprot_clear_protnone_bits (pgprot_t prot)
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm/pat: Use IS_ENABLED() instead of ifdef
The 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: e7616bb5ef5fe752e15db8a3dbd8657dc19c21f2 Gitweb: https://git.kernel.org/tip/e7616bb5ef5fe752e15db8a3dbd8657dc19c21f2 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:34 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:09 -07:00
x86/mm/pat: Use IS_ENABLED() instead of ifdef
Use IS_ENABLED() to check if we are on 32 bit. This standardizes this check with the other 32 bit check in the file. No functional changes.
--- arch/x86/mm/pat/set_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +2 -3
@@ -888,8 +888,8 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) {/* change init_mm */ set_pte_atomic (kpte, pte); -#ifdef CONFIG_X86_32 - { + +if (IS_ENABLED (CONFIG_X86_32 )) {struct page *page;list_for_each_entry (page, &pgd_list, lru) {
@@ -905,7 +905,6 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)set_pte_atomic ((pte_t *)pmd, pte); } } -#endif }static pgprot_t pgprot_clear_protnone_bits (pgprot_t prot)
PATCH v2 2/9 x86/mm/pat: Convert __set_pmd_pte() to ptdescs
In reply to Vishal MoolaConvert __set_pmd_pte() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/pat/set_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +3 -3
@@ -890,15 +890,15 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)set_pte_atomic (kpte, pte);if (IS_ENABLED (CONFIG_X86_32 )) { -struct page *page; +struct ptdesc *ptdesc; -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;p4d_t *p4d;pud_t *pud;pmd_t *pmd; - pgd = (pgd_t *)page_address (page) +pgd_index (address); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (address); p4d =p4d_offset (pgd, address); pud =pud_offset (p4d, address); pmd =pmd_offset (pud, address);
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm/pat: Convert __set_pmd_pte() to ptdescs
The 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: e27d938b0de86304f12c89706b8034f89f015077 Gitweb: https://git.kernel.org/tip/e27d938b0de86304f12c89706b8034f89f015077 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:35 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm/pat: Convert __set_pmd_pte() to ptdescs
Convert __set_pmd_pte() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/pat/set_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +3 -3
@@ -890,15 +890,15 @@ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)set_pte_atomic (kpte, pte);if (IS_ENABLED (CONFIG_X86_32 )) { -struct page *page; +struct ptdesc *ptdesc; -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;p4d_t *p4d;pud_t *pud;pmd_t *pmd; - pgd = (pgd_t *)page_address (page) +pgd_index (address); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (address); p4d =p4d_offset (pgd, address); pud =pud_offset (p4d, address); pmd =pmd_offset (pud, address);
PATCH v2 3/9 x86/mm/pat: Convert collapse_pmd_page() to ptdescs
In reply to Vishal MoolaConvert collapse_pmd_page() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/pat/set_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +3 -3
@@ -1297,11 +1297,11 @@ static int collapse_pmd_page(pmd_t *pmd, unsigned long addr,list_add (&page_ptdesc (pmd_page (old_pmd))->pt_list, pgtables);if (IS_ENABLED (CONFIG_X86_32 )) { -struct page *page; +struct ptdesc *ptdesc;/* Update all PGD tables to use the same large page */ -list_for_each_entry (page, &pgd_list, lru) { -pgd_t *pgd = (pgd_t *)page_address (page) +pgd_index (addr); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +pgd_t *pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);p4d_t *p4d =p4d_offset (pgd, addr);pud_t *pud =pud_offset (p4d, addr);pmd_t *pmd =pmd_offset (pud, addr);
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm/pat: Convert collapse_pmd_page() to ptdescs
The 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: 5fcb2abffe015017c252a5a720375145e808337e Gitweb: https://git.kernel.org/tip/5fcb2abffe015017c252a5a720375145e808337e Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:36 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm/pat: Convert collapse_pmd_page() to ptdescs
Convert collapse_pmd_page() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/pat/set_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/pat/set_memory.c +3 -3
@@ -1297,11 +1297,11 @@ static int collapse_pmd_page(pmd_t *pmd, unsigned long addr,list_add (&page_ptdesc (pmd_page (old_pmd))->pt_list, pgtables);if (IS_ENABLED (CONFIG_X86_32 )) { -struct page *page; +struct ptdesc *ptdesc;/* Update all PGD tables to use the same large page */ -list_for_each_entry (page, &pgd_list, lru) { -pgd_t *pgd = (pgd_t *)page_address (page) +pgd_index (addr); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +pgd_t *pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);p4d_t *p4d =p4d_offset (pgd, addr);pud_t *pud =pud_offset (p4d, addr);pmd_t *pmd =pmd_offset (pud, addr);
PATCH v2 4/9 x86/mm: Convert arch_sync_kernel_mappings() to ptdescs
In reply to Vishal MoolaConvert arch_sync_kernel_mappings() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
Following this patch, we can successfully boot a 32-bit x86 kernel with separately allocated ptdescs.
--- arch/x86/mm/fault.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/fault.c +4 -4
@@ -275,17 +275,17 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)for (addr = start &PMD_MASK ; addr >=TASK_SIZE_MAX && addr <VMALLOC_END ; addr +=PMD_SIZE ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {spinlock_t *pgt_lock;/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock); -vmalloc_sync_one (page_address (page), addr); +vmalloc_sync_one (ptdesc_address (ptdesc), addr);spin_unlock (pgt_lock); }spin_unlock (&pgd_lock);
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm: Convert arch_sync_kernel_mappings() to ptdescs
The 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: 46ee485bb9dee952cab3e7b22138b9ad0e5cb468 Gitweb: https://git.kernel.org/tip/46ee485bb9dee952cab3e7b22138b9ad0e5cb468 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:37 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm: Convert arch_sync_kernel_mappings() to ptdescs
Convert arch_sync_kernel_mappings() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
Following this patch, we can successfully boot a 32-bit x86 kernel with separately allocated ptdescs.
--- arch/x86/mm/fault.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/fault.c +4 -4
@@ -275,17 +275,17 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)for (addr = start &PMD_MASK ; addr >=TASK_SIZE_MAX && addr <VMALLOC_END ; addr +=PMD_SIZE ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {spinlock_t *pgt_lock;/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock); -vmalloc_sync_one (page_address (page), addr); +vmalloc_sync_one (ptdesc_address (ptdesc), addr);spin_unlock (pgt_lock); }spin_unlock (&pgd_lock);
PATCH v2 5/9 x86/mm: Convert sync_global_pgds_l5() to ptdescs
In reply to Vishal MoolaConvert sync_global_pgds_l5() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/init_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/init_64.c +4 -4
@@ -136,7 +136,7 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end)for (addr = start; addr <= end; addr =ALIGN (addr +1 ,PGDIR_SIZE )) {const pgd_t *pgd_ref =pgd_offset_k (addr); -struct page *page; +struct ptdesc *ptdesc;/* Check for overflow */ if (addr < start)
@@ -146,13 +146,13 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end)continue ;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;spinlock_t *pgt_lock; - pgd = (pgd_t *)page_address (page) +pgd_index (addr); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock);if (!pgd_none (*pgd_ref) && !pgd_none (*pgd))
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm: Convert sync_global_pgds_l5() to ptdescs
The 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: 90c881895fab258924772846f2555a9c9eaac8f1 Gitweb: https://git.kernel.org/tip/90c881895fab258924772846f2555a9c9eaac8f1 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:38 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm: Convert sync_global_pgds_l5() to ptdescs
Convert sync_global_pgds_l5() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/init_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/init_64.c +4 -4
@@ -136,7 +136,7 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end)for (addr = start; addr <= end; addr =ALIGN (addr +1 ,PGDIR_SIZE )) {const pgd_t *pgd_ref =pgd_offset_k (addr); -struct page *page; +struct ptdesc *ptdesc;/* Check for overflow */ if (addr < start)
@@ -146,13 +146,13 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end)continue ;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;spinlock_t *pgt_lock; - pgd = (pgd_t *)page_address (page) +pgd_index (addr); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock);if (!pgd_none (*pgd_ref) && !pgd_none (*pgd))
PATCH v2 6/9 x86/mm: Convert sync_global_pgds_l4() to ptdescs
In reply to Vishal MoolaConvert sync_global_pgds_l4() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/init_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/init_64.c +4 -4
@@ -174,7 +174,7 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)for (addr = start; addr <= end; addr =ALIGN (addr +1 ,PGDIR_SIZE )) {pgd_t *pgd_ref =pgd_offset_k (addr);const p4d_t *p4d_ref; -struct page *page; +struct ptdesc *ptdesc;/* * With folded p4d, pgd_none() is always false, we need to
@@ -187,15 +187,15 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)continue ;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;p4d_t *p4d;spinlock_t *pgt_lock; - pgd = (pgd_t *)page_address (page) +pgd_index (addr); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr); p4d =p4d_offset (pgd, addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock);if (!p4d_none (*p4d_ref) && !p4d_none (*p4d))
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm: Convert sync_global_pgds_l4() to ptdescs
The 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: 9c453f8784dc033a35d06dff929be1eaedb3020c Gitweb: https://git.kernel.org/tip/9c453f8784dc033a35d06dff929be1eaedb3020c Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:39 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm: Convert sync_global_pgds_l4() to ptdescs
Convert sync_global_pgds_l4() to ptdescs in preparation for the eventual splitting of ptdescs from struct page.
--- arch/x86/mm/init_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/mm/init_64.c +4 -4
@@ -174,7 +174,7 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)for (addr = start; addr <= end; addr =ALIGN (addr +1 ,PGDIR_SIZE )) {pgd_t *pgd_ref =pgd_offset_k (addr);const p4d_t *p4d_ref; -struct page *page; +struct ptdesc *ptdesc;/* * With folded p4d, pgd_none() is always false, we need to
@@ -187,15 +187,15 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)continue ;spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { +list_for_each_entry (ptdesc, &pgd_list, pt_list) {pgd_t *pgd;p4d_t *p4d;spinlock_t *pgt_lock; - pgd = (pgd_t *)page_address (page) +pgd_index (addr); + pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr); p4d =p4d_offset (pgd, addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (page)->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock;spin_lock (pgt_lock);if (!p4d_none (*p4d_ref) && !p4d_none (*p4d))
PATCH v2 7/9 x86/mm: Convert pgd_page_get_mm() to ptdescs
In reply to Vishal MoolaConvert pgd_page_get_mm() to ptdescs. Define struct ptdesc in our pgtable_types so that our declarations recognize ptdesc as an appropriate page table type.
Now that all callers are using ptdescs, we can pass in that ptdesc to get the underlying mm_struct.
--- arch/x86/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable_types.h | 2 +- arch/x86/mm/fault.c | 2 +- arch/x86/mm/init_64.c | 4 ++-- arch/x86/mm/pgtable.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/pgtable.h +1 -1
@@ -50,7 +50,7 @@ void ptdump_walk_user_pgd_level_checkwx(void);extern spinlock_t pgd_lock;extern struct list_head pgd_list; -extern struct mm_struct *pgd_page_get_mm (struct page *page); +struct mm_struct *pgd_page_get_mm (struct ptdesc *pt);extern pmdval_t early_pmd_flags;
arch/x86/include/asm/pgtable_types.h +1 -1
@@ -512,7 +512,7 @@ static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)return __pgprot (protval_large_2_4k (pgprot_val (pgprot))); } - +struct ptdesc ;typedef struct page *pgtable_t ;extern pteval_t __supported_pte_mask;
arch/x86/mm/fault.c +1 -1
@@ -282,7 +282,7 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)spinlock_t *pgt_lock;/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);vmalloc_sync_one (ptdesc_address (ptdesc), addr);
arch/x86/mm/init_64.c +2 -2
@@ -152,7 +152,7 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end) pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);if (!pgd_none (*pgd_ref) && !pgd_none (*pgd))
@@ -195,7 +195,7 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end) pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr); p4d =p4d_offset (pgd, addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);if (!p4d_none (*p4d_ref) && !p4d_none (*p4d))
arch/x86/mm/pgtable.c +2 -2
@@ -74,9 +74,9 @@ static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)virt_to_ptdesc (pgd)->pt_mm = mm; } -struct mm_struct *pgd_page_get_mm (struct page *page) +struct mm_struct *pgd_page_get_mm (struct ptdesc *pt) { -return page_ptdesc (page)->pt_mm; +return pt->pt_mm; }static void pgd_ctor (struct mm_struct *mm,pgd_t *pgd)
Signature · 1 line
2.54.0
[tip: x86/mm] x86/mm: Convert pgd_page_get_mm() to ptdescs
The 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: dd9850c91665a56babd964df19de2cb90a98c538 Gitweb: https://git.kernel.org/tip/dd9850c91665a56babd964df19de2cb90a98c538 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:40 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/mm: Convert pgd_page_get_mm() to ptdescs
Convert pgd_page_get_mm() to ptdescs. Define struct ptdesc in our pgtable_types so that our declarations recognize ptdesc as an appropriate page table type.
Now that all callers are using ptdescs, we can pass in that ptdesc to get the underlying mm_struct.
--- arch/x86/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable_types.h | 2 +- arch/x86/mm/fault.c | 2 +- arch/x86/mm/init_64.c | 4 ++-- arch/x86/mm/pgtable.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/pgtable.h +1 -1
@@ -50,7 +50,7 @@ void ptdump_walk_user_pgd_level_checkwx(void);extern spinlock_t pgd_lock;extern struct list_head pgd_list; -extern struct mm_struct *pgd_page_get_mm (struct page *page); +struct mm_struct *pgd_page_get_mm (struct ptdesc *pt);extern pmdval_t early_pmd_flags;
arch/x86/include/asm/pgtable_types.h +1 -1
@@ -512,7 +512,7 @@ static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)return __pgprot (protval_large_2_4k (pgprot_val (pgprot))); } - +struct ptdesc ;typedef struct page *pgtable_t ;extern pteval_t __supported_pte_mask;
arch/x86/mm/fault.c +1 -1
@@ -282,7 +282,7 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)spinlock_t *pgt_lock;/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);vmalloc_sync_one (ptdesc_address (ptdesc), addr);
arch/x86/mm/init_64.c +2 -2
@@ -152,7 +152,7 @@ static void sync_global_pgds_l5(unsigned long start, unsigned long end) pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);if (!pgd_none (*pgd_ref) && !pgd_none (*pgd))
@@ -195,7 +195,7 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end) pgd = (pgd_t *)ptdesc_address (ptdesc) +pgd_index (addr); p4d =p4d_offset (pgd, addr);/* the pgt_lock only for Xen */ - pgt_lock = &pgd_page_get_mm (ptdesc_page (ptdesc))->page_table_lock; + pgt_lock = &pgd_page_get_mm (ptdesc)->page_table_lock;spin_lock (pgt_lock);if (!p4d_none (*p4d_ref) && !p4d_none (*p4d))
arch/x86/mm/pgtable.c +2 -2
@@ -74,9 +74,9 @@ static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)virt_to_ptdesc (pgd)->pt_mm = mm; } -struct mm_struct *pgd_page_get_mm (struct page *page) +struct mm_struct *pgd_page_get_mm (struct ptdesc *pt) { -return page_ptdesc (page)->pt_mm; +return pt->pt_mm; }static void pgd_ctor (struct mm_struct *mm,pgd_t *pgd)
PATCH v2 8/9 x86/xen: Convert xen_mm_pin_all() to ptdescs
In reply to Vishal MoolaConvert xen_mm_pin_all() to ptdescs in preparation for the eventual splitting of ptdescs from struct page. Continue checking PagePinned through the underlying page as we do not have a per-memdesc api for page flags yet.
--- arch/x86/xen/mmu_pv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/xen/mmu_pv.c +5 -5
@@ -836,15 +836,15 @@ static void xen_pgd_pin(struct mm_struct *mm)*/ void xen_mm_pin_all (void ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&init_mm.page_table_lock);spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { -if (!PagePinned (page)) { -__xen_pgd_pin (&init_mm, (pgd_t *)page_address (page)); -SetPageSavePinned (page); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +if (!PagePinned (ptdesc_page (ptdesc))) { +__xen_pgd_pin (&init_mm, (pgd_t *)ptdesc_address (ptdesc)); +SetPageSavePinned (ptdesc_page (ptdesc)); } }
Signature · 1 line
2.54.0
[tip: x86/mm] x86/xen: Convert xen_mm_pin_all() to ptdescs
The 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: 278ddbd27427e4f51e6fdc0e1f11930b22b2f5a9 Gitweb: https://git.kernel.org/tip/278ddbd27427e4f51e6fdc0e1f11930b22b2f5a9 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:41 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/xen: Convert xen_mm_pin_all() to ptdescs
Convert xen_mm_pin_all() to ptdescs in preparation for the eventual splitting of ptdescs from struct page. Continue checking PagePinned through the underlying page as we do not have a per-memdesc api for page flags yet.
--- arch/x86/xen/mmu_pv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/xen/mmu_pv.c +5 -5
@@ -836,15 +836,15 @@ static void xen_pgd_pin(struct mm_struct *mm)*/ void xen_mm_pin_all (void ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&init_mm.page_table_lock);spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { -if (!PagePinned (page)) { -__xen_pgd_pin (&init_mm, (pgd_t *)page_address (page)); -SetPageSavePinned (page); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +if (!PagePinned (ptdesc_page (ptdesc))) { +__xen_pgd_pin (&init_mm, (pgd_t *)ptdesc_address (ptdesc)); +SetPageSavePinned (ptdesc_page (ptdesc)); } }
PATCH v2 9/9 x86/xen: Convert xen_mm_unpin_all() to ptdescs
In reply to Vishal MoolaConvert xen_mm_unpin_all() to ptdescs in preparation for the eventual splitting of ptdescs from struct page. Continue checking PagePinned through the underlying page as we do not have a per-memdesc api yet.
--- arch/x86/xen/mmu_pv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/xen/mmu_pv.c +6 -6
@@ -947,16 +947,16 @@ static void xen_pgd_unpin(struct mm_struct *mm)*/ void xen_mm_unpin_all (void ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&init_mm.page_table_lock);spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { -if (PageSavePinned (page)) { -BUG_ON (!PagePinned (page)); -__xen_pgd_unpin (&init_mm, (pgd_t *)page_address (page)); -ClearPageSavePinned (page); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +if (PageSavePinned (ptdesc_page (ptdesc))) { +BUG_ON (!PagePinned (ptdesc_page (ptdesc))); +__xen_pgd_unpin (&init_mm, (pgd_t *)ptdesc_address (ptdesc)); +ClearPageSavePinned (ptdesc_page (ptdesc)); } }
Signature · 1 line
2.54.0
[tip: x86/mm] x86/xen: Convert xen_mm_unpin_all() to ptdescs
The 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: defbd61c2ab01654b37750ed1515864523280cc4 Gitweb: https://git.kernel.org/tip/defbd61c2ab01654b37750ed1515864523280cc4 Author: Vishal Moola <[email protected]> AuthorDate: Mon, 29 Jun 2026 11:57:42 -07:00 Committer: Dave Hansen <[email protected]> CommitterDate: Mon, 13 Jul 2026 15:55:10 -07:00
x86/xen: Convert xen_mm_unpin_all() to ptdescs
Convert xen_mm_unpin_all() to ptdescs in preparation for the eventual splitting of ptdescs from struct page. Continue checking PagePinned through the underlying page as we do not have a per-memdesc api yet.
--- arch/x86/xen/mmu_pv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/xen/mmu_pv.c +6 -6
@@ -947,16 +947,16 @@ static void xen_pgd_unpin(struct mm_struct *mm)*/ void xen_mm_unpin_all (void ) { -struct page *page; +struct ptdesc *ptdesc;spin_lock (&init_mm.page_table_lock);spin_lock (&pgd_lock); -list_for_each_entry (page, &pgd_list, lru) { -if (PageSavePinned (page)) { -BUG_ON (!PagePinned (page)); -__xen_pgd_unpin (&init_mm, (pgd_t *)page_address (page)); -ClearPageSavePinned (page); +list_for_each_entry (ptdesc, &pgd_list, pt_list) { +if (PageSavePinned (ptdesc_page (ptdesc))) { +BUG_ON (!PagePinned (ptdesc_page (ptdesc))); +__xen_pgd_unpin (&init_mm, (pgd_t *)ptdesc_address (ptdesc)); +ClearPageSavePinned (ptdesc_page (ptdesc)); } }
Quoted 20 lines · Vishal Moola
This continues the ptdesc conversions for x86[1]. This is a necessary step in preparation for the separate allocation of ptdescs from struct page. Once ptdescs are not wrappers, the
pgd_listshould be used to find our ptdesc, not page.In fact, after patch 4 we can successfully boot a 32-bit x86 kernel that separately allocates ptdescs.
All of the patches are rather straightforward, I just kept them split up for ease of review. There are no intended functional changes as ptdescs are currently still wrappers around struct page.
[1] https://lore.kernel.org/linux-mm/[email protected]/
----------------
v2:
- Collect Review tags
- Rebase on 7.2-rc1
Quoted 6 lines
I've compiled and booted both 64 and 32 bit on a kernel with separately allocated ptdescs. I ensured the codepaths were hit for all the changes except Xen.
This applies cleanly to 7.2-rc1. Dave, can you please take this through the x86 mm tree?
Hi Dave, will you take this through your tree? Let me know if there are any changes you'd like to see, or if you'd rather this go through some other tree.
Quoted 23 lines
Vishal Moola (9):
x86/mm/pat: UseIS_ENABLED()instead of ifdef x86/mm/pat: Convert__set_pmd_pte()to ptdescs x86/mm/pat: Convertcollapse_pmd_page()to ptdescs x86/mm: Convertarch_sync_kernel_mappings()to ptdescs x86/mm: Convertsync_global_pgds_l5()to ptdescs x86/mm: Convertsync_global_pgds_l4()to ptdescs x86/mm: Convertpgd_page_get_mm()to ptdescs x86/xen: Convertxen_mm_pin_all()to ptdescs x86/xen: Convertxen_mm_unpin_all()to ptdescsarch/x86/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable_types.h | 2 +- arch/x86/mm/fault.c | 8 ++++---- arch/x86/mm/init_64.c | 16 ++++++++-------- arch/x86/mm/pat/set_memory.c | 17 ++++++++--------- arch/x86/mm/pgtable.c | 4 ++-- arch/x86/xen/mmu_pv.c | 22 +++++++++++----------- 7 files changed, 35 insertions(+), 36 deletions(-)Signature · 1 line
2.54.0