Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-18 Thread Alex Shi



On 2026/1/18 18:51, David Hildenbrand (Red Hat) wrote:

On 1/18/26 09:13, Alex Shi wrote:



On 2026/1/8 10:23, Alex Shi wrote:



On 2026/1/7 22:48, Matthew Wilcox wrote:

On Wed, Jan 07, 2026 at 05:28:36PM +0800, Alex Shi wrote:

Right, I will fix this. and sent the 2nd version.
No, the patch is stupid and wrong.  Don't send a v2.  You seem to 
have a

hairtrigger resend, so I'm trying to prevent a v2 being sent instead of
sending a patient reply.


Hi Matthew,

I hear you—no v2 will be sent.
but sorry for a bit confusing, what's your expected fix? is the too
quick resenting? or the direction to alignment pgtable_t with ptdesc is
wrong?


Hi Willy, Do you mind to share the detailed concern for this patch?


I think we recently had a discussion that we should much rather rework 
core code to consistently make pgtable_t a pointer to the start of the 
page table or something like that.


Because the way you change the code just means that we will not be able 
to handle code that fits multiple pages tables into a single page 
(s390x, ppc) consistently.


 arch/s390/include/asm/page.h:typedef pte_t *pgtable_t;



Got it. Thanks a lot for the explanation!


___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-18 Thread David Hildenbrand (Red Hat)

On 1/18/26 09:13, Alex Shi wrote:



On 2026/1/8 10:23, Alex Shi wrote:



On 2026/1/7 22:48, Matthew Wilcox wrote:

On Wed, Jan 07, 2026 at 05:28:36PM +0800, Alex Shi wrote:

Right, I will fix this. and sent the 2nd version.

No, the patch is stupid and wrong.  Don't send a v2.  You seem to have a
hairtrigger resend, so I'm trying to prevent a v2 being sent instead of
sending a patient reply.


Hi Matthew,

I hear you—no v2 will be sent.
but sorry for a bit confusing, what's your expected fix? is the too
quick resenting? or the direction to alignment pgtable_t with ptdesc is
wrong?


Hi Willy, Do you mind to share the detailed concern for this patch?


I think we recently had a discussion that we should much rather rework 
core code to consistently make pgtable_t a pointer to the start of the 
page table or something like that.


Because the way you change the code just means that we will not be able 
to handle code that fits multiple pages tables into a single page 
(s390x, ppc) consistently.


arch/s390/include/asm/page.h:typedef pte_t *pgtable_t;

--
Cheers

David

___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-18 Thread Alex Shi



On 2026/1/8 10:23, Alex Shi wrote:



On 2026/1/7 22:48, Matthew Wilcox wrote:

On Wed, Jan 07, 2026 at 05:28:36PM +0800, Alex Shi wrote:

Right, I will fix this. and sent the 2nd version.

No, the patch is stupid and wrong.  Don't send a v2.  You seem to have a
hairtrigger resend, so I'm trying to prevent a v2 being sent instead of
sending a patient reply.


Hi Matthew,

I hear you—no v2 will be sent.
but sorry for a bit confusing, what's your expected fix? is the too 
quick resenting? or the direction to alignment pgtable_t with ptdesc is 
wrong?


Hi Willy, Do you mind to share the detailed concern for this patch?

Thanks



If it's the first. the new change for review address Mike's concern.
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/ 
pgalloc.h

index a17f01235c29..a204c3ac800a 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -94,13 +94,13 @@ pte_alloc_one_kernel(struct mm_struct *mm)
  static inline pgtable_t
  pte_alloc_one(struct mm_struct *mm)
  {
-   struct page *pte;
+   struct ptdesc *pte;

     pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);
     if (!pte)
     return NULL;
-   if (!PageHighMem(pte))
-   clean_pte_table(page_address(pte));
+   if (!PageHighMem(ptdesc_page(pte)))
+   clean_pte_table(ptdesc_address(pte));
     return pte;
  }

@@ -141,7 +141,7 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmdp, 
pgtable_t ptep)

     else
     prot = _PAGE_USER_TABLE;

-   __pmd_populate(pmdp, page_to_phys(ptep), prot);
+   __pmd_populate(pmdp, page_to_phys(ptdesc_page(ptep)), prot);
  }

  #endif /* CONFIG_MMU */



___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-07 Thread Alex Shi



On 2026/1/7 22:48, Matthew Wilcox wrote:

On Wed, Jan 07, 2026 at 05:28:36PM +0800, Alex Shi wrote:

Right, I will fix this. and sent the 2nd version.

No, the patch is stupid and wrong.  Don't send a v2.  You seem to have a
hairtrigger resend, so I'm trying to prevent a v2 being sent instead of
sending a patient reply.


Hi Matthew,

I hear you—no v2 will be sent.
but sorry for a bit confusing, what's your expected fix? is the too 
quick resenting? or the direction to alignment pgtable_t with ptdesc is 
wrong?


If it's the first. the new change for review address Mike's concern.
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
index a17f01235c29..a204c3ac800a 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -94,13 +94,13 @@ pte_alloc_one_kernel(struct mm_struct *mm)
 static inline pgtable_t
 pte_alloc_one(struct mm_struct *mm)
 {
-   struct page *pte;
+   struct ptdesc *pte;

pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);
if (!pte)
return NULL;
-   if (!PageHighMem(pte))
-   clean_pte_table(page_address(pte));
+   if (!PageHighMem(ptdesc_page(pte)))
+   clean_pte_table(ptdesc_address(pte));
return pte;
 }

@@ -141,7 +141,7 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmdp, 
pgtable_t ptep)

else
prot = _PAGE_USER_TABLE;

-   __pmd_populate(pmdp, page_to_phys(ptep), prot);
+   __pmd_populate(pmdp, page_to_phys(ptdesc_page(ptep)), prot);
 }

 #endif /* CONFIG_MMU */

___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-07 Thread Matthew Wilcox
On Wed, Jan 07, 2026 at 05:28:36PM +0800, Alex Shi wrote:
> Right, I will fix this. and sent the 2nd version.

No, the patch is stupid and wrong.  Don't send a v2.  You seem to have a
hairtrigger resend, so I'm trying to prevent a v2 being sent instead of
sending a patient reply.

___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-07 Thread Alex Shi




On 2026/1/7 17:05, Mike Rapoport wrote:

On Wed, Jan 07, 2026 at 02:46:35PM +0800,[email protected] wrote:

From: Alex Shi

After struct ptdesc introduced, pgtable_t should used it instead of old
struct page pointer. The only thing in the way for this change is just
pgtable->lru in pgtable_trans_huge_deposit/withdraw.

Let's convert them into ptdesc and use struct ptdesc* as pgtable_t.
Thanks testing support from kernel test robot

Signed-off-by: Alex Shi
---

...


diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
index a17f01235c29..1a3484c2df4c 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -96,12 +96,12 @@ pte_alloc_one(struct mm_struct *mm)
  {
struct page *pte;
  
-	pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);

+   pte = ptdesc_page(__pte_alloc_one(mm, GFP_PGTABLE_USER | 
PGTABLE_HIGHMEM));

When ptdesc will be separated from struct page, ptdesc_page() would fail if the
allocation failed. This line should be split into something like

struct ptdesc *ptdesc = __pte_alloc_one(...);
if (!ptesc)
return NULL;
pte = ptdesc_page(ptdesc);




Right, I will fix this. and sent the 2nd version.
Thanks a lot!


if (!pte)
return NULL;
if (!PageHighMem(pte))
clean_pte_table(page_address(pte));
-   return pte;
+   return page_ptdesc(pte);
  }
  
  static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,

-- Sincerely yours, Mike.




___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-07 Thread Mike Rapoport
On Wed, Jan 07, 2026 at 02:46:35PM +0800, [email protected] wrote:
> From: Alex Shi 
> 
> After struct ptdesc introduced, pgtable_t should used it instead of old
> struct page pointer. The only thing in the way for this change is just
> pgtable->lru in pgtable_trans_huge_deposit/withdraw.
> 
> Let's convert them into ptdesc and use struct ptdesc* as pgtable_t.
> Thanks testing support from kernel test robot 
> 
> Signed-off-by: Alex Shi 
> ---

...

> diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
> index a17f01235c29..1a3484c2df4c 100644
> --- a/arch/arm/include/asm/pgalloc.h
> +++ b/arch/arm/include/asm/pgalloc.h
> @@ -96,12 +96,12 @@ pte_alloc_one(struct mm_struct *mm)
>  {
>   struct page *pte;
>  
> - pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);
> + pte = ptdesc_page(__pte_alloc_one(mm, GFP_PGTABLE_USER | 
> PGTABLE_HIGHMEM));

When ptdesc will be separated from struct page, ptdesc_page() would fail if the
allocation failed. This line should be split into something like

struct ptdesc *ptdesc = __pte_alloc_one(...);
if (!ptesc)
return NULL;
pte = ptdesc_page(ptdesc);


>   if (!pte)
>   return NULL;
>   if (!PageHighMem(pte))
>   clean_pte_table(page_address(pte));
> - return pte;
> + return page_ptdesc(pte);
>  }
>  
>  static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,

-- 
Sincerely yours,
Mike.

___
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] mm/pgtable: convert pgtable_t to ptdesc pointer

2026-01-06 Thread alexs
From: Alex Shi 

After struct ptdesc introduced, pgtable_t should used it instead of old
struct page pointer. The only thing in the way for this change is just
pgtable->lru in pgtable_trans_huge_deposit/withdraw.

Let's convert them into ptdesc and use struct ptdesc* as pgtable_t.
Thanks testing support from kernel test robot 

Signed-off-by: Alex Shi 
---
 arch/alpha/include/asm/page.h|  2 +-
 arch/alpha/include/asm/pgalloc.h |  2 +-
 arch/arc/include/asm/page.h  |  2 +-
 arch/arc/include/asm/pgalloc.h   |  2 +-
 arch/arm/include/asm/page.h  |  2 +-
 arch/arm/include/asm/pgalloc.h   |  6 +++---
 arch/arm/include/asm/tlb.h   |  4 +---
 arch/arm64/include/asm/page.h|  2 +-
 arch/arm64/include/asm/pgalloc.h |  2 +-
 arch/csky/include/asm/page.h |  2 +-
 arch/csky/include/asm/pgalloc.h  |  2 +-
 arch/hexagon/include/asm/page.h  |  2 +-
 arch/hexagon/include/asm/pgalloc.h   |  2 +-
 arch/loongarch/include/asm/page.h|  2 +-
 arch/loongarch/include/asm/pgalloc.h |  2 +-
 arch/m68k/include/asm/page.h |  2 +-
 arch/microblaze/include/asm/page.h   |  2 +-
 arch/mips/include/asm/page.h |  2 +-
 arch/mips/include/asm/pgalloc.h  |  2 +-
 arch/nios2/include/asm/page.h|  2 +-
 arch/nios2/include/asm/pgalloc.h |  2 +-
 arch/openrisc/include/asm/page.h |  2 +-
 arch/parisc/include/asm/page.h   |  2 +-
 arch/riscv/include/asm/page.h|  2 +-
 arch/riscv/include/asm/pgalloc.h |  4 ++--
 arch/sh/include/asm/page.h   |  2 +-
 arch/sh/include/asm/pgalloc.h|  2 +-
 arch/um/include/asm/page.h   |  2 +-
 arch/um/include/asm/pgalloc.h|  8 
 arch/x86/include/asm/pgalloc.h   |  8 
 arch/x86/include/asm/pgtable_types.h |  2 +-
 arch/x86/mm/pgtable.c|  6 +++---
 arch/xtensa/include/asm/page.h   |  2 +-
 arch/xtensa/include/asm/pgalloc.h|  6 +++---
 include/asm-generic/pgalloc.h|  8 +++-
 include/linux/pgtable.h  |  2 +-
 mm/pgtable-generic.c | 15 ++-
 37 files changed, 57 insertions(+), 64 deletions(-)

diff --git a/arch/alpha/include/asm/page.h b/arch/alpha/include/asm/page.h
index d2c6667d73e9..6edd9207f6bb 100644
--- a/arch/alpha/include/asm/page.h
+++ b/arch/alpha/include/asm/page.h
@@ -58,7 +58,7 @@ typedef unsigned long pgprot_t;
 
 #endif /* STRICT_MM_TYPECHECKS */
 
-typedef struct page *pgtable_t;
+typedef struct ptdesc *pgtable_t;
 
 #ifdef USE_48_BIT_KSEG
 #define PAGE_OFFSET0x8000UL
diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
index 68be7adbfe58..11271b3e8186 100644
--- a/arch/alpha/include/asm/pgalloc.h
+++ b/arch/alpha/include/asm/pgalloc.h
@@ -16,7 +16,7 @@
 static inline void
 pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t pte)
 {
-   pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET));
+   pmd_set(pmd, (pte_t *)(page_to_pa(ptdesc_page(pte)) + PAGE_OFFSET));
 }
 
 static inline void
diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 9720fe6b2c24..26bfc16e95ce 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -82,7 +82,7 @@ typedef struct {
 #define __pgprot(x)((pgprot_t) { (x) })
 #define pte_pgprot(x)  __pgprot(pte_val(x))
 
-typedef struct page *pgtable_t;
+typedef struct ptdesc *pgtable_t;
 
 /*
  * When HIGHMEM is enabled we have holes in the memory map so we need
diff --git a/arch/arc/include/asm/pgalloc.h b/arch/arc/include/asm/pgalloc.h
index dfae070fe8d5..ff36debca073 100644
--- a/arch/arc/include/asm/pgalloc.h
+++ b/arch/arc/include/asm/pgalloc.h
@@ -48,7 +48,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t 
*pte)
 
 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t 
pte_page)
 {
-   set_pmd(pmd, __pmd((unsigned long)page_address(pte_page)));
+   set_pmd(pmd, __pmd((unsigned long)ptdesc_address(pte_page)));
 }
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index ef11b721230e..861804e56be7 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -173,7 +173,7 @@ extern void copy_page(void *to, const void *from);
 
 #endif /* CONFIG_MMU */
 
-typedef struct page *pgtable_t;
+typedef struct ptdesc *pgtable_t;
 
 #ifdef CONFIG_HAVE_ARCH_PFN_VALID
 extern int pfn_valid(unsigned long);
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
index a17f01235c29..1a3484c2df4c 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -96,12 +96,12 @@ pte_alloc_one(struct mm_struct *mm)
 {
struct page *pte;
 
-   pte = __pte_alloc_one(mm, GFP_PGTABLE_USER | PGTABLE_HIGHMEM);
+   pte = ptdesc_page(__pte_alloc_one(mm, GFP_PGTABLE_USER | 
PGTABLE_HIGHMEM));
if (!pte)
return NULL;
if (!PageHighMem(