All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] arch: make PxD_ORDER generically available
@ 2022-07-03 14:11 Mike Rapoport
  2022-07-03 14:11 ` [PATCH 01/14] csky: drop definition of PTE_ORDER Mike Rapoport
                   ` (15 more replies)
  0 siblings, 16 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

Hi,

The question what does PxD_ORDER define raises from time to time and
there is still a conflict between MIPS and DAX definitions.

Some time ago Matthew Wilcox suggested to use PMD_TABLE_ORDER to define
the order of page table allocation: 

[1] https://lore.kernel.org/linux-arch/YPCJftSTUBEnq2lI@casper.infradead.org/

The parisc patch made it in, but mips didn't. 
Now mips defines from asm/include/pgtable.h were copied to loongarch which
made it worse.

Let's deal with it once and for all and rename PxD_ORDER defines to
PxD_TABLE_ORDER or just drop them when the only possible order of page
table is 0.

I think the best way to merge this via mm tree with acks from arch
maintainers.

Matthew Wilcox (Oracle) (1):
  mips: Rename PMD_ORDER to PMD_TABLE_ORDER

Mike Rapoport (13):
  csky: drop definition of PTE_ORDER
  csky: drop definition of PGD_ORDER
  mips: Rename PUD_ORDER to PUD_TABLE_ORDER
  mips: drop definitions of PTE_ORDER
  mips: Rename PGD_ORDER to PGD_TABLE_ORDER
  nios2: drop definition of PTE_ORDER
  nios2: drop definition of PGD_ORDER
  loongarch: drop definition of PTE_ORDER
  loongarch: drop definition of PMD_ORDER
  loongarch: drop definition of PUD_ORDER
  loongarch: drop definition of PGD_ORDER
  parisc: Rename PGD_ORDER to PGD_TABLE_ORDER
  xtensa: drop definition of PGD_ORDER

 arch/csky/include/asm/pgalloc.h      |  2 +-
 arch/csky/include/asm/pgtable.h      |  6 +--
 arch/loongarch/include/asm/pgalloc.h |  6 +--
 arch/loongarch/include/asm/pgtable.h | 27 +++++-------
 arch/loongarch/kernel/asm-offsets.c  |  5 ---
 arch/loongarch/mm/pgtable.c          |  2 +-
 arch/loongarch/mm/tlbex.S            |  6 +--
 arch/mips/include/asm/pgalloc.h      |  8 ++--
 arch/mips/include/asm/pgtable-32.h   | 19 ++++-----
 arch/mips/include/asm/pgtable-64.h   | 61 +++++++++++++---------------
 arch/mips/kernel/asm-offsets.c       |  5 ---
 arch/mips/kvm/mmu.c                  |  2 +-
 arch/mips/mm/pgtable.c               |  2 +-
 arch/mips/mm/tlbex.c                 | 14 +++----
 arch/nios2/include/asm/pgtable.h     |  7 +---
 arch/nios2/mm/init.c                 |  5 +--
 arch/nios2/mm/pgtable.c              |  2 +-
 arch/parisc/include/asm/pgalloc.h    |  6 +--
 arch/parisc/include/asm/pgtable.h    |  8 ++--
 arch/xtensa/include/asm/pgalloc.h    |  2 +-
 arch/xtensa/include/asm/pgtable.h    |  1 -
 21 files changed, 84 insertions(+), 112 deletions(-)


base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a
-- 
2.34.1


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

* [PATCH 01/14] csky: drop definition of PTE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 02/14] csky: drop definition of PGD_ORDER Mike Rapoport
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PTE.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/csky/include/asm/pgtable.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h
index bbe245117777..f8bb1e12334b 100644
--- a/arch/csky/include/asm/pgtable.h
+++ b/arch/csky/include/asm/pgtable.h
@@ -19,11 +19,10 @@
  * C-SKY is two-level paging structure:
  */
 #define PGD_ORDER	0
-#define PTE_ORDER	0
 
 #define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
 #define PTRS_PER_PMD	1
-#define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+#define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 
 #define pte_ERROR(e) \
 	pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
-- 
2.34.1


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

* [PATCH 02/14] csky: drop definition of PGD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
  2022-07-03 14:11 ` [PATCH 01/14] csky: drop definition of PTE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 03/14] mips: Rename PMD_ORDER to PMD_TABLE_ORDER Mike Rapoport
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PGD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/csky/include/asm/pgalloc.h | 2 +-
 arch/csky/include/asm/pgtable.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/csky/include/asm/pgalloc.h b/arch/csky/include/asm/pgalloc.h
index bbbd0698b397..7d57e5da0914 100644
--- a/arch/csky/include/asm/pgalloc.h
+++ b/arch/csky/include/asm/pgalloc.h
@@ -44,7 +44,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 	pgd_t *ret;
 	pgd_t *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = (pgd_t *) __get_free_page(GFP_KERNEL);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init((unsigned long *)ret);
diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h
index f8bb1e12334b..0f1e2eda1601 100644
--- a/arch/csky/include/asm/pgtable.h
+++ b/arch/csky/include/asm/pgtable.h
@@ -18,9 +18,8 @@
 /*
  * C-SKY is two-level paging structure:
  */
-#define PGD_ORDER	0
 
-#define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
+#define PTRS_PER_PGD	(PAGE_SIZE / sizeof(pgd_t))
 #define PTRS_PER_PMD	1
 #define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 
-- 
2.34.1


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

* [PATCH 03/14] mips: Rename PMD_ORDER to PMD_TABLE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
  2022-07-03 14:11 ` [PATCH 01/14] csky: drop definition of PTE_ORDER Mike Rapoport
  2022-07-03 14:11 ` [PATCH 02/14] csky: drop definition of PGD_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 04/14] mips: Rename PUD_ORDER to PUD_TABLE_ORDER Mike Rapoport
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

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

While at it remove unused defintion of _PMD_ORDER in asm-offsets.

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

diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 867e9c3db76e..0ef245cfcae9 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -67,12 +67,12 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 	pmd_t *pmd;
 	struct page *pg;
 
-	pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER);
+	pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_TABLE_ORDER);
 	if (!pg)
 		return NULL;
 
 	if (!pgtable_pmd_page_ctor(pg)) {
-		__free_pages(pg, PMD_ORDER);
+		__free_pages(pg, PMD_TABLE_ORDER);
 		return NULL;
 	}
 
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..ca7c5af7697d 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -197,9 +197,6 @@ void output_mm_defines(void)
 	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
 	BLANK();
 	DEFINE(_PGD_ORDER, PGD_ORDER);
-#ifndef __PAGETABLE_PMD_FOLDED
-	DEFINE(_PMD_ORDER, PMD_ORDER);
-#endif
 	DEFINE(_PTE_ORDER, PTE_ORDER);
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
-- 
2.34.1


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

* [PATCH 04/14] mips: Rename PUD_ORDER to PUD_TABLE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (2 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 03/14] mips: Rename PMD_ORDER to PMD_TABLE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 05/14] mips: drop definitions of PTE_ORDER Mike Rapoport
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

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

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/mips/include/asm/pgalloc.h    |  2 +-
 arch/mips/include/asm/pgtable-32.h |  2 +-
 arch/mips/include/asm/pgtable-64.h | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 0ef245cfcae9..1ef8e86ae565 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -91,7 +91,7 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	pud_t *pud;
 
-	pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_ORDER);
+	pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_TABLE_ORDER);
 	if (pud)
 		pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table);
 	return pud;
diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
index 8d57bd5b0b94..d9ae244a4fce 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -81,7 +81,7 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
 #endif
 
 #define PGD_ORDER	(__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
-#define PUD_ORDER	aieeee_attempt_to_allocate_pud
+#define PUD_TABLE_ORDER	aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER	aieeee_attempt_to_allocate_pmd
 #define PTE_ORDER	0
 
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index ae0d5a09064d..7daf9a6509d8 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -59,7 +59,7 @@
 #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))
+#define PGDIR_SHIFT	(PUD_SHIFT + (PAGE_SHIFT + PUD_TABLE_ORDER - 3))
 #endif
 
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
@@ -86,17 +86,17 @@
 #ifdef CONFIG_PAGE_SIZE_4KB
 # ifdef CONFIG_MIPS_VA_BITS_48
 #  define PGD_ORDER		0
-#  define PUD_ORDER		0
+#  define PUD_TABLE_ORDER		0
 # else
 #  define PGD_ORDER		1
-#  define PUD_ORDER		aieeee_attempt_to_allocate_pud
+#  define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 # endif
 #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 PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
 #define PTE_ORDER		0
 #endif
@@ -106,19 +106,19 @@
 #else
 #define PGD_ORDER               0
 #endif
-#define PUD_ORDER		aieeee_attempt_to_allocate_pud
+#define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #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 PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #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
+#define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #ifdef CONFIG_MIPS_VA_BITS_48
 #define PMD_TABLE_ORDER		0
 #else
@@ -129,7 +129,7 @@
 
 #define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
 #ifndef __PAGETABLE_PUD_FOLDED
-#define PTRS_PER_PUD	((PAGE_SIZE << PUD_ORDER) / sizeof(pud_t))
+#define PTRS_PER_PUD	((PAGE_SIZE << PUD_TABLE_ORDER) / sizeof(pud_t))
 #endif
 #ifndef __PAGETABLE_PMD_FOLDED
 #define PTRS_PER_PMD	((PAGE_SIZE << PMD_TABLE_ORDER) / sizeof(pmd_t))
-- 
2.34.1


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

* [PATCH 05/14] mips: drop definitions of PTE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (3 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 04/14] mips: Rename PUD_ORDER to PUD_TABLE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 06/14] mips: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PTE.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/mips/include/asm/pgtable-32.h |  9 ++++-----
 arch/mips/include/asm/pgtable-64.h | 15 +++++----------
 arch/mips/kernel/asm-offsets.c     |  1 -
 arch/mips/mm/tlbex.c               |  2 +-
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
index d9ae244a4fce..35bd519a1078 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -62,9 +62,9 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
 
 /* PGDIR_SHIFT determines what a third-level page table entry can map */
 #if defined(CONFIG_MIPS_HUGE_TLB_SUPPORT) && !defined(CONFIG_PHYS_ADDR_T_64BIT)
-# define PGDIR_SHIFT	(2 * PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2 - 1)
+# define PGDIR_SHIFT	(2 * PAGE_SHIFT - PTE_T_LOG2 - 1)
 #else
-# define PGDIR_SHIFT	(2 * PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2)
+# define PGDIR_SHIFT	(2 * PAGE_SHIFT - PTE_T_LOG2)
 #endif
 
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
@@ -83,13 +83,12 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
 #define PGD_ORDER	(__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
 #define PUD_TABLE_ORDER	aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER	aieeee_attempt_to_allocate_pmd
-#define PTE_ORDER	0
 
 #define PTRS_PER_PGD	(USER_PTRS_PER_PGD * 2)
 #if defined(CONFIG_MIPS_HUGE_TLB_SUPPORT) && !defined(CONFIG_PHYS_ADDR_T_64BIT)
-# define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t) / 2)
+# define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t) / 2)
 #else
-# define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+# define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 #endif
 
 #define USER_PTRS_PER_PGD	(0x80000000UL/PGDIR_SIZE)
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 7daf9a6509d8..dbf7e461d360 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -42,11 +42,11 @@
 
 /* PGDIR_SHIFT determines what a third-level page table entry can map */
 #ifdef __PAGETABLE_PMD_FOLDED
-#define PGDIR_SHIFT	(PAGE_SHIFT + PAGE_SHIFT + PTE_ORDER - 3)
+#define PGDIR_SHIFT	(PAGE_SHIFT + PAGE_SHIFT - 3)
 #else
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
-#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
+#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
 
@@ -86,19 +86,17 @@
 #ifdef CONFIG_PAGE_SIZE_4KB
 # ifdef CONFIG_MIPS_VA_BITS_48
 #  define PGD_ORDER		0
-#  define PUD_TABLE_ORDER		0
+#  define PUD_TABLE_ORDER	0
 # else
 #  define PGD_ORDER		1
-#  define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
+#  define PUD_TABLE_ORDER	aieeee_attempt_to_allocate_pud
 # endif
 #define PMD_TABLE_ORDER		0
-#define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_8KB
 #define PGD_ORDER		0
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
-#define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_16KB
 #ifdef CONFIG_MIPS_VA_BITS_48
@@ -108,13 +106,11 @@
 #endif
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
-#define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_32KB
 #define PGD_ORDER		0
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
-#define PTE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_64KB
 #define PGD_ORDER		0
@@ -124,7 +120,6 @@
 #else
 #define PMD_TABLE_ORDER		aieeee_attempt_to_allocate_pmd
 #endif
-#define PTE_ORDER		0
 #endif
 
 #define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
@@ -134,7 +129,7 @@
 #ifndef __PAGETABLE_PMD_FOLDED
 #define PTRS_PER_PMD	((PAGE_SIZE << PMD_TABLE_ORDER) / sizeof(pmd_t))
 #endif
-#define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+#define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 
 #define USER_PTRS_PER_PGD       ((TASK_SIZE64 / PGDIR_SIZE)?(TASK_SIZE64 / PGDIR_SIZE):1)
 
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index ca7c5af7697d..0c97f755e256 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -197,7 +197,6 @@ void output_mm_defines(void)
 	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
 	BLANK();
 	DEFINE(_PGD_ORDER, PGD_ORDER);
-	DEFINE(_PTE_ORDER, PTE_ORDER);
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
 	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 8dbbd99fc7e8..6e8e71f12fab 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -2065,7 +2065,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
 
 	UASM_i_MFC0(p, wr.r1, C0_BADVADDR);
 	UASM_i_LW(p, wr.r2, 0, wr.r2);
-	UASM_i_SRL(p, wr.r1, wr.r1, PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2);
+	UASM_i_SRL(p, wr.r1, wr.r1, PAGE_SHIFT - PTE_T_LOG2);
 	uasm_i_andi(p, wr.r1, wr.r1, (PTRS_PER_PTE - 1) << PTE_T_LOG2);
 	UASM_i_ADDU(p, wr.r2, wr.r2, wr.r1);
 
-- 
2.34.1


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

* [PATCH 06/14] mips: Rename PGD_ORDER to PGD_TABLE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (4 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 05/14] mips: drop definitions of PTE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 07/14] nios2: drop definition of PTE_ORDER Mike Rapoport
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

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

While at it remove unused defintion of _PGD_ORDER in asm-offsets.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/mips/include/asm/pgalloc.h    |  2 +-
 arch/mips/include/asm/pgtable-32.h |  6 +++---
 arch/mips/include/asm/pgtable-64.h | 16 ++++++++--------
 arch/mips/kernel/asm-offsets.c     |  1 -
 arch/mips/kvm/mmu.c                |  2 +-
 arch/mips/mm/pgtable.c             |  2 +-
 arch/mips/mm/tlbex.c               | 12 ++++++------
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 1ef8e86ae565..796035784c73 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -51,7 +51,7 @@ extern pgd_t *pgd_alloc(struct mm_struct *mm);
 
 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 {
-	free_pages((unsigned long)pgd, PGD_ORDER);
+	free_pages((unsigned long)pgd, PGD_TABLE_ORDER);
 }
 
 #define __pte_free_tlb(tlb,pte,address)			\
diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
index 35bd519a1078..495c603c1a30 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -75,12 +75,12 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
  * we don't really have any PUD/PMD directory physically.
  */
 #if defined(CONFIG_MIPS_HUGE_TLB_SUPPORT) && !defined(CONFIG_PHYS_ADDR_T_64BIT)
-# define __PGD_ORDER	(32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2 + 1)
+# define __PGD_TABLE_ORDER (32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2 + 1)
 #else
-# define __PGD_ORDER	(32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2)
+# define __PGD_TABLE_ORDER (32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2)
 #endif
 
-#define PGD_ORDER	(__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
+#define PGD_TABLE_ORDER	(__PGD_TABLE_ORDER >= 0 ? __PGD_TABLE_ORDER : 0)
 #define PUD_TABLE_ORDER	aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER	aieeee_attempt_to_allocate_pmd
 
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index dbf7e461d360..a259ca4d1272 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -85,35 +85,35 @@
  */
 #ifdef CONFIG_PAGE_SIZE_4KB
 # ifdef CONFIG_MIPS_VA_BITS_48
-#  define PGD_ORDER		0
+#  define PGD_TABLE_ORDER	0
 #  define PUD_TABLE_ORDER	0
 # else
-#  define PGD_ORDER		1
+#  define PGD_TABLE_ORDER	1
 #  define PUD_TABLE_ORDER	aieeee_attempt_to_allocate_pud
 # endif
 #define PMD_TABLE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_8KB
-#define PGD_ORDER		0
+#define PGD_TABLE_ORDER		0
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_16KB
 #ifdef CONFIG_MIPS_VA_BITS_48
-#define PGD_ORDER               1
+#define PGD_TABLE_ORDER		1
 #else
-#define PGD_ORDER               0
+#define PGD_TABLE_ORDER		0
 #endif
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_32KB
-#define PGD_ORDER		0
+#define PGD_TABLE_ORDER		0
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #define PMD_TABLE_ORDER		0
 #endif
 #ifdef CONFIG_PAGE_SIZE_64KB
-#define PGD_ORDER		0
+#define PGD_TABLE_ORDER		0
 #define PUD_TABLE_ORDER		aieeee_attempt_to_allocate_pud
 #ifdef CONFIG_MIPS_VA_BITS_48
 #define PMD_TABLE_ORDER		0
@@ -122,7 +122,7 @@
 #endif
 #endif
 
-#define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
+#define PTRS_PER_PGD	((PAGE_SIZE << PGD_TABLE_ORDER) / sizeof(pgd_t))
 #ifndef __PAGETABLE_PUD_FOLDED
 #define PTRS_PER_PUD	((PAGE_SIZE << PUD_TABLE_ORDER) / sizeof(pud_t))
 #endif
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 0c97f755e256..c4501897b870 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -196,7 +196,6 @@ void output_mm_defines(void)
 #endif
 	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
 	BLANK();
-	DEFINE(_PGD_ORDER, PGD_ORDER);
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
 	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
index 1bfd1b501d82..db17e870bdff 100644
--- a/arch/mips/kvm/mmu.c
+++ b/arch/mips/kvm/mmu.c
@@ -80,7 +80,7 @@ pgd_t *kvm_pgd_alloc(void)
 {
 	pgd_t *ret;
 
-	ret = (pgd_t *)__get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = (pgd_t *)__get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER);
 	if (ret)
 		kvm_pgd_init(ret);
 
diff --git a/arch/mips/mm/pgtable.c b/arch/mips/mm/pgtable.c
index 05560b042d82..3b7590660a04 100644
--- a/arch/mips/mm/pgtable.c
+++ b/arch/mips/mm/pgtable.c
@@ -12,7 +12,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init((unsigned long)ret);
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 6e8e71f12fab..a57519ae96b1 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -818,7 +818,7 @@ void build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
 		 * everything but the lower xuseg addresses goes down
 		 * the module_alloc/vmalloc path.
 		 */
-		uasm_i_dsrl_safe(p, ptr, tmp, PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
+		uasm_i_dsrl_safe(p, ptr, tmp, PGDIR_SHIFT + PGD_TABLE_ORDER + PAGE_SHIFT - 3);
 		uasm_il_bnez(p, r, ptr, label_vmalloc);
 	} else {
 		uasm_il_bltz(p, r, tmp, label_vmalloc);
@@ -1127,7 +1127,7 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
 			UASM_i_SW(p, scratch, scratchpad_offset(0), 0);
 
 		uasm_i_dsrl_safe(p, scratch, tmp,
-				 PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
+				 PGDIR_SHIFT + PGD_TABLE_ORDER + PAGE_SHIFT - 3);
 		uasm_il_bnez(p, r, scratch, label_vmalloc);
 
 		if (pgd_reg == -1) {
@@ -1493,12 +1493,12 @@ static void setup_pw(void)
 #endif
 	pgd_i = PGDIR_SHIFT;  /* 1st level PGD */
 #ifndef __PAGETABLE_PMD_FOLDED
-	pgd_w = PGDIR_SHIFT - PMD_SHIFT + PGD_ORDER;
+	pgd_w = PGDIR_SHIFT - PMD_SHIFT + PGD_TABLE_ORDER;
 
 	pmd_i = PMD_SHIFT;    /* 2nd level PMD */
 	pmd_w = PMD_SHIFT - PAGE_SHIFT;
 #else
-	pgd_w = PGDIR_SHIFT - PAGE_SHIFT + PGD_ORDER;
+	pgd_w = PGDIR_SHIFT - PAGE_SHIFT + PGD_TABLE_ORDER;
 #endif
 
 	pt_i  = PAGE_SHIFT;    /* 3rd level PTE */
@@ -1536,7 +1536,7 @@ static void build_loongson3_tlb_refill_handler(void)
 
 	if (check_for_high_segbits) {
 		uasm_i_dmfc0(&p, K0, C0_BADVADDR);
-		uasm_i_dsrl_safe(&p, K1, K0, PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
+		uasm_i_dsrl_safe(&p, K1, K0, PGDIR_SHIFT + PGD_TABLE_ORDER + PAGE_SHIFT - 3);
 		uasm_il_beqz(&p, &r, K1, label_vmalloc);
 		uasm_i_nop(&p);
 
@@ -2611,7 +2611,7 @@ void build_tlb_refill_handler(void)
 	check_pabits();
 
 #ifdef CONFIG_64BIT
-	check_for_high_segbits = current_cpu_data.vmbits > (PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
+	check_for_high_segbits = current_cpu_data.vmbits > (PGDIR_SHIFT + PGD_TABLE_ORDER + PAGE_SHIFT - 3);
 #endif
 
 	if (cpu_has_3kex) {
-- 
2.34.1


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

* [PATCH 07/14] nios2: drop definition of PTE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (5 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 06/14] mips: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 08/14] nios2: drop definition of PGD_ORDER Mike Rapoport
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PTE.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/nios2/include/asm/pgtable.h | 3 +--
 arch/nios2/mm/init.c             | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h
index 262d0609268c..eaf8f28baa8b 100644
--- a/arch/nios2/include/asm/pgtable.h
+++ b/arch/nios2/include/asm/pgtable.h
@@ -69,10 +69,9 @@ struct mm_struct;
 #define PAGE_COPY MKP(0, 0, 1)
 
 #define PGD_ORDER	0
-#define PTE_ORDER	0
 
 #define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
-#define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+#define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 
 #define USER_PTRS_PER_PGD	\
 	(CONFIG_NIOS2_KERNEL_MMU_REGION_BASE / PGDIR_SIZE)
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c
index 613fcaa5988a..2d6dbf7701f6 100644
--- a/arch/nios2/mm/init.c
+++ b/arch/nios2/mm/init.c
@@ -80,7 +80,7 @@ void __init mmu_init(void)
 
 #define __page_aligned(order) __aligned(PAGE_SIZE << (order))
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER);
-pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);
+pte_t invalid_pte_table[PTRS_PER_PTE] __aligned(PAGE_SIZE);
 static struct page *kuser_page[1];
 
 static int alloc_kuser_page(void)
-- 
2.34.1


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

* [PATCH 08/14] nios2: drop definition of PGD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (6 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 07/14] nios2: drop definition of PTE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 09/14] loongarch: drop definition of PTE_ORDER Mike Rapoport
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PGD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/nios2/include/asm/pgtable.h | 4 +---
 arch/nios2/mm/init.c             | 3 +--
 arch/nios2/mm/pgtable.c          | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h
index eaf8f28baa8b..74af16dafe86 100644
--- a/arch/nios2/include/asm/pgtable.h
+++ b/arch/nios2/include/asm/pgtable.h
@@ -68,9 +68,7 @@ struct mm_struct;
 
 #define PAGE_COPY MKP(0, 0, 1)
 
-#define PGD_ORDER	0
-
-#define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
+#define PTRS_PER_PGD	(PAGE_SIZE / sizeof(pgd_t))
 #define PTRS_PER_PTE	(PAGE_SIZE / sizeof(pte_t))
 
 #define USER_PTRS_PER_PGD	\
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c
index 2d6dbf7701f6..eab65e8ea69c 100644
--- a/arch/nios2/mm/init.c
+++ b/arch/nios2/mm/init.c
@@ -78,8 +78,7 @@ void __init mmu_init(void)
 	flush_tlb_all();
 }
 
-#define __page_aligned(order) __aligned(PAGE_SIZE << (order))
-pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER);
+pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 pte_t invalid_pte_table[PTRS_PER_PTE] __aligned(PAGE_SIZE);
 static struct page *kuser_page[1];
 
diff --git a/arch/nios2/mm/pgtable.c b/arch/nios2/mm/pgtable.c
index 9b587fd592dd..7c76e8a7447a 100644
--- a/arch/nios2/mm/pgtable.c
+++ b/arch/nios2/mm/pgtable.c
@@ -54,7 +54,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = (pgd_t *) __get_free_page(GFP_KERNEL);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init(ret);
-- 
2.34.1


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

* [PATCH 09/14] loongarch: drop definition of PTE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (7 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 08/14] nios2: drop definition of PGD_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:11 ` [PATCH 10/14] loongarch: drop definition of PMD_ORDER Mike Rapoport
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PTE.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/loongarch/include/asm/pgtable.h | 9 ++++-----
 arch/loongarch/kernel/asm-offsets.c  | 1 -
 arch/loongarch/mm/tlbex.S            | 6 +++---
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index d9e86cfa53e2..e0bbfc31fe72 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -24,17 +24,16 @@
 #define PGD_ORDER		0
 #define PUD_ORDER		0
 #define PMD_ORDER		0
-#define PTE_ORDER		0
 
 #if CONFIG_PGTABLE_LEVELS == 2
-#define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
+#define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #elif CONFIG_PGTABLE_LEVELS == 3
-#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
+#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
 #define PGDIR_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
 #elif CONFIG_PGTABLE_LEVELS == 4
-#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
+#define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
 #define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
@@ -55,7 +54,7 @@
 #if CONFIG_PGTABLE_LEVELS > 2
 #define PTRS_PER_PMD	((PAGE_SIZE << PMD_ORDER) >> 3)
 #endif
-#define PTRS_PER_PTE	((PAGE_SIZE << PTE_ORDER) >> 3)
+#define PTRS_PER_PTE	(PAGE_SIZE >> 3)
 
 #define USER_PTRS_PER_PGD       ((TASK_SIZE64 / PGDIR_SIZE)?(TASK_SIZE64 / PGDIR_SIZE):1)
 
diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/asm-offsets.c
index bfb65eb2844f..1a1166a7e61c 100644
--- a/arch/loongarch/kernel/asm-offsets.c
+++ b/arch/loongarch/kernel/asm-offsets.c
@@ -194,7 +194,6 @@ void output_mm_defines(void)
 #ifndef __PAGETABLE_PMD_FOLDED
 	DEFINE(_PMD_ORDER, PMD_ORDER);
 #endif
-	DEFINE(_PTE_ORDER, PTE_ORDER);
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
 	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
diff --git a/arch/loongarch/mm/tlbex.S b/arch/loongarch/mm/tlbex.S
index 7eee40271577..e36c2c07dee3 100644
--- a/arch/loongarch/mm/tlbex.S
+++ b/arch/loongarch/mm/tlbex.S
@@ -83,7 +83,7 @@ vmalloc_done_load:
 	bne	t0, $r0, tlb_huge_update_load
 
 	csrrd	t0, LOONGARCH_CSR_BADV
-	srli.d	t0, t0, (PAGE_SHIFT + PTE_ORDER)
+	srli.d	t0, t0, PAGE_SHIFT
 	andi	t0, t0, (PTRS_PER_PTE - 1)
 	slli.d	t0, t0, _PTE_T_LOG2
 	add.d	t1, ra, t0
@@ -247,7 +247,7 @@ vmalloc_done_store:
 	bne	t0, $r0, tlb_huge_update_store
 
 	csrrd	t0, LOONGARCH_CSR_BADV
-	srli.d	t0, t0, (PAGE_SHIFT + PTE_ORDER)
+	srli.d	t0, t0, PAGE_SHIFT
 	andi	t0, t0, (PTRS_PER_PTE - 1)
 	slli.d	t0, t0, _PTE_T_LOG2
 	add.d	t1, ra, t0
@@ -414,7 +414,7 @@ vmalloc_done_modify:
 	bne	t0, $r0, tlb_huge_update_modify
 
 	csrrd	t0, LOONGARCH_CSR_BADV
-	srli.d	t0, t0, (PAGE_SHIFT + PTE_ORDER)
+	srli.d	t0, t0, PAGE_SHIFT
 	andi	t0, t0, (PTRS_PER_PTE - 1)
 	slli.d	t0, t0, _PTE_T_LOG2
 	add.d	t1, ra, t0
-- 
2.34.1


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

* [PATCH 10/14] loongarch: drop definition of PMD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (8 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 09/14] loongarch: drop definition of PTE_ORDER Mike Rapoport
@ 2022-07-03 14:11 ` Mike Rapoport
  2022-07-03 14:12 ` [PATCH 11/14] loongarch: drop definition of PUD_ORDER Mike Rapoport
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PMD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/loongarch/include/asm/pgalloc.h | 4 ++--
 arch/loongarch/include/asm/pgtable.h | 7 +++----
 arch/loongarch/kernel/asm-offsets.c  | 3 ---
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h
index b0a57b25c131..93e785f46639 100644
--- a/arch/loongarch/include/asm/pgalloc.h
+++ b/arch/loongarch/include/asm/pgalloc.h
@@ -66,12 +66,12 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 	pmd_t *pmd;
 	struct page *pg;
 
-	pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER);
+	pg = alloc_page(GFP_KERNEL_ACCOUNT);
 	if (!pg)
 		return NULL;
 
 	if (!pgtable_pmd_page_ctor(pg)) {
-		__free_pages(pg, PMD_ORDER);
+		__free_page(pg);
 		return NULL;
 	}
 
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index e0bbfc31fe72..f926537d2233 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -23,7 +23,6 @@
 
 #define PGD_ORDER		0
 #define PUD_ORDER		0
-#define PMD_ORDER		0
 
 #if CONFIG_PGTABLE_LEVELS == 2
 #define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
@@ -31,12 +30,12 @@
 #define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
-#define PGDIR_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
+#define PGDIR_SHIFT	(PMD_SHIFT + (PAGE_SHIFT - 3))
 #elif CONFIG_PGTABLE_LEVELS == 4
 #define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #define PMD_SIZE	(1UL << PMD_SHIFT)
 #define PMD_MASK	(~(PMD_SIZE-1))
-#define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
+#define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT - 3))
 #define PUD_SIZE	(1UL << PUD_SHIFT)
 #define PUD_MASK	(~(PUD_SIZE-1))
 #define PGDIR_SHIFT	(PUD_SHIFT + (PAGE_SHIFT + PUD_ORDER - 3))
@@ -52,7 +51,7 @@
 #define PTRS_PER_PUD	((PAGE_SIZE << PUD_ORDER) >> 3)
 #endif
 #if CONFIG_PGTABLE_LEVELS > 2
-#define PTRS_PER_PMD	((PAGE_SIZE << PMD_ORDER) >> 3)
+#define PTRS_PER_PMD	(PAGE_SIZE >> 3)
 #endif
 #define PTRS_PER_PTE	(PAGE_SIZE >> 3)
 
diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/asm-offsets.c
index 1a1166a7e61c..aa4ef42d759f 100644
--- a/arch/loongarch/kernel/asm-offsets.c
+++ b/arch/loongarch/kernel/asm-offsets.c
@@ -191,9 +191,6 @@ void output_mm_defines(void)
 	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
 	BLANK();
 	DEFINE(_PGD_ORDER, PGD_ORDER);
-#ifndef __PAGETABLE_PMD_FOLDED
-	DEFINE(_PMD_ORDER, PMD_ORDER);
-#endif
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
 	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
-- 
2.34.1


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

* [PATCH 11/14] loongarch: drop definition of PUD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (9 preceding siblings ...)
  2022-07-03 14:11 ` [PATCH 10/14] loongarch: drop definition of PMD_ORDER Mike Rapoport
@ 2022-07-03 14:12 ` Mike Rapoport
  2022-07-03 14:12 ` [PATCH 12/14] loongarch: drop definition of PGD_ORDER Mike Rapoport
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PUD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/loongarch/include/asm/pgalloc.h | 2 +-
 arch/loongarch/include/asm/pgtable.h | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h
index 93e785f46639..4bfeb3c9c9ac 100644
--- a/arch/loongarch/include/asm/pgalloc.h
+++ b/arch/loongarch/include/asm/pgalloc.h
@@ -90,7 +90,7 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	pud_t *pud;
 
-	pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_ORDER);
+	pud = (pud_t *) __get_free_page(GFP_KERNEL);
 	if (pud)
 		pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table);
 	return pud;
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index f926537d2233..a97996fefaed 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -22,7 +22,6 @@
 #endif
 
 #define PGD_ORDER		0
-#define PUD_ORDER		0
 
 #if CONFIG_PGTABLE_LEVELS == 2
 #define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
@@ -38,7 +37,7 @@
 #define PUD_SHIFT	(PMD_SHIFT + (PAGE_SHIFT - 3))
 #define PUD_SIZE	(1UL << PUD_SHIFT)
 #define PUD_MASK	(~(PUD_SIZE-1))
-#define PGDIR_SHIFT	(PUD_SHIFT + (PAGE_SHIFT + PUD_ORDER - 3))
+#define PGDIR_SHIFT	(PUD_SHIFT + (PAGE_SHIFT - 3))
 #endif
 
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
@@ -48,7 +47,7 @@
 
 #define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) >> 3)
 #if CONFIG_PGTABLE_LEVELS > 3
-#define PTRS_PER_PUD	((PAGE_SIZE << PUD_ORDER) >> 3)
+#define PTRS_PER_PUD	(PAGE_SIZE >> 3)
 #endif
 #if CONFIG_PGTABLE_LEVELS > 2
 #define PTRS_PER_PMD	(PAGE_SIZE >> 3)
-- 
2.34.1


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

* [PATCH 12/14] loongarch: drop definition of PGD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (10 preceding siblings ...)
  2022-07-03 14:12 ` [PATCH 11/14] loongarch: drop definition of PUD_ORDER Mike Rapoport
@ 2022-07-03 14:12 ` Mike Rapoport
  2022-07-03 20:50   ` Matthew Wilcox
  2022-07-03 14:12 ` [PATCH 13/14] parisc: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PGD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/loongarch/include/asm/pgtable.h | 6 ++----
 arch/loongarch/kernel/asm-offsets.c  | 1 -
 arch/loongarch/mm/pgtable.c          | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index a97996fefaed..e03443abaf7d 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -21,8 +21,6 @@
 #include <asm-generic/pgtable-nop4d.h>
 #endif
 
-#define PGD_ORDER		0
-
 #if CONFIG_PGTABLE_LEVELS == 2
 #define PGDIR_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT - 3))
 #elif CONFIG_PGTABLE_LEVELS == 3
@@ -43,9 +41,9 @@
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE-1))
 
-#define VA_BITS		(PGDIR_SHIFT + (PAGE_SHIFT + PGD_ORDER - 3))
+#define VA_BITS		(PGDIR_SHIFT + (PAGE_SHIFT - 3))
 
-#define PTRS_PER_PGD	((PAGE_SIZE << PGD_ORDER) >> 3)
+#define PTRS_PER_PGD	(PAGE_SIZE >> 3)
 #if CONFIG_PGTABLE_LEVELS > 3
 #define PTRS_PER_PUD	(PAGE_SIZE >> 3)
 #endif
diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/asm-offsets.c
index aa4ef42d759f..72f431a7289d 100644
--- a/arch/loongarch/kernel/asm-offsets.c
+++ b/arch/loongarch/kernel/asm-offsets.c
@@ -190,7 +190,6 @@ void output_mm_defines(void)
 #endif
 	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
 	BLANK();
-	DEFINE(_PGD_ORDER, PGD_ORDER);
 	BLANK();
 	DEFINE(_PMD_SHIFT, PMD_SHIFT);
 	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
diff --git a/arch/loongarch/mm/pgtable.c b/arch/loongarch/mm/pgtable.c
index 0569647152e9..ee179ccd3e3f 100644
--- a/arch/loongarch/mm/pgtable.c
+++ b/arch/loongarch/mm/pgtable.c
@@ -13,7 +13,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = (pgd_t *) __get_free_page(GFP_KERNEL);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init((unsigned long)ret);
-- 
2.34.1


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

* [PATCH 13/14] parisc: Rename PGD_ORDER to PGD_TABLE_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (11 preceding siblings ...)
  2022-07-03 14:12 ` [PATCH 12/14] loongarch: drop definition of PGD_ORDER Mike Rapoport
@ 2022-07-03 14:12 ` Mike Rapoport
  2022-07-03 14:12 ` [PATCH 14/14] xtensa: drop definition of PGD_ORDER Mike Rapoport
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

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

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/parisc/include/asm/pgalloc.h | 6 +++---
 arch/parisc/include/asm/pgtable.h | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
index 54b63374579b..e3e142b1c5c5 100644
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -20,18 +20,18 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *pgd;
 
-	pgd = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	pgd = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER);
 	if (unlikely(pgd == NULL))
 		return NULL;
 
-	memset(pgd, 0, PAGE_SIZE << PGD_ORDER);
+	memset(pgd, 0, PAGE_SIZE << PGD_TABLE_ORDER);
 
 	return pgd;
 }
 
 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 {
-	free_pages((unsigned long)pgd, PGD_ORDER);
+	free_pages((unsigned long)pgd, PGD_TABLE_ORDER);
 }
 
 #if CONFIG_PGTABLE_LEVELS == 3
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 69765a6dbe89..6790b554bdfd 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -118,9 +118,9 @@ extern void __update_cache(pte_t pte);
 
 #if CONFIG_PGTABLE_LEVELS == 3
 #define PMD_TABLE_ORDER	1
-#define PGD_ORDER	0
+#define PGD_TABLE_ORDER	0
 #else
-#define PGD_ORDER	1
+#define PGD_TABLE_ORDER	1
 #endif
 
 /* Definitions for 3rd level (we use PLD here for Page Lower directory
@@ -144,10 +144,10 @@ extern void __update_cache(pte_t pte);
 
 /* Definitions for 1st level */
 #define PGDIR_SHIFT	(PLD_SHIFT + BITS_PER_PTE + BITS_PER_PMD)
-#if (PGDIR_SHIFT + PAGE_SHIFT + PGD_ORDER - BITS_PER_PGD_ENTRY) > BITS_PER_LONG
+#if (PGDIR_SHIFT + PAGE_SHIFT + PGD_TABLE_ORDER - BITS_PER_PGD_ENTRY) > BITS_PER_LONG
 #define BITS_PER_PGD	(BITS_PER_LONG - PGDIR_SHIFT)
 #else
-#define BITS_PER_PGD	(PAGE_SHIFT + PGD_ORDER - BITS_PER_PGD_ENTRY)
+#define BITS_PER_PGD	(PAGE_SHIFT + PGD_TABLE_ORDER - BITS_PER_PGD_ENTRY)
 #endif
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE-1))
-- 
2.34.1


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

* [PATCH 14/14] xtensa: drop definition of PGD_ORDER
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (12 preceding siblings ...)
  2022-07-03 14:12 ` [PATCH 13/14] parisc: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
@ 2022-07-03 14:12 ` Mike Rapoport
  2022-07-03 14:27 ` [PATCH 00/14] arch: make PxD_ORDER generically available Helge Deller
  2022-07-03 21:14   ` Matthew Wilcox (Oracle)
  15 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-03 14:12 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui,
	linux-arch, linux-csky, linux-kernel, linux-mips, linux-mm,
	linux-parisc, linux-xtensa, loongarch

From: Mike Rapoport <rppt@linux.ibm.com>

This is the order of the page table allocation, not the order of a PGD.
Since its always hardwired to 0, simply drop it.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/xtensa/include/asm/pgalloc.h | 2 +-
 arch/xtensa/include/asm/pgtable.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/xtensa/include/asm/pgalloc.h b/arch/xtensa/include/asm/pgalloc.h
index eeb2de3a89e5..7fc0f9126dd3 100644
--- a/arch/xtensa/include/asm/pgalloc.h
+++ b/arch/xtensa/include/asm/pgalloc.h
@@ -29,7 +29,7 @@
 static inline pgd_t*
 pgd_alloc(struct mm_struct *mm)
 {
-	return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER);
+	return (pgd_t*) __get_free_page(GFP_KERNEL | __GFP_ZERO);
 }
 
 static inline void ptes_clear(pte_t *ptep)
diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
index 0a91376131c5..4bd77d2b6715 100644
--- a/arch/xtensa/include/asm/pgtable.h
+++ b/arch/xtensa/include/asm/pgtable.h
@@ -57,7 +57,6 @@
 #define PTRS_PER_PTE		1024
 #define PTRS_PER_PTE_SHIFT	10
 #define PTRS_PER_PGD		1024
-#define PGD_ORDER		0
 #define USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
 #define FIRST_USER_PGD_NR	(FIRST_USER_ADDRESS >> PGDIR_SHIFT)
 
-- 
2.34.1


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

* Re: [PATCH 00/14] arch: make PxD_ORDER generically available
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
                   ` (13 preceding siblings ...)
  2022-07-03 14:12 ` [PATCH 14/14] xtensa: drop definition of PGD_ORDER Mike Rapoport
@ 2022-07-03 14:27 ` Helge Deller
  2022-07-04  0:40   ` Huacai Chen
  2022-07-03 21:14   ` Matthew Wilcox (Oracle)
  15 siblings, 1 reply; 41+ messages in thread
From: Helge Deller @ 2022-07-03 14:27 UTC (permalink / raw)
  To: Mike Rapoport, Andrew Morton
  Cc: Arnd Bergmann, Dinh Nguyen, Guo Ren, Huacai Chen,
	James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui, linux-arch,
	linux-csky, linux-kernel, linux-mips, linux-mm, linux-parisc,
	linux-xtensa, loongarch

On 7/3/22 16:11, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@linux.ibm.com>
>
> Hi,
>
> The question what does PxD_ORDER define raises from time to time and
> there is still a conflict between MIPS and DAX definitions.
>
> Some time ago Matthew Wilcox suggested to use PMD_TABLE_ORDER to define
> the order of page table allocation:
>
> [1] https://lore.kernel.org/linux-arch/YPCJftSTUBEnq2lI@casper.infradead.org/
>
> The parisc patch made it in, but mips didn't.
> Now mips defines from asm/include/pgtable.h were copied to loongarch which
> made it worse.
>
> Let's deal with it once and for all and rename PxD_ORDER defines to
> PxD_TABLE_ORDER or just drop them when the only possible order of page
> table is 0.
>
> I think the best way to merge this via mm tree with acks from arch
> maintainers.

That's fine for me.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge



> Matthew Wilcox (Oracle) (1):
>   mips: Rename PMD_ORDER to PMD_TABLE_ORDER
>
> Mike Rapoport (13):
>   csky: drop definition of PTE_ORDER
>   csky: drop definition of PGD_ORDER
>   mips: Rename PUD_ORDER to PUD_TABLE_ORDER
>   mips: drop definitions of PTE_ORDER
>   mips: Rename PGD_ORDER to PGD_TABLE_ORDER
>   nios2: drop definition of PTE_ORDER
>   nios2: drop definition of PGD_ORDER
>   loongarch: drop definition of PTE_ORDER
>   loongarch: drop definition of PMD_ORDER
>   loongarch: drop definition of PUD_ORDER
>   loongarch: drop definition of PGD_ORDER
>   parisc: Rename PGD_ORDER to PGD_TABLE_ORDER
>   xtensa: drop definition of PGD_ORDER
>
>  arch/csky/include/asm/pgalloc.h      |  2 +-
>  arch/csky/include/asm/pgtable.h      |  6 +--
>  arch/loongarch/include/asm/pgalloc.h |  6 +--
>  arch/loongarch/include/asm/pgtable.h | 27 +++++-------
>  arch/loongarch/kernel/asm-offsets.c  |  5 ---
>  arch/loongarch/mm/pgtable.c          |  2 +-
>  arch/loongarch/mm/tlbex.S            |  6 +--
>  arch/mips/include/asm/pgalloc.h      |  8 ++--
>  arch/mips/include/asm/pgtable-32.h   | 19 ++++-----
>  arch/mips/include/asm/pgtable-64.h   | 61 +++++++++++++---------------
>  arch/mips/kernel/asm-offsets.c       |  5 ---
>  arch/mips/kvm/mmu.c                  |  2 +-
>  arch/mips/mm/pgtable.c               |  2 +-
>  arch/mips/mm/tlbex.c                 | 14 +++----
>  arch/nios2/include/asm/pgtable.h     |  7 +---
>  arch/nios2/mm/init.c                 |  5 +--
>  arch/nios2/mm/pgtable.c              |  2 +-
>  arch/parisc/include/asm/pgalloc.h    |  6 +--
>  arch/parisc/include/asm/pgtable.h    |  8 ++--
>  arch/xtensa/include/asm/pgalloc.h    |  2 +-
>  arch/xtensa/include/asm/pgtable.h    |  1 -
>  21 files changed, 84 insertions(+), 112 deletions(-)
>
>
> base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a


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

* Re: [PATCH 12/14] loongarch: drop definition of PGD_ORDER
  2022-07-03 14:12 ` [PATCH 12/14] loongarch: drop definition of PGD_ORDER Mike Rapoport
@ 2022-07-03 20:50   ` Matthew Wilcox
  2022-07-04  3:57     ` WANG Xuerui
  0 siblings, 1 reply; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-03 20:50 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller,
	Huacai Chen, James E.J. Bottomley, Max Filippov, Mike Rapoport,
	Thomas Bogendoerfer, WANG Xuerui, linux-arch, linux-csky,
	linux-kernel, linux-mips, linux-mm, linux-parisc, linux-xtensa,
	loongarch

On Sun, Jul 03, 2022 at 05:12:01PM +0300, Mike Rapoport wrote:
> +++ b/arch/loongarch/kernel/asm-offsets.c
> @@ -190,7 +190,6 @@ void output_mm_defines(void)
>  #endif
>  	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
>  	BLANK();
> -	DEFINE(_PGD_ORDER, PGD_ORDER);
>  	BLANK();
>  	DEFINE(_PMD_SHIFT, PMD_SHIFT);
>  	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);

Should probably also drop one of these BLANK() lines too?


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

* [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
@ 2022-07-03 21:14   ` Matthew Wilcox (Oracle)
  2022-07-03 14:11 ` [PATCH 02/14] csky: drop definition of PGD_ORDER Mike Rapoport
                     ` (14 subsequent siblings)
  15 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-07-03 21:14 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox (Oracle),
	Arnd Bergmann, Mike Rapoport, Russell King, linux-arm-kernel,
	linux-mm, linux-kernel

This is the number of bits used by a PMD entry, 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 500612d3da2e..d16159ced58f 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_BITS	3
 #else
 #define PG_DIR_SIZE	0x4000
-#define PMD_ORDER	2
+#define PMD_BITS	2
 #endif
 
 	.globl	swapper_pg_dir
@@ -240,7 +240,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_BITS]	@ identity mapping
 	cmp	r5, r6
 	addlo	r5, r5, #1			@ next section
 	blo	1b
@@ -250,7 +250,7 @@ __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_BITS)
 	ldr	r6, =(_end - 1)
 	adr_l	r5, kernel_sec_start		@ _pa(kernel_sec_start)
 #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
@@ -259,8 +259,8 @@ __create_page_tables:
 	str	r8, [r5]			@ Save physical start of kernel (LE)
 #endif
 	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_BITS)
+1:	str	r3, [r0], #1 << PMD_BITS
 	add	r3, r3, #1 << SECTION_SHIFT
 	cmp	r0, r6
 	bls	1b
@@ -280,14 +280,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_BITS)
+	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_BITS]!
 	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_BITS
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_BITS)
 1:	cmp	r0, r6
 	add	r3, r3, #1 << SECTION_SHIFT
-	strls	r3, [r0], #1 << PMD_ORDER
+	strls	r3, [r0], #1 << PMD_BITS
 	bls	1b
 #endif
 
@@ -297,10 +297,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_BITS)
 	addne	r3, r3, r4
 	orrne	r6, r7, r0, lsl #SECTION_SHIFT
-	strne	r6, [r3], #1 << PMD_ORDER
+	strne	r6, [r3], #1 << PMD_BITS
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
 
@@ -319,7 +319,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_BITS
 
 	add	r0, r4, r3
 	mov	r3, r7, lsr #SECTION_SHIFT
@@ -349,7 +349,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_BITS)
 	orr	r3, r7, #0x7c000000
 	str	r3, [r0]
 #endif
@@ -359,10 +359,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_BITS)
 	orr	r3, r7, #0x02000000
 	str	r3, [r0]
-	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_BITS)
 	str	r3, [r0]
 #endif
 #endif
-- 
2.35.1


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

* [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-03 21:14   ` Matthew Wilcox (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox (Oracle) @ 2022-07-03 21:14 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox (Oracle),
	Arnd Bergmann, Mike Rapoport, Russell King, linux-arm-kernel,
	linux-mm, linux-kernel

This is the number of bits used by a PMD entry, 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 500612d3da2e..d16159ced58f 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_BITS	3
 #else
 #define PG_DIR_SIZE	0x4000
-#define PMD_ORDER	2
+#define PMD_BITS	2
 #endif
 
 	.globl	swapper_pg_dir
@@ -240,7 +240,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_BITS]	@ identity mapping
 	cmp	r5, r6
 	addlo	r5, r5, #1			@ next section
 	blo	1b
@@ -250,7 +250,7 @@ __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_BITS)
 	ldr	r6, =(_end - 1)
 	adr_l	r5, kernel_sec_start		@ _pa(kernel_sec_start)
 #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
@@ -259,8 +259,8 @@ __create_page_tables:
 	str	r8, [r5]			@ Save physical start of kernel (LE)
 #endif
 	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_BITS)
+1:	str	r3, [r0], #1 << PMD_BITS
 	add	r3, r3, #1 << SECTION_SHIFT
 	cmp	r0, r6
 	bls	1b
@@ -280,14 +280,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_BITS)
+	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_BITS]!
 	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_BITS
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_BITS)
 1:	cmp	r0, r6
 	add	r3, r3, #1 << SECTION_SHIFT
-	strls	r3, [r0], #1 << PMD_ORDER
+	strls	r3, [r0], #1 << PMD_BITS
 	bls	1b
 #endif
 
@@ -297,10 +297,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_BITS)
 	addne	r3, r3, r4
 	orrne	r6, r7, r0, lsl #SECTION_SHIFT
-	strne	r6, [r3], #1 << PMD_ORDER
+	strne	r6, [r3], #1 << PMD_BITS
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
 
@@ -319,7 +319,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_BITS
 
 	add	r0, r4, r3
 	mov	r3, r7, lsr #SECTION_SHIFT
@@ -349,7 +349,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_BITS)
 	orr	r3, r7, #0x7c000000
 	str	r3, [r0]
 #endif
@@ -359,10 +359,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_BITS)
 	orr	r3, r7, #0x02000000
 	str	r3, [r0]
-	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_BITS)
 	str	r3, [r0]
 #endif
 #endif
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-03 21:14   ` Matthew Wilcox (Oracle)
@ 2022-07-03 21:16     ` Russell King (Oracle)
  -1 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-03 21:16 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> This is the number of bits used by a PMD entry, not the order of a PMD.

No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
This is even more confusing.

-- 
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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-03 21:16     ` Russell King (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-03 21:16 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> This is the number of bits used by a PMD entry, not the order of a PMD.

No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
This is even more confusing.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-03 21:16     ` Russell King (Oracle)
@ 2022-07-03 21:54       ` Matthew Wilcox
  -1 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-03 21:54 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > This is the number of bits used by a PMD entry, not the order of a PMD.
> 
> No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> This is even more confusing.

Well, what is it then?  The order of something is PAGE_SIZE << n, and
that doesn't seem to be what this is.  Happy to call it whatever you
want to call it.

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-03 21:54       ` Matthew Wilcox
  0 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-03 21:54 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > This is the number of bits used by a PMD entry, not the order of a PMD.
> 
> No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> This is even more confusing.

Well, what is it then?  The order of something is PAGE_SIZE << n, and
that doesn't seem to be what this is.  Happy to call it whatever you
want to call it.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 00/14] arch: make PxD_ORDER generically available
  2022-07-03 14:27 ` [PATCH 00/14] arch: make PxD_ORDER generically available Helge Deller
@ 2022-07-04  0:40   ` Huacai Chen
  2022-07-04  1:45     ` Guo Ren
  0 siblings, 1 reply; 41+ messages in thread
From: Huacai Chen @ 2022-07-04  0:40 UTC (permalink / raw)
  To: Helge Deller
  Cc: Mike Rapoport, Andrew Morton, Arnd Bergmann, Dinh Nguyen,
	Guo Ren, James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui, linux-arch,
	linux-csky, LKML, open list:MIPS, Linux-MM, linux-parisc,
	linux-xtensa, loongarch

Acked-by: Huacai Chen <chenhuacai@kernel.org> # LoongArch

On Sun, Jul 3, 2022 at 10:28 PM Helge Deller <deller@gmx.de> wrote:
>
> On 7/3/22 16:11, Mike Rapoport wrote:
> > From: Mike Rapoport <rppt@linux.ibm.com>
> >
> > Hi,
> >
> > The question what does PxD_ORDER define raises from time to time and
> > there is still a conflict between MIPS and DAX definitions.
> >
> > Some time ago Matthew Wilcox suggested to use PMD_TABLE_ORDER to define
> > the order of page table allocation:
> >
> > [1] https://lore.kernel.org/linux-arch/YPCJftSTUBEnq2lI@casper.infradead.org/
> >
> > The parisc patch made it in, but mips didn't.
> > Now mips defines from asm/include/pgtable.h were copied to loongarch which
> > made it worse.
> >
> > Let's deal with it once and for all and rename PxD_ORDER defines to
> > PxD_TABLE_ORDER or just drop them when the only possible order of page
> > table is 0.
> >
> > I think the best way to merge this via mm tree with acks from arch
> > maintainers.
>
> That's fine for me.
>
> Acked-by: Helge Deller <deller@gmx.de> # parisc
>
> Thanks!
> Helge
>
>
>
> > Matthew Wilcox (Oracle) (1):
> >   mips: Rename PMD_ORDER to PMD_TABLE_ORDER
> >
> > Mike Rapoport (13):
> >   csky: drop definition of PTE_ORDER
> >   csky: drop definition of PGD_ORDER
> >   mips: Rename PUD_ORDER to PUD_TABLE_ORDER
> >   mips: drop definitions of PTE_ORDER
> >   mips: Rename PGD_ORDER to PGD_TABLE_ORDER
> >   nios2: drop definition of PTE_ORDER
> >   nios2: drop definition of PGD_ORDER
> >   loongarch: drop definition of PTE_ORDER
> >   loongarch: drop definition of PMD_ORDER
> >   loongarch: drop definition of PUD_ORDER
> >   loongarch: drop definition of PGD_ORDER
> >   parisc: Rename PGD_ORDER to PGD_TABLE_ORDER
> >   xtensa: drop definition of PGD_ORDER
> >
> >  arch/csky/include/asm/pgalloc.h      |  2 +-
> >  arch/csky/include/asm/pgtable.h      |  6 +--
> >  arch/loongarch/include/asm/pgalloc.h |  6 +--
> >  arch/loongarch/include/asm/pgtable.h | 27 +++++-------
> >  arch/loongarch/kernel/asm-offsets.c  |  5 ---
> >  arch/loongarch/mm/pgtable.c          |  2 +-
> >  arch/loongarch/mm/tlbex.S            |  6 +--
> >  arch/mips/include/asm/pgalloc.h      |  8 ++--
> >  arch/mips/include/asm/pgtable-32.h   | 19 ++++-----
> >  arch/mips/include/asm/pgtable-64.h   | 61 +++++++++++++---------------
> >  arch/mips/kernel/asm-offsets.c       |  5 ---
> >  arch/mips/kvm/mmu.c                  |  2 +-
> >  arch/mips/mm/pgtable.c               |  2 +-
> >  arch/mips/mm/tlbex.c                 | 14 +++----
> >  arch/nios2/include/asm/pgtable.h     |  7 +---
> >  arch/nios2/mm/init.c                 |  5 +--
> >  arch/nios2/mm/pgtable.c              |  2 +-
> >  arch/parisc/include/asm/pgalloc.h    |  6 +--
> >  arch/parisc/include/asm/pgtable.h    |  8 ++--
> >  arch/xtensa/include/asm/pgalloc.h    |  2 +-
> >  arch/xtensa/include/asm/pgtable.h    |  1 -
> >  21 files changed, 84 insertions(+), 112 deletions(-)
> >
> >
> > base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a
>

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

* Re: [PATCH 00/14] arch: make PxD_ORDER generically available
  2022-07-04  0:40   ` Huacai Chen
@ 2022-07-04  1:45     ` Guo Ren
  0 siblings, 0 replies; 41+ messages in thread
From: Guo Ren @ 2022-07-04  1:45 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Helge Deller, Mike Rapoport, Andrew Morton, Arnd Bergmann,
	Dinh Nguyen, James E.J. Bottomley, Matthew Wilcox, Max Filippov,
	Mike Rapoport, Thomas Bogendoerfer, WANG Xuerui, linux-arch,
	linux-csky, LKML, open list:MIPS, Linux-MM, Parisc List,
	open list:TENSILICA XTENSA PORT (xtensa),
	loongarch

For csky part.

Acked-by: Guo Ren <guoren@kernel.org>

On Mon, Jul 4, 2022 at 8:40 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Acked-by: Huacai Chen <chenhuacai@kernel.org> # LoongArch
>
> On Sun, Jul 3, 2022 at 10:28 PM Helge Deller <deller@gmx.de> wrote:
> >
> > On 7/3/22 16:11, Mike Rapoport wrote:
> > > From: Mike Rapoport <rppt@linux.ibm.com>
> > >
> > > Hi,
> > >
> > > The question what does PxD_ORDER define raises from time to time and
> > > there is still a conflict between MIPS and DAX definitions.
> > >
> > > Some time ago Matthew Wilcox suggested to use PMD_TABLE_ORDER to define
> > > the order of page table allocation:
> > >
> > > [1] https://lore.kernel.org/linux-arch/YPCJftSTUBEnq2lI@casper.infradead.org/
> > >
> > > The parisc patch made it in, but mips didn't.
> > > Now mips defines from asm/include/pgtable.h were copied to loongarch which
> > > made it worse.
> > >
> > > Let's deal with it once and for all and rename PxD_ORDER defines to
> > > PxD_TABLE_ORDER or just drop them when the only possible order of page
> > > table is 0.
> > >
> > > I think the best way to merge this via mm tree with acks from arch
> > > maintainers.
> >
> > That's fine for me.
> >
> > Acked-by: Helge Deller <deller@gmx.de> # parisc
> >
> > Thanks!
> > Helge
> >
> >
> >
> > > Matthew Wilcox (Oracle) (1):
> > >   mips: Rename PMD_ORDER to PMD_TABLE_ORDER
> > >
> > > Mike Rapoport (13):
> > >   csky: drop definition of PTE_ORDER
> > >   csky: drop definition of PGD_ORDER
> > >   mips: Rename PUD_ORDER to PUD_TABLE_ORDER
> > >   mips: drop definitions of PTE_ORDER
> > >   mips: Rename PGD_ORDER to PGD_TABLE_ORDER
> > >   nios2: drop definition of PTE_ORDER
> > >   nios2: drop definition of PGD_ORDER
> > >   loongarch: drop definition of PTE_ORDER
> > >   loongarch: drop definition of PMD_ORDER
> > >   loongarch: drop definition of PUD_ORDER
> > >   loongarch: drop definition of PGD_ORDER
> > >   parisc: Rename PGD_ORDER to PGD_TABLE_ORDER
> > >   xtensa: drop definition of PGD_ORDER
> > >
> > >  arch/csky/include/asm/pgalloc.h      |  2 +-
> > >  arch/csky/include/asm/pgtable.h      |  6 +--
> > >  arch/loongarch/include/asm/pgalloc.h |  6 +--
> > >  arch/loongarch/include/asm/pgtable.h | 27 +++++-------
> > >  arch/loongarch/kernel/asm-offsets.c  |  5 ---
> > >  arch/loongarch/mm/pgtable.c          |  2 +-
> > >  arch/loongarch/mm/tlbex.S            |  6 +--
> > >  arch/mips/include/asm/pgalloc.h      |  8 ++--
> > >  arch/mips/include/asm/pgtable-32.h   | 19 ++++-----
> > >  arch/mips/include/asm/pgtable-64.h   | 61 +++++++++++++---------------
> > >  arch/mips/kernel/asm-offsets.c       |  5 ---
> > >  arch/mips/kvm/mmu.c                  |  2 +-
> > >  arch/mips/mm/pgtable.c               |  2 +-
> > >  arch/mips/mm/tlbex.c                 | 14 +++----
> > >  arch/nios2/include/asm/pgtable.h     |  7 +---
> > >  arch/nios2/mm/init.c                 |  5 +--
> > >  arch/nios2/mm/pgtable.c              |  2 +-
> > >  arch/parisc/include/asm/pgalloc.h    |  6 +--
> > >  arch/parisc/include/asm/pgtable.h    |  8 ++--
> > >  arch/xtensa/include/asm/pgalloc.h    |  2 +-
> > >  arch/xtensa/include/asm/pgtable.h    |  1 -
> > >  21 files changed, 84 insertions(+), 112 deletions(-)
> > >
> > >
> > > base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a
> >



-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

* Re: [PATCH 12/14] loongarch: drop definition of PGD_ORDER
  2022-07-03 20:50   ` Matthew Wilcox
@ 2022-07-04  3:57     ` WANG Xuerui
  2022-07-04  6:37       ` Mike Rapoport
  0 siblings, 1 reply; 41+ messages in thread
From: WANG Xuerui @ 2022-07-04  3:57 UTC (permalink / raw)
  To: Matthew Wilcox, Mike Rapoport
  Cc: Andrew Morton, Arnd Bergmann, Dinh Nguyen, Guo Ren, Helge Deller,
	Huacai Chen, James E.J. Bottomley, Max Filippov, Mike Rapoport,
	Thomas Bogendoerfer, WANG Xuerui, linux-arch, linux-csky,
	linux-kernel, linux-mips, linux-mm, linux-parisc, linux-xtensa,
	loongarch


On 2022/7/4 04:50, Matthew Wilcox wrote:
> On Sun, Jul 03, 2022 at 05:12:01PM +0300, Mike Rapoport wrote:
>> +++ b/arch/loongarch/kernel/asm-offsets.c
>> @@ -190,7 +190,6 @@ void output_mm_defines(void)
>>   #endif
>>   	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
>>   	BLANK();
>> -	DEFINE(_PGD_ORDER, PGD_ORDER);
>>   	BLANK();
>>   	DEFINE(_PMD_SHIFT, PMD_SHIFT);
>>   	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
> Should probably also drop one of these BLANK() lines too?
>
Agreed; IMO the blank lines can and should be removed because the 
surrounding lines are also mm definitions.

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-03 21:54       ` Matthew Wilcox
@ 2022-07-04  4:32         ` Russell King (Oracle)
  -1 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04  4:32 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > 
> > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > This is even more confusing.
> 
> Well, what is it then?  The order of something is PAGE_SIZE << n, and
> that doesn't seem to be what this is.

Where is it defined that "order" means "PAGE_SIZE << n" ?

"order" here is "order of magnitude" and in this case, it is 2^n, just
like order of magnitude in base 10 is 10^n. So strictly, the usage
here is completely correct, but if you describe "order" as "PAGE_SIZE <<
n" that is no longer an order of magnitude, because it doesn't increase
in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).

Now, if you're trying to tell me that Linux has decided to define
"order" to be something non-standard, I'll accept that, but then we
shouldn't be renaming stuff that is using it in a standard way.

-- 
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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04  4:32         ` Russell King (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04  4:32 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > 
> > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > This is even more confusing.
> 
> Well, what is it then?  The order of something is PAGE_SIZE << n, and
> that doesn't seem to be what this is.

Where is it defined that "order" means "PAGE_SIZE << n" ?

"order" here is "order of magnitude" and in this case, it is 2^n, just
like order of magnitude in base 10 is 10^n. So strictly, the usage
here is completely correct, but if you describe "order" as "PAGE_SIZE <<
n" that is no longer an order of magnitude, because it doesn't increase
in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).

Now, if you're trying to tell me that Linux has decided to define
"order" to be something non-standard, I'll accept that, but then we
shouldn't be renaming stuff that is using it in a standard way.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04  4:32         ` Russell King (Oracle)
@ 2022-07-04  6:26           ` Mike Rapoport
  -1 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-04  6:26 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Matthew Wilcox, Andrew Morton, Arnd Bergmann, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > 
> > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > This is even more confusing.
> > 
> > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > that doesn't seem to be what this is.
> 
> Where is it defined that "order" means "PAGE_SIZE << n" ?
> 
> "order" here is "order of magnitude" and in this case, it is 2^n, just
> like order of magnitude in base 10 is 10^n. So strictly, the usage
> here is completely correct, but if you describe "order" as "PAGE_SIZE <<
> n" that is no longer an order of magnitude, because it doesn't increase
> in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).

I'd go with PMD_ENTRY_ORDER as Russell suggested last year.

From 6389dfb2e5ae5b040ca1c8f07a071d8da2873b13 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <rppt@linux.ibm.com>
Date: Mon, 4 Jul 2022 09:17:40 +0300
Subject: [PATCH] ARM: head.S: rename PMD_ORDER to PMD_ENTRY_ORDER

PMD_ORDER denotes order of magnitude for a PMD entry, i.e PMD entry
size is 2 ^ PMD_ORDER.

Rename PMD_ORDER to PMD_ENTRY_ORDER to allow a generic definition of
PMD_ORDER as order of a PMD allocation: (PMD_SHIFT - PAGE_SHIFT).

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 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 500612d3da2e..29e2900178a1 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_ENTRY_ORDER	3	/* PMD entry size is 2^PMD_ENTRY_ORDER */
 #else
 #define PG_DIR_SIZE	0x4000
-#define PMD_ORDER	2
+#define PMD_ENTRY_ORDER	2
 #endif
 
 	.globl	swapper_pg_dir
@@ -240,7 +240,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_ENTRY_ORDER]	@ identity mapping
 	cmp	r5, r6
 	addlo	r5, r5, #1			@ next section
 	blo	1b
@@ -250,7 +250,7 @@ __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_ENTRY_ORDER)
 	ldr	r6, =(_end - 1)
 	adr_l	r5, kernel_sec_start		@ _pa(kernel_sec_start)
 #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
@@ -259,8 +259,8 @@ __create_page_tables:
 	str	r8, [r5]			@ Save physical start of kernel (LE)
 #endif
 	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_ENTRY_ORDER)
+1:	str	r3, [r0], #1 << PMD_ENTRY_ORDER
 	add	r3, r3, #1 << SECTION_SHIFT
 	cmp	r0, r6
 	bls	1b
@@ -280,14 +280,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_ENTRY_ORDER)
+	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ENTRY_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_ENTRY_ORDER
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ENTRY_ORDER)
 1:	cmp	r0, r6
 	add	r3, r3, #1 << SECTION_SHIFT
-	strls	r3, [r0], #1 << PMD_ORDER
+	strls	r3, [r0], #1 << PMD_ENTRY_ORDER
 	bls	1b
 #endif
 
@@ -297,10 +297,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_ENTRY_ORDER)
 	addne	r3, r3, r4
 	orrne	r6, r7, r0, lsl #SECTION_SHIFT
-	strne	r6, [r3], #1 << PMD_ORDER
+	strne	r6, [r3], #1 << PMD_ENTRY_ORDER
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
 
@@ -319,7 +319,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_ENTRY_ORDER
 
 	add	r0, r4, r3
 	mov	r3, r7, lsr #SECTION_SHIFT
@@ -349,7 +349,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_ENTRY_ORDER)
 	orr	r3, r7, #0x7c000000
 	str	r3, [r0]
 #endif
@@ -359,10 +359,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_ENTRY_ORDER)
 	orr	r3, r7, #0x02000000
 	str	r3, [r0]
-	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ENTRY_ORDER)
 	str	r3, [r0]
 #endif
 #endif
-- 
2.34.1


-- 
Sincerely yours,
Mike.

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04  6:26           ` Mike Rapoport
  0 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-04  6:26 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Matthew Wilcox, Andrew Morton, Arnd Bergmann, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > 
> > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > This is even more confusing.
> > 
> > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > that doesn't seem to be what this is.
> 
> Where is it defined that "order" means "PAGE_SIZE << n" ?
> 
> "order" here is "order of magnitude" and in this case, it is 2^n, just
> like order of magnitude in base 10 is 10^n. So strictly, the usage
> here is completely correct, but if you describe "order" as "PAGE_SIZE <<
> n" that is no longer an order of magnitude, because it doesn't increase
> in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).

I'd go with PMD_ENTRY_ORDER as Russell suggested last year.

From 6389dfb2e5ae5b040ca1c8f07a071d8da2873b13 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <rppt@linux.ibm.com>
Date: Mon, 4 Jul 2022 09:17:40 +0300
Subject: [PATCH] ARM: head.S: rename PMD_ORDER to PMD_ENTRY_ORDER

PMD_ORDER denotes order of magnitude for a PMD entry, i.e PMD entry
size is 2 ^ PMD_ORDER.

Rename PMD_ORDER to PMD_ENTRY_ORDER to allow a generic definition of
PMD_ORDER as order of a PMD allocation: (PMD_SHIFT - PAGE_SHIFT).

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 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 500612d3da2e..29e2900178a1 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_ENTRY_ORDER	3	/* PMD entry size is 2^PMD_ENTRY_ORDER */
 #else
 #define PG_DIR_SIZE	0x4000
-#define PMD_ORDER	2
+#define PMD_ENTRY_ORDER	2
 #endif
 
 	.globl	swapper_pg_dir
@@ -240,7 +240,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_ENTRY_ORDER]	@ identity mapping
 	cmp	r5, r6
 	addlo	r5, r5, #1			@ next section
 	blo	1b
@@ -250,7 +250,7 @@ __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_ENTRY_ORDER)
 	ldr	r6, =(_end - 1)
 	adr_l	r5, kernel_sec_start		@ _pa(kernel_sec_start)
 #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
@@ -259,8 +259,8 @@ __create_page_tables:
 	str	r8, [r5]			@ Save physical start of kernel (LE)
 #endif
 	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_ENTRY_ORDER)
+1:	str	r3, [r0], #1 << PMD_ENTRY_ORDER
 	add	r3, r3, #1 << SECTION_SHIFT
 	cmp	r0, r6
 	bls	1b
@@ -280,14 +280,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_ENTRY_ORDER)
+	str	r3, [r0, #((XIP_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ENTRY_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_ENTRY_ORDER
+	add	r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ENTRY_ORDER)
 1:	cmp	r0, r6
 	add	r3, r3, #1 << SECTION_SHIFT
-	strls	r3, [r0], #1 << PMD_ORDER
+	strls	r3, [r0], #1 << PMD_ENTRY_ORDER
 	bls	1b
 #endif
 
@@ -297,10 +297,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_ENTRY_ORDER)
 	addne	r3, r3, r4
 	orrne	r6, r7, r0, lsl #SECTION_SHIFT
-	strne	r6, [r3], #1 << PMD_ORDER
+	strne	r6, [r3], #1 << PMD_ENTRY_ORDER
 	addne	r6, r6, #1 << SECTION_SHIFT
 	strne	r6, [r3]
 
@@ -319,7 +319,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_ENTRY_ORDER
 
 	add	r0, r4, r3
 	mov	r3, r7, lsr #SECTION_SHIFT
@@ -349,7 +349,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_ENTRY_ORDER)
 	orr	r3, r7, #0x7c000000
 	str	r3, [r0]
 #endif
@@ -359,10 +359,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_ENTRY_ORDER)
 	orr	r3, r7, #0x02000000
 	str	r3, [r0]
-	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER)
+	add	r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ENTRY_ORDER)
 	str	r3, [r0]
 #endif
 #endif
-- 
2.34.1


-- 
Sincerely yours,
Mike.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 12/14] loongarch: drop definition of PGD_ORDER
  2022-07-04  3:57     ` WANG Xuerui
@ 2022-07-04  6:37       ` Mike Rapoport
  0 siblings, 0 replies; 41+ messages in thread
From: Mike Rapoport @ 2022-07-04  6:37 UTC (permalink / raw)
  To: WANG Xuerui
  Cc: Matthew Wilcox, Andrew Morton, Arnd Bergmann, Dinh Nguyen,
	Guo Ren, Helge Deller, Huacai Chen, James E.J. Bottomley,
	Max Filippov, Mike Rapoport, Thomas Bogendoerfer, linux-arch,
	linux-csky, linux-kernel, linux-mips, linux-mm, linux-parisc,
	linux-xtensa, loongarch

On Mon, Jul 04, 2022 at 11:57:28AM +0800, WANG Xuerui wrote:
> 
> On 2022/7/4 04:50, Matthew Wilcox wrote:
> > On Sun, Jul 03, 2022 at 05:12:01PM +0300, Mike Rapoport wrote:
> > > +++ b/arch/loongarch/kernel/asm-offsets.c
> > > @@ -190,7 +190,6 @@ void output_mm_defines(void)
> > >   #endif
> > >   	DEFINE(_PTE_T_LOG2, PTE_T_LOG2);
> > >   	BLANK();
> > > -	DEFINE(_PGD_ORDER, PGD_ORDER);
> > >   	BLANK();
> > >   	DEFINE(_PMD_SHIFT, PMD_SHIFT);
> > >   	DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT);
> > Should probably also drop one of these BLANK() lines too?
> > 
> Agreed; IMO the blank lines can and should be removed because the
> surrounding lines are also mm definitions.

They are mm definitions, but still they are separated by blanks to have
nice grouping in the generated asm-offsets.h.

I suspect that there are more unused definitions in asm-offsets.c, worth
taking a look.

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04  4:32         ` Russell King (Oracle)
@ 2022-07-04 10:48           ` Matthew Wilcox
  -1 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-04 10:48 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > 
> > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > This is even more confusing.
> > 
> > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > that doesn't seem to be what this is.
> 
> Where is it defined that "order" means "PAGE_SIZE << n" ?

include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size

> "order" here is "order of magnitude" and in this case, it is 2^n, just
> like order of magnitude in base 10 is 10^n. So strictly, the usage
> here is completely correct, but if you describe "order" as "PAGE_SIZE <<
> n" that is no longer an order of magnitude, because it doesn't increase
> in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).
> 
> Now, if you're trying to tell me that Linux has decided to define
> "order" to be something non-standard, I'll accept that, but then we
> shouldn't be renaming stuff that is using it in a standard way.
> 
> -- 
> 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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04 10:48           ` Matthew Wilcox
  0 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-04 10:48 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > 
> > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > This is even more confusing.
> > 
> > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > that doesn't seem to be what this is.
> 
> Where is it defined that "order" means "PAGE_SIZE << n" ?

include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size

> "order" here is "order of magnitude" and in this case, it is 2^n, just
> like order of magnitude in base 10 is 10^n. So strictly, the usage
> here is completely correct, but if you describe "order" as "PAGE_SIZE <<
> n" that is no longer an order of magnitude, because it doesn't increase
> in an order of magnitude (iow, n = 2 isn't PAGE_SIZE * PAGE_SIZE).
> 
> Now, if you're trying to tell me that Linux has decided to define
> "order" to be something non-standard, I'll accept that, but then we
> shouldn't be renaming stuff that is using it in a standard way.
> 
> -- 
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04 10:48           ` Matthew Wilcox
@ 2022-07-04 11:32             ` Russell King (Oracle)
  -1 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 11:32 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > 
> > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > This is even more confusing.
> > > 
> > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > that doesn't seem to be what this is.
> > 
> > Where is it defined that "order" means "PAGE_SIZE << n" ?
> 
> include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size

I really don't care - "order" is something that is a standard term,
and is entirely appropriate in its use in this case. The fact is,
this use conforms to the standard term usage, not some made up
Linux whim.

-- 
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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04 11:32             ` Russell King (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 11:32 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > 
> > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > This is even more confusing.
> > > 
> > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > that doesn't seem to be what this is.
> > 
> > Where is it defined that "order" means "PAGE_SIZE << n" ?
> 
> include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size

I really don't care - "order" is something that is a standard term,
and is entirely appropriate in its use in this case. The fact is,
this use conforms to the standard term usage, not some made up
Linux whim.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04  6:26           ` Mike Rapoport
@ 2022-07-04 11:37             ` Russell King (Oracle)
  -1 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 11:37 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Matthew Wilcox, Andrew Morton, Arnd Bergmann, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 09:26:22AM +0300, Mike Rapoport wrote:
> I'd go with PMD_ENTRY_ORDER as Russell suggested last year.
> 
> From 6389dfb2e5ae5b040ca1c8f07a071d8da2873b13 Mon Sep 17 00:00:00 2001
> From: Mike Rapoport <rppt@linux.ibm.com>
> Date: Mon, 4 Jul 2022 09:17:40 +0300
> Subject: [PATCH] ARM: head.S: rename PMD_ORDER to PMD_ENTRY_ORDER
> 
> PMD_ORDER denotes order of magnitude for a PMD entry, i.e PMD entry
> size is 2 ^ PMD_ORDER.
> 
> Rename PMD_ORDER to PMD_ENTRY_ORDER to allow a generic definition of
> PMD_ORDER as order of a PMD allocation: (PMD_SHIFT - PAGE_SHIFT).
> 
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>

Yes, absolutely.

Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

I really don't buy the argument that we should not be using "order" here
and we need to make up some other random idiotic term just because Linux
uses "order" *elsewhere* for PAGE_SIZE * 2^n. The Linux kernel doesn't
get to redefine standard terms, and certainly doesn't get to demand that
one has to make up another name for a standard term because it conflicts
with some other usage of that term that's non-standard.

-- 
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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04 11:37             ` Russell King (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 11:37 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Matthew Wilcox, Andrew Morton, Arnd Bergmann, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 09:26:22AM +0300, Mike Rapoport wrote:
> I'd go with PMD_ENTRY_ORDER as Russell suggested last year.
> 
> From 6389dfb2e5ae5b040ca1c8f07a071d8da2873b13 Mon Sep 17 00:00:00 2001
> From: Mike Rapoport <rppt@linux.ibm.com>
> Date: Mon, 4 Jul 2022 09:17:40 +0300
> Subject: [PATCH] ARM: head.S: rename PMD_ORDER to PMD_ENTRY_ORDER
> 
> PMD_ORDER denotes order of magnitude for a PMD entry, i.e PMD entry
> size is 2 ^ PMD_ORDER.
> 
> Rename PMD_ORDER to PMD_ENTRY_ORDER to allow a generic definition of
> PMD_ORDER as order of a PMD allocation: (PMD_SHIFT - PAGE_SHIFT).
> 
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>

Yes, absolutely.

Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

I really don't buy the argument that we should not be using "order" here
and we need to make up some other random idiotic term just because Linux
uses "order" *elsewhere* for PAGE_SIZE * 2^n. The Linux kernel doesn't
get to redefine standard terms, and certainly doesn't get to demand that
one has to make up another name for a standard term because it conflicts
with some other usage of that term that's non-standard.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04 11:32             ` Russell King (Oracle)
@ 2022-07-04 14:28               ` Matthew Wilcox
  -1 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-04 14:28 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 12:32:20PM +0100, Russell King (Oracle) wrote:
> On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> > On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > > 
> > > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > > This is even more confusing.
> > > > 
> > > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > > that doesn't seem to be what this is.
> > > 
> > > Where is it defined that "order" means "PAGE_SIZE << n" ?
> > 
> > include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size
> 
> I really don't care - "order" is something that is a standard term,

The word "order" has many different uses, just in mathematics alone (to
say nothing of its uses in biology, business, the military, religion,
or signal processing).

https://en.wikipedia.org/wiki/Order_(mathematics)

> and is entirely appropriate in its use in this case. The fact is,
> this use conforms to the standard term usage, not some made up
> Linux whim.

At the point where you're talking about PMD order, you're in the realm
of memory management, and using terms to mean something different from
their normal meaning within mm is only going to lead to confusion.

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04 14:28               ` Matthew Wilcox
  0 siblings, 0 replies; 41+ messages in thread
From: Matthew Wilcox @ 2022-07-04 14:28 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 12:32:20PM +0100, Russell King (Oracle) wrote:
> On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> > On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > > 
> > > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > > This is even more confusing.
> > > > 
> > > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > > that doesn't seem to be what this is.
> > > 
> > > Where is it defined that "order" means "PAGE_SIZE << n" ?
> > 
> > include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size
> 
> I really don't care - "order" is something that is a standard term,

The word "order" has many different uses, just in mathematics alone (to
say nothing of its uses in biology, business, the military, religion,
or signal processing).

https://en.wikipedia.org/wiki/Order_(mathematics)

> and is entirely appropriate in its use in this case. The fact is,
> this use conforms to the standard term usage, not some made up
> Linux whim.

At the point where you're talking about PMD order, you're in the realm
of memory management, and using terms to mean something different from
their normal meaning within mm is only going to lead to confusion.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
  2022-07-04 14:28               ` Matthew Wilcox
@ 2022-07-04 17:22                 ` Russell King (Oracle)
  -1 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 17:22 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 03:28:07PM +0100, Matthew Wilcox wrote:
> On Mon, Jul 04, 2022 at 12:32:20PM +0100, Russell King (Oracle) wrote:
> > On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> > > On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > > > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > > > 
> > > > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > > > This is even more confusing.
> > > > > 
> > > > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > > > that doesn't seem to be what this is.
> > > > 
> > > > Where is it defined that "order" means "PAGE_SIZE << n" ?
> > > 
> > > include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size
> > 
> > I really don't care - "order" is something that is a standard term,
> 
> The word "order" has many different uses, just in mathematics alone (to
> say nothing of its uses in biology, business, the military, religion,
> or signal processing).
> 
> https://en.wikipedia.org/wiki/Order_(mathematics)

Right, and no one of those listed there has a claim to exclusive use of
the term over any of the others. That even lists the meaning that I'm
referring to - "Orders of Magnitude".

https://en.wikipedia.org/wiki/Order_of_magnitude

"Other orders of magnitude may be calculated using bases other than 10."

This usage you don't like is to use ORDER in the kernel to mean "orders
of magnitude in base 2" in it's purest form. The calculation here is
address = index << PMD_ORDER which is the same as address = index *
2^PMD_ORDER.

I have no suggestion for you other than what Mike has put forward, which
retains the use of ORDER. If you still object to the use of ORDER, then
I'm sorry, but I have no further suggestions.

-- 
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] 41+ messages in thread

* Re: [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS
@ 2022-07-04 17:22                 ` Russell King (Oracle)
  0 siblings, 0 replies; 41+ messages in thread
From: Russell King (Oracle) @ 2022-07-04 17:22 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andrew Morton, Arnd Bergmann, Mike Rapoport, linux-arm-kernel,
	linux-mm, linux-kernel

On Mon, Jul 04, 2022 at 03:28:07PM +0100, Matthew Wilcox wrote:
> On Mon, Jul 04, 2022 at 12:32:20PM +0100, Russell King (Oracle) wrote:
> > On Mon, Jul 04, 2022 at 11:48:39AM +0100, Matthew Wilcox wrote:
> > > On Mon, Jul 04, 2022 at 05:32:33AM +0100, Russell King (Oracle) wrote:
> > > > On Sun, Jul 03, 2022 at 10:54:49PM +0100, Matthew Wilcox wrote:
> > > > > On Sun, Jul 03, 2022 at 10:16:45PM +0100, Russell King (Oracle) wrote:
> > > > > > On Sun, Jul 03, 2022 at 10:14:41PM +0100, Matthew Wilcox (Oracle) wrote:
> > > > > > > This is the number of bits used by a PMD entry, not the order of a PMD.
> > > > > > 
> > > > > > No, it's not the number of bits. A PMD entry doesn't fit in 2 or 3 bits.
> > > > > > This is even more confusing.
> > > > > 
> > > > > Well, what is it then?  The order of something is PAGE_SIZE << n, and
> > > > > that doesn't seem to be what this is.
> > > > 
> > > > Where is it defined that "order" means "PAGE_SIZE << n" ?
> > > 
> > > include/asm-generic/getorder.h: * get_order - Determine the allocation order of a memory size
> > 
> > I really don't care - "order" is something that is a standard term,
> 
> The word "order" has many different uses, just in mathematics alone (to
> say nothing of its uses in biology, business, the military, religion,
> or signal processing).
> 
> https://en.wikipedia.org/wiki/Order_(mathematics)

Right, and no one of those listed there has a claim to exclusive use of
the term over any of the others. That even lists the meaning that I'm
referring to - "Orders of Magnitude".

https://en.wikipedia.org/wiki/Order_of_magnitude

"Other orders of magnitude may be calculated using bases other than 10."

This usage you don't like is to use ORDER in the kernel to mean "orders
of magnitude in base 2" in it's purest form. The calculation here is
address = index << PMD_ORDER which is the same as address = index *
2^PMD_ORDER.

I have no suggestion for you other than what Mike has put forward, which
retains the use of ORDER. If you still object to the use of ORDER, then
I'm sorry, but I have no further suggestions.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-07-04 17:28 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03 14:11 [PATCH 00/14] arch: make PxD_ORDER generically available Mike Rapoport
2022-07-03 14:11 ` [PATCH 01/14] csky: drop definition of PTE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 02/14] csky: drop definition of PGD_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 03/14] mips: Rename PMD_ORDER to PMD_TABLE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 04/14] mips: Rename PUD_ORDER to PUD_TABLE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 05/14] mips: drop definitions of PTE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 06/14] mips: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 07/14] nios2: drop definition of PTE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 08/14] nios2: drop definition of PGD_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 09/14] loongarch: drop definition of PTE_ORDER Mike Rapoport
2022-07-03 14:11 ` [PATCH 10/14] loongarch: drop definition of PMD_ORDER Mike Rapoport
2022-07-03 14:12 ` [PATCH 11/14] loongarch: drop definition of PUD_ORDER Mike Rapoport
2022-07-03 14:12 ` [PATCH 12/14] loongarch: drop definition of PGD_ORDER Mike Rapoport
2022-07-03 20:50   ` Matthew Wilcox
2022-07-04  3:57     ` WANG Xuerui
2022-07-04  6:37       ` Mike Rapoport
2022-07-03 14:12 ` [PATCH 13/14] parisc: Rename PGD_ORDER to PGD_TABLE_ORDER Mike Rapoport
2022-07-03 14:12 ` [PATCH 14/14] xtensa: drop definition of PGD_ORDER Mike Rapoport
2022-07-03 14:27 ` [PATCH 00/14] arch: make PxD_ORDER generically available Helge Deller
2022-07-04  0:40   ` Huacai Chen
2022-07-04  1:45     ` Guo Ren
2022-07-03 21:14 ` [PATCH 15/14] arm: Rename PMD_ORDER to PMD_BITS Matthew Wilcox (Oracle)
2022-07-03 21:14   ` Matthew Wilcox (Oracle)
2022-07-03 21:16   ` Russell King (Oracle)
2022-07-03 21:16     ` Russell King (Oracle)
2022-07-03 21:54     ` Matthew Wilcox
2022-07-03 21:54       ` Matthew Wilcox
2022-07-04  4:32       ` Russell King (Oracle)
2022-07-04  4:32         ` Russell King (Oracle)
2022-07-04  6:26         ` Mike Rapoport
2022-07-04  6:26           ` Mike Rapoport
2022-07-04 11:37           ` Russell King (Oracle)
2022-07-04 11:37             ` Russell King (Oracle)
2022-07-04 10:48         ` Matthew Wilcox
2022-07-04 10:48           ` Matthew Wilcox
2022-07-04 11:32           ` Russell King (Oracle)
2022-07-04 11:32             ` Russell King (Oracle)
2022-07-04 14:28             ` Matthew Wilcox
2022-07-04 14:28               ` Matthew Wilcox
2022-07-04 17:22               ` Russell King (Oracle)
2022-07-04 17:22                 ` Russell King (Oracle)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.