linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Make PMD_ORDER generically available
@ 2021-07-15 13:46 Matthew Wilcox (Oracle)
  2021-07-15 13:46 ` [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER Matthew Wilcox (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-07-15 13:46 UTC (permalink / raw)
  To: linux-arch, linux-parisc, linux-mips, linux-arm-kernel
  Cc: Matthew Wilcox (Oracle), linux-kernel

These three architectures each define PMD_ORDER to mean "the order of
an allocation for a PMD table", but logically PMD_ORDER should be the
order of a PMD allocation, ie (PMD_SHIFT - PAGE_SHIFT) as DAX defines it.

Could each architecture maintainer please apply the appropriate patch
to their respective trees?

Matthew Wilcox (Oracle) (3):
  arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  mips: Rename PMD_ORDER to PMD_TABLE_ORDER
  parisc: Rename PMD_ORDER to PMD_TABLE_ORDER

 arch/arm/kernel/head.S             | 34 +++++++++++++++---------------
 arch/mips/include/asm/pgalloc.h    |  2 +-
 arch/mips/include/asm/pgtable-32.h |  2 +-
 arch/mips/include/asm/pgtable-64.h | 18 ++++++++--------
 arch/mips/kernel/asm-offsets.c     |  2 +-
 arch/parisc/include/asm/pgalloc.h  |  6 +++---
 arch/parisc/include/asm/pgtable.h  |  4 ++--
 arch/parisc/mm/init.c              |  4 ++--
 8 files changed, 36 insertions(+), 36 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 13:46 [PATCH 0/3] Make PMD_ORDER generically available Matthew Wilcox (Oracle)
@ 2021-07-15 13:46 ` Matthew Wilcox (Oracle)
  2021-07-15 16:47   ` Russell King (Oracle)
  2021-07-15 13:46 ` [PATCH 2/3] mips: " Matthew Wilcox (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-07-15 13:46 UTC (permalink / raw)
  To: linux-arch, linux-parisc, linux-mips, linux-arm-kernel
  Cc: Matthew Wilcox (Oracle), linux-kernel

This is the order of the page table allocation, not the order of a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/arm/kernel/head.S | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 9eb0b4dbcc12..6da39a1d70ba 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -38,10 +38,10 @@
 #ifdef CONFIG_ARM_LPAE
 	/* LPAE requires an additional page for the PGD */
 #define PG_DIR_SIZE	0x5000
-#define PMD_ORDER	3
+#define PMD_TABLE_ORDER	3
 #else
 #define PG_DIR_SIZE	0x4000
-#define PMD_ORDER	2
+#define PMD_TABLE_ORDER	2
 #endif
 
 	.globl	swapper_pg_dir
@@ -237,7 +237,7 @@ __create_page_tables:
 	mov	r6, r6, lsr #SECTION_SHIFT
 
 1:	orr	r3, r7, r5, lsl #SECTION_SHIFT	@ flags + kernel base
-	str	r3, [r4, r5, lsl #PMD_ORDER]	@ identity mapping
+	str	r3, [r4, r5, lsl #PMD_TABLE_ORDER]	@ identity mapping
 	cmp	r5, r6
 	addlo	r5, r5, #1			@ next section
 	blo	1b
@@ -247,13 +247,13 @@ __create_page_tables:
 	 * set two variables to indicate the physical start and end of the
 	 * kernel.
 	 */
-	add	r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_TABLE_ORDER)
 	ldr	r6, =(_end - 1)
 	adr_l	r5, kernel_sec_start		@ _pa(kernel_sec_start)
 	str	r8, [r5]			@ Save physical start of kernel
 	orr	r3, r8, r7			@ Add the MMU flags
-	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
-1:	str	r3, [r0], #1 << PMD_ORDER
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_TABLE_ORDER)
+1:	str	r3, [r0], #1 << PMD_TABLE_ORDER
 	add	r3, r3, #1 << SECTION_SHIFT
 	cmp	r0, r6
 	bls	1b
@@ -269,14 +269,14 @@ __create_page_tables:
 	mov	r3, pc
 	mov	r3, r3, lsr #SECTION_SHIFT
 	orr	r3, r7, r3, lsl #SECTION_SHIFT
-	add	r0, r4,  #(XIP_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER)
-	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]!
+	add	r0, r4,  #(XIP_START & 0xff000000) >> (SECTION_SHIFT - PMD_TABLE_ORDER)
+	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_TABLE_ORDER]!
 	ldr	r6, =(_edata_loc - 1)
-	add	r0, r0, #1 << PMD_ORDER
-	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER)
+	add	r0, r0, #1 << PMD_TABLE_ORDER
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_TABLE_ORDER)
 1:	cmp	r0, r6
 	add	r3, r3, #1 << SECTION_SHIFT
-	strls	r3, [r0], #1 << PMD_ORDER
+	strls	r3, [r0], #1 << PMD_TABLE_ORDER
 	bls	1b
 #endif
 
@@ -286,10 +286,10 @@ __create_page_tables:
 	 */
 	mov	r0, r2, lsr #SECTION_SHIFT
 	cmp	r2, #0
-	ldrne	r3, =FDT_FIXED_BASE >> (SECTION_SHIFT - PMD_ORDER)
+	ldrne	r3, =FDT_FIXED_BASE >> (SECTION_SHIFT - PMD_TABLE_ORDER)
 	addne	r3, r3, r4
 	orrne	r6, r7, r0, lsl #SECTION_SHIFT
-	strne	r6, [r3], #1 << PMD_ORDER
+	strne	r6, [r3], #1 << PMD_TABLE_ORDER
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
 
@@ -308,7 +308,7 @@ __create_page_tables:
 	addruart r7, r3, r0
 
 	mov	r3, r3, lsr #SECTION_SHIFT
-	mov	r3, r3, lsl #PMD_ORDER
+	mov	r3, r3, lsl #PMD_TABLE_ORDER
 
 	add	r0, r4, r3
 	mov	r3, r7, lsr #SECTION_SHIFT
@@ -338,7 +338,7 @@ __create_page_tables:
 	 * If we're using the NetWinder or CATS, we also need to map
 	 * in the 16550-type serial port for the debug messages
 	 */
-	add	r0, r4, #0xff000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xff000000 >> (SECTION_SHIFT - PMD_TABLE_ORDER)
 	orr	r3, r7, #0x7c000000
 	str	r3, [r0]
 #endif
@@ -348,10 +348,10 @@ __create_page_tables:
 	 * Similar reasons here - for debug.  This is
 	 * only for Acorn RiscPC architectures.
 	 */
-	add	r0, r4, #0x02000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0x02000000 >> (SECTION_SHIFT - PMD_TABLE_ORDER)
 	orr	r3, r7, #0x02000000
 	str	r3, [r0]
-	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_TABLE_ORDER)
 	str	r3, [r0]
 #endif
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] mips: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 13:46 [PATCH 0/3] Make PMD_ORDER generically available Matthew Wilcox (Oracle)
  2021-07-15 13:46 ` [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER Matthew Wilcox (Oracle)
@ 2021-07-15 13:46 ` Matthew Wilcox (Oracle)
  2021-07-15 13:46 ` [PATCH 3/3] parisc: " Matthew Wilcox (Oracle)
  2021-07-15 16:28 ` [PATCH 0/3] Make PMD_ORDER generically available Helge Deller
  3 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-07-15 13:46 UTC (permalink / raw)
  To: linux-arch, linux-parisc, linux-mips, linux-arm-kernel
  Cc: Matthew Wilcox (Oracle), linux-kernel

This is the order of the page table allocation, not the order of a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/mips/include/asm/pgalloc.h    |  2 +-
 arch/mips/include/asm/pgtable-32.h |  2 +-
 arch/mips/include/asm/pgtable-64.h | 18 +++++++++---------
 arch/mips/kernel/asm-offsets.c     |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 4b2567d6b2df..795e9e2219c9 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -61,7 +61,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 	pmd_t *pmd = NULL;
 	struct page *pg;
 
-	pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER);
+	pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_TABLE_ORDER);
 	if (pg) {
 		pgtable_pmd_page_ctor(pg);
 		pmd = (pmd_t *)page_address(pg);
diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
index 95df9c293d8d..8d57bd5b0b94 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -82,7 +82,7 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
 
 #define PGD_ORDER	(__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
 #define PUD_ORDER	aieeee_attempt_to_allocate_pud
-#define PMD_ORDER	aieeee_attempt_to_allocate_pmd
+#define PMD_TABLE_ORDER	aieeee_attempt_to_allocate_pmd
 #define PTE_ORDER	0
 
 #define PTRS_PER_PGD	(USER_PTRS_PER_PGD * 2)
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 41921acdc9d8..ae0d5a09064d 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -51,12 +51,12 @@
 #define PMD_MASK	(~(PMD_SIZE-1))
 
 # ifdef __PAGETABLE_PUD_FOLDED
-# define PGDIR_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
+# define PGDIR_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_TABLE_ORDER - 3))
 # endif
 #endif
 
 #ifndef __PAGETABLE_PUD_FOLDED
-#define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
+#define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_TABLE_ORDER - 3))
 #define PUD_SIZE	(1UL << PUD_SHIFT)
 #define PUD_MASK	(~(PUD_SIZE-1))
 #define PGDIR_SHIFT	(PUD_SHIFT + (PAGE_SHIFT + PUD_ORDER - 3))
@@ -91,13 +91,13 @@
 #  define PGD_ORDER		1
 #  define PUD_ORDER		aieeee_attempt_to_allocate_pud
 # endif
-#define PMD_ORDER		0
+#define PMD_TABLE_ORDER		0
 #define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_8KB
 #define PGD_ORDER		0
 #define PUD_ORDER		aieeee_attempt_to_allocate_pud
-#define PMD_ORDER		0
+#define PMD_TABLE_ORDER		0
 #define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_16KB
@@ -107,22 +107,22 @@
 #define PGD_ORDER               0
 #endif
 #define PUD_ORDER		aieeee_attempt_to_allocate_pud
-#define PMD_ORDER		0
+#define PMD_TABLE_ORDER		0
 #define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_32KB
 #define PGD_ORDER		0
 #define PUD_ORDER		aieeee_attempt_to_allocate_pud
-#define PMD_ORDER		0
+#define PMD_TABLE_ORDER		0
 #define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_64KB
 #define PGD_ORDER		0
 #define PUD_ORDER		aieeee_attempt_to_allocate_pud
 #ifdef CONFIG_MIPS_VA_BITS_48
-#define PMD_ORDER		0
+#define PMD_TABLE_ORDER		0
 #else
-#define PMD_ORDER		aieeee_attempt_to_allocate_pmd
+#define PMD_TABLE_ORDER		aieeee_attempt_to_allocate_pmd
 #endif
 #define PTE_ORDER		0
 #endif
@@ -132,7 +132,7 @@
 #define PTRS_PER_PUD	((PAGE_SIZE << PUD_ORDER) / sizeof(pud_t))
 #endif
 #ifndef __PAGETABLE_PMD_FOLDED
-#define PTRS_PER_PMD	((PAGE_SIZE << PMD_ORDER) / sizeof(pmd_t))
+#define PTRS_PER_PMD	((PAGE_SIZE << PMD_TABLE_ORDER) / sizeof(pmd_t))
 #endif
 #define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
 
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 04ca75278f02..d6b89080d245 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -198,7 +198,7 @@ void output_mm_defines(void)
 	BLANK();
 	DEFINE(_PGD_ORDER, PGD_ORDER);
 #ifndef __PAGETABLE_PMD_FOLDED
-	DEFINE(_PMD_ORDER, PMD_ORDER);
+	DEFINE(_PMD_TABLE_ORDER, PMD_TABLE_ORDER);
 #endif
 	DEFINE(_PTE_ORDER, PTE_ORDER);
 	BLANK();
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] parisc: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 13:46 [PATCH 0/3] Make PMD_ORDER generically available Matthew Wilcox (Oracle)
  2021-07-15 13:46 ` [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER Matthew Wilcox (Oracle)
  2021-07-15 13:46 ` [PATCH 2/3] mips: " Matthew Wilcox (Oracle)
@ 2021-07-15 13:46 ` Matthew Wilcox (Oracle)
  2021-07-15 16:28 ` [PATCH 0/3] Make PMD_ORDER generically available Helge Deller
  3 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-07-15 13:46 UTC (permalink / raw)
  To: linux-arch, linux-parisc, linux-mips, linux-arm-kernel
  Cc: Matthew Wilcox (Oracle), linux-kernel

This is the order of the page table allocation, not the order of a PMD.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/parisc/include/asm/pgalloc.h | 6 +++---
 arch/parisc/include/asm/pgtable.h | 4 ++--
 arch/parisc/mm/init.c             | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
index 6a7e98e71f1d..54b63374579b 100644
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -48,15 +48,15 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	pmd_t *pmd;
 
-	pmd = (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_ORDER);
+	pmd = (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_TABLE_ORDER);
 	if (likely(pmd))
-		memset ((void *)pmd, 0, PAGE_SIZE << PMD_ORDER);
+		memset ((void *)pmd, 0, PAGE_SIZE << PMD_TABLE_ORDER);
 	return pmd;
 }
 
 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 {
-	free_pages((unsigned long)pmd, PMD_ORDER);
+	free_pages((unsigned long)pmd, PMD_TABLE_ORDER);
 }
 #endif
 
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 43937af127b1..7badd872f05a 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -112,7 +112,7 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 #define KERNEL_INITIAL_SIZE	(1 << KERNEL_INITIAL_ORDER)
 
 #if CONFIG_PGTABLE_LEVELS == 3
-#define PMD_ORDER	1
+#define PMD_TABLE_ORDER	1
 #define PGD_ORDER	0
 #else
 #define PGD_ORDER	1
@@ -131,7 +131,7 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 #define PMD_SHIFT       (PLD_SHIFT + BITS_PER_PTE)
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
-#define BITS_PER_PMD	(PAGE_SHIFT + PMD_ORDER - BITS_PER_PMD_ENTRY)
+#define BITS_PER_PMD	(PAGE_SHIFT + PMD_TABLE_ORDER - BITS_PER_PMD_ENTRY)
 #define PTRS_PER_PMD    (1UL << BITS_PER_PMD)
 #else
 #define BITS_PER_PMD	0
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 591a4e939415..3f7d6d5b56ac 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -378,8 +378,8 @@ static void __init map_pages(unsigned long start_vaddr,
 
 #if CONFIG_PGTABLE_LEVELS == 3
 		if (pud_none(*pud)) {
-			pmd = memblock_alloc(PAGE_SIZE << PMD_ORDER,
-					     PAGE_SIZE << PMD_ORDER);
+			pmd = memblock_alloc(PAGE_SIZE << PMD_TABLE_ORDER,
+					     PAGE_SIZE << PMD_TABLE_ORDER);
 			if (!pmd)
 				panic("pmd allocation failed.\n");
 			pud_populate(NULL, pud, pmd);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] Make PMD_ORDER generically available
  2021-07-15 13:46 [PATCH 0/3] Make PMD_ORDER generically available Matthew Wilcox (Oracle)
                   ` (2 preceding siblings ...)
  2021-07-15 13:46 ` [PATCH 3/3] parisc: " Matthew Wilcox (Oracle)
@ 2021-07-15 16:28 ` Helge Deller
  2021-07-15 16:38   ` Matthew Wilcox
  3 siblings, 1 reply; 10+ messages in thread
From: Helge Deller @ 2021-07-15 16:28 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle),
	linux-arch, linux-parisc, linux-mips, linux-arm-kernel
  Cc: linux-kernel

On 7/15/21 3:46 PM, Matthew Wilcox (Oracle) wrote:
> These three architectures each define PMD_ORDER to mean "the order of
> an allocation for a PMD table", but logically PMD_ORDER should be the
> order of a PMD allocation, ie (PMD_SHIFT - PAGE_SHIFT) as DAX defines it.

Some architectures do have PGD_ORDER, PUD_ORDER and PTE_ORDER as well.
If you rename PMD_ORDER, IMHO the others should be renamed too.

Why not simply rename "PMD_ORDER" in fs/dax.c to e.g.
#define DAX_PMD_SHIFT   (PMD_SHIFT - PAGE_SHIFT)
and use that inside the dax filesystem code?

Helge

> Could each architecture maintainer please apply the appropriate patch
> to their respective trees?
>
> Matthew Wilcox (Oracle) (3):
>    arm: Rename PMD_ORDER to PMD_TABLE_ORDER
>    mips: Rename PMD_ORDER to PMD_TABLE_ORDER
>    parisc: Rename PMD_ORDER to PMD_TABLE_ORDER
>
>   arch/arm/kernel/head.S             | 34 +++++++++++++++---------------
>   arch/mips/include/asm/pgalloc.h    |  2 +-
>   arch/mips/include/asm/pgtable-32.h |  2 +-
>   arch/mips/include/asm/pgtable-64.h | 18 ++++++++--------
>   arch/mips/kernel/asm-offsets.c     |  2 +-
>   arch/parisc/include/asm/pgalloc.h  |  6 +++---
>   arch/parisc/include/asm/pgtable.h  |  4 ++--
>   arch/parisc/mm/init.c              |  4 ++--
>   8 files changed, 36 insertions(+), 36 deletions(-)
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] Make PMD_ORDER generically available
  2021-07-15 16:28 ` [PATCH 0/3] Make PMD_ORDER generically available Helge Deller
@ 2021-07-15 16:38   ` Matthew Wilcox
  0 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2021-07-15 16:38 UTC (permalink / raw)
  To: Helge Deller
  Cc: linux-arch, linux-parisc, linux-mips, linux-arm-kernel, linux-kernel

On Thu, Jul 15, 2021 at 06:28:42PM +0200, Helge Deller wrote:
> On 7/15/21 3:46 PM, Matthew Wilcox (Oracle) wrote:
> > These three architectures each define PMD_ORDER to mean "the order of
> > an allocation for a PMD table", but logically PMD_ORDER should be the
> > order of a PMD allocation, ie (PMD_SHIFT - PAGE_SHIFT) as DAX defines it.
> 
> Some architectures do have PGD_ORDER, PUD_ORDER and PTE_ORDER as well.
> If you rename PMD_ORDER, IMHO the others should be renamed too.
> 
> Why not simply rename "PMD_ORDER" in fs/dax.c to e.g.
> #define DAX_PMD_SHIFT   (PMD_SHIFT - PAGE_SHIFT)
> and use that inside the dax filesystem code?

Because that's wrong.  PMD order is clearly the order of a PMD page,
not the order of a PMD table.

I'm sure the others should also be renamed, but this is the one which
is causing me pain today.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 13:46 ` [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER Matthew Wilcox (Oracle)
@ 2021-07-15 16:47   ` Russell King (Oracle)
  2021-07-15 18:10     ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Russell King (Oracle) @ 2021-07-15 16:47 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: linux-arch, linux-parisc, linux-mips, linux-arm-kernel, linux-kernel

On Thu, Jul 15, 2021 at 02:46:10PM +0100, Matthew Wilcox (Oracle) wrote:
> This is the order of the page table allocation, not the order of a PMD.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  arch/arm/kernel/head.S | 34 +++++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index 9eb0b4dbcc12..6da39a1d70ba 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -38,10 +38,10 @@
>  #ifdef CONFIG_ARM_LPAE
>  	/* LPAE requires an additional page for the PGD */
>  #define PG_DIR_SIZE	0x5000
> -#define PMD_ORDER	3
> +#define PMD_TABLE_ORDER	3
>  #else
>  #define PG_DIR_SIZE	0x4000
> -#define PMD_ORDER	2
> +#define PMD_TABLE_ORDER	2

I think PMD_ENTRY_ORDER would make more sense here - this is the
power-of-2 of an individual PMD entry, not of the entire table.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 16:47   ` Russell King (Oracle)
@ 2021-07-15 18:10     ` Matthew Wilcox
  2021-07-15 18:37       ` Russell King (Oracle)
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2021-07-15 18:10 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: linux-arch, linux-parisc, linux-mips, linux-arm-kernel, linux-kernel

On Thu, Jul 15, 2021 at 05:47:41PM +0100, Russell King (Oracle) wrote:
> On Thu, Jul 15, 2021 at 02:46:10PM +0100, Matthew Wilcox (Oracle) wrote:
> > This is the order of the page table allocation, not the order of a PMD.
> > -#define PMD_ORDER	3
> > +#define PMD_TABLE_ORDER	3
> >  #else
> >  #define PG_DIR_SIZE	0x4000
> > -#define PMD_ORDER	2
> > +#define PMD_TABLE_ORDER	2
> 
> I think PMD_ENTRY_ORDER would make more sense here - this is the
> power-of-2 of an individual PMD entry, not of the entire table.

But ... we have two kinds of PMD entries.  We have the direct entry that
points to a 1-16MB sized chunk of memory, and we have the table entry that
points to a 4k-32k chunk of memory that contains PTEs.  So I don't think
calling it 'entry' order actually disambiguates anything.  That's why
I went with 'table' -- I can't think of anything else to call it!
PMD_PTE_ARRAY_ORDER doesn't seem like an improvement to me ...

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 18:10     ` Matthew Wilcox
@ 2021-07-15 18:37       ` Russell King (Oracle)
  2021-07-15 19:16         ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Russell King (Oracle) @ 2021-07-15 18:37 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-arch, linux-parisc, linux-mips, linux-arm-kernel, linux-kernel

On Thu, Jul 15, 2021 at 07:10:54PM +0100, Matthew Wilcox wrote:
> On Thu, Jul 15, 2021 at 05:47:41PM +0100, Russell King (Oracle) wrote:
> > On Thu, Jul 15, 2021 at 02:46:10PM +0100, Matthew Wilcox (Oracle) wrote:
> > > This is the order of the page table allocation, not the order of a PMD.
> > > -#define PMD_ORDER	3
> > > +#define PMD_TABLE_ORDER	3
> > >  #else
> > >  #define PG_DIR_SIZE	0x4000
> > > -#define PMD_ORDER	2
> > > +#define PMD_TABLE_ORDER	2
> > 
> > I think PMD_ENTRY_ORDER would make more sense here - this is the
> > power-of-2 of an individual PMD entry, not of the entire table.
> 
> But ... we have two kinds of PMD entries.  We have the direct entry that
> points to a 1-16MB sized chunk of memory, and we have the table entry that
> points to a 4k-32k chunk of memory that contains PTEs.  So I don't think
> calling it 'entry' order actually disambiguates anything.  That's why
> I went with 'table' -- I can't think of anything else to call it!
> PMD_PTE_ARRAY_ORDER doesn't seem like an improvement to me ...

There may be two kinds of PMD entries, but that isn't relevant here.
Going back to the original terminology, 1 << PMD_ORDER here is the
size of each PMD entry. It doesn't have anything to do with how much
memory is being mapped by each entry.

I think what is confusing you is stuff like:

        add     r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER)

r4 is the base address of the page tables, and r0 is the address of
the entry we want to manipulate for "KERNEL_OFFSET" - which is the
virtual address. 1 << SECTION_SHIFT is how much memory each entry
maps (and this is fixed here - there's no variability as you suggest
above.)

Effectively, the calculation above is:

	index = KERNEL_OFFSET >> SECTION_SHIFT;
	pmd_entry_size = 1 << PMD_ORDER;
	r0 = base + index * pmd_entry_size;

but in a single instruction as we can be sure that KERNEL_OFFSET will
have zeros as the low bits after shifting by SECTION_SHIFT - PMD_ORDER.

Hope this helps to explain what this PMD_ORDER is actually doing here.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER
  2021-07-15 18:37       ` Russell King (Oracle)
@ 2021-07-15 19:16         ` Matthew Wilcox
  0 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2021-07-15 19:16 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: linux-arch, linux-parisc, linux-mips, linux-arm-kernel, linux-kernel

On Thu, Jul 15, 2021 at 07:37:27PM +0100, Russell King (Oracle) wrote:
> On Thu, Jul 15, 2021 at 07:10:54PM +0100, Matthew Wilcox wrote:
> > On Thu, Jul 15, 2021 at 05:47:41PM +0100, Russell King (Oracle) wrote:
> > > On Thu, Jul 15, 2021 at 02:46:10PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > This is the order of the page table allocation, not the order of a PMD.
> > > > -#define PMD_ORDER	3
> > > > +#define PMD_TABLE_ORDER	3
> > > >  #else
> > > >  #define PG_DIR_SIZE	0x4000
> > > > -#define PMD_ORDER	2
> > > > +#define PMD_TABLE_ORDER	2
> > > 
> > > I think PMD_ENTRY_ORDER would make more sense here - this is the
> > > power-of-2 of an individual PMD entry, not of the entire table.
> > 
> > But ... we have two kinds of PMD entries.  We have the direct entry that
> > points to a 1-16MB sized chunk of memory, and we have the table entry that
> > points to a 4k-32k chunk of memory that contains PTEs.  So I don't think
> > calling it 'entry' order actually disambiguates anything.  That's why
> > I went with 'table' -- I can't think of anything else to call it!
> > PMD_PTE_ARRAY_ORDER doesn't seem like an improvement to me ...
> 
> There may be two kinds of PMD entries, but that isn't relevant here.
> Going back to the original terminology, 1 << PMD_ORDER here is the
> size of each PMD entry. It doesn't have anything to do with how much
> memory is being mapped by each entry.

Oh.  Oh!  So, 'order' is usually a shift that is _added on to_ the
PAGE_SHIFT in order to find how many bytes are in question.  See
include/asm-generic/getorder.h.

Now, PMD_SHIFT is already in use, but perhaps what is meant here is
PMD_ENTRY_SHIFT?

> I think what is confusing you is stuff like:
> 
>         add     r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER)
> 
> r4 is the base address of the page tables, and r0 is the address of
> the entry we want to manipulate for "KERNEL_OFFSET" - which is the
> virtual address. 1 << SECTION_SHIFT is how much memory each entry
> maps (and this is fixed here - there's no variability as you suggest
> above.)

(the variability I intended above was more to accommodate architectural
differences; I hate to use x86-specific numbers like 4KiB and 2MiB)

> Effectively, the calculation above is:
> 
> 	index = KERNEL_OFFSET >> SECTION_SHIFT;
> 	pmd_entry_size = 1 << PMD_ORDER;
> 	r0 = base + index * pmd_entry_size;
> 
> but in a single instruction as we can be sure that KERNEL_OFFSET will
> have zeros as the low bits after shifting by SECTION_SHIFT - PMD_ORDER.
> 
> Hope this helps to explain what this PMD_ORDER is actually doing here.

Thank you, yes, I was terminally confused.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-15 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 13:46 [PATCH 0/3] Make PMD_ORDER generically available Matthew Wilcox (Oracle)
2021-07-15 13:46 ` [PATCH 1/3] arm: Rename PMD_ORDER to PMD_TABLE_ORDER Matthew Wilcox (Oracle)
2021-07-15 16:47   ` Russell King (Oracle)
2021-07-15 18:10     ` Matthew Wilcox
2021-07-15 18:37       ` Russell King (Oracle)
2021-07-15 19:16         ` Matthew Wilcox
2021-07-15 13:46 ` [PATCH 2/3] mips: " Matthew Wilcox (Oracle)
2021-07-15 13:46 ` [PATCH 3/3] parisc: " Matthew Wilcox (Oracle)
2021-07-15 16:28 ` [PATCH 0/3] Make PMD_ORDER generically available Helge Deller
2021-07-15 16:38   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).