All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE
@ 2019-03-14 12:54 Michael Ellerman
  2019-03-14 13:20 ` Aneesh Kumar K.V
  2019-04-21 14:18 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2019-03-14 12:54 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar

Add comments describing the size in bytes of the various levels of the
page table tree, and the size of the virtual address space mapped by
each level, to make it clear what the sizes are without having to also
look up other definitions.

The code that calculates the sizes actually uses sizeof(pgd_t) etc.,
so in theory these comments could skew vs the code, but the size of
pgd_t etc. is unlikely to change very often.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/book3s/64/hash-4k.h   | 8 ++++----
 arch/powerpc/include/asm/book3s/64/hash-64k.h  | 9 +++++----
 arch/powerpc/include/asm/book3s/64/radix-4k.h  | 9 +++++----
 arch/powerpc/include/asm/book3s/64/radix-64k.h | 8 ++++----
 4 files changed, 18 insertions(+), 16 deletions(-)

Someone *please* check my math :)

diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
index cf5ba5254299..54fab723a8c7 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
@@ -2,10 +2,10 @@
 #ifndef _ASM_POWERPC_BOOK3S_64_HASH_4K_H
 #define _ASM_POWERPC_BOOK3S_64_HASH_4K_H
 
-#define H_PTE_INDEX_SIZE  9
-#define H_PMD_INDEX_SIZE  7
-#define H_PUD_INDEX_SIZE  9
-#define H_PGD_INDEX_SIZE  9
+#define H_PTE_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x   4KB =   2MB
+#define H_PMD_INDEX_SIZE  7  // size: 8B << 7 = 1KB, maps: 2^7 x   2MB = 256MB
+#define H_PUD_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x 256MB = 128GB
+#define H_PGD_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x 128GB =  64TB
 
 /*
  * Each context is 512TB. But on 4k we restrict our max TASK size to 64TB
diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
index f82ee8a3b561..81f4eb6e7da4 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
@@ -2,10 +2,11 @@
 #ifndef _ASM_POWERPC_BOOK3S_64_HASH_64K_H
 #define _ASM_POWERPC_BOOK3S_64_HASH_64K_H
 
-#define H_PTE_INDEX_SIZE  8
-#define H_PMD_INDEX_SIZE  10
-#define H_PUD_INDEX_SIZE  10
-#define H_PGD_INDEX_SIZE  8
+#define H_PTE_INDEX_SIZE   8  // size: 8B <<  8 = 2KB, maps 2^8  x 64KB = 16MB
+#define H_PMD_INDEX_SIZE  10  // size: 8B << 10 = 8KB, maps 2^10 x 16MB = 16GB
+#define H_PUD_INDEX_SIZE  10  // size: 8B << 10 = 8KB, maps 2^10 x 16GB = 16TB
+#define H_PGD_INDEX_SIZE   8  // size: 8B <<  8 = 2KB, maps 2^8  x 16TB =  4PB
+
 
 /*
  * Each context is 512TB size. SLB miss for first context/default context
diff --git a/arch/powerpc/include/asm/book3s/64/radix-4k.h b/arch/powerpc/include/asm/book3s/64/radix-4k.h
index 863c3e8286fb..d5f5ab73dc7f 100644
--- a/arch/powerpc/include/asm/book3s/64/radix-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/radix-4k.h
@@ -5,10 +5,11 @@
 /*
  * For 4K page size supported index is 13/9/9/9
  */
-#define RADIX_PTE_INDEX_SIZE  9  /* 2MB huge page */
-#define RADIX_PMD_INDEX_SIZE  9  /* 1G huge page */
-#define RADIX_PUD_INDEX_SIZE	 9
-#define RADIX_PGD_INDEX_SIZE  13
+#define RADIX_PTE_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x    4K =   2MB
+#define RADIX_PMD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   2MB =   1GB
+#define RADIX_PUD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   1GB = 512GB
+#define RADIX_PGD_INDEX_SIZE  13  // size: 8B << 13 = 64KB, maps 2^13 x 512GB =   4PB
+
 /*
  * One fragment per per page
  */
diff --git a/arch/powerpc/include/asm/book3s/64/radix-64k.h b/arch/powerpc/include/asm/book3s/64/radix-64k.h
index ccb78ca9d0c5..54e33828b0fb 100644
--- a/arch/powerpc/include/asm/book3s/64/radix-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/radix-64k.h
@@ -5,10 +5,10 @@
 /*
  * For 64K page size supported index is 13/9/9/5
  */
-#define RADIX_PTE_INDEX_SIZE  5  /* 2MB huge page */
-#define RADIX_PMD_INDEX_SIZE  9  /* 1G huge page */
-#define RADIX_PUD_INDEX_SIZE	 9
-#define RADIX_PGD_INDEX_SIZE  13
+#define RADIX_PTE_INDEX_SIZE   5  // size: 8B <<  5 = 256B, maps 2^5  x   64K =   2MB
+#define RADIX_PMD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   2MB =   1GB
+#define RADIX_PUD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   1GB = 512GB
+#define RADIX_PGD_INDEX_SIZE  13  // size: 8B << 13 = 64KB, maps 2^13 x 512GB =   4PB
 
 /*
  * We use a 256 byte PTE page fragment in radix
-- 
2.20.1


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

* Re: [PATCH] powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE
  2019-03-14 12:54 [PATCH] powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE Michael Ellerman
@ 2019-03-14 13:20 ` Aneesh Kumar K.V
  2019-04-21 14:18 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Aneesh Kumar K.V @ 2019-03-14 13:20 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: aneesh.kumar

Michael Ellerman <mpe@ellerman.id.au> writes:

> Add comments describing the size in bytes of the various levels of the
> page table tree, and the size of the virtual address space mapped by
> each level, to make it clear what the sizes are without having to also
> look up other definitions.
>
> The code that calculates the sizes actually uses sizeof(pgd_t) etc.,
> so in theory these comments could skew vs the code, but the size of
> pgd_t etc. is unlikely to change very often.
>

This makes it soo much easier to follow the page table mapping w.r.t hugepages.

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/book3s/64/hash-4k.h   | 8 ++++----
>  arch/powerpc/include/asm/book3s/64/hash-64k.h  | 9 +++++----
>  arch/powerpc/include/asm/book3s/64/radix-4k.h  | 9 +++++----
>  arch/powerpc/include/asm/book3s/64/radix-64k.h | 8 ++++----
>  4 files changed, 18 insertions(+), 16 deletions(-)
>
> Someone *please* check my math :)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> index cf5ba5254299..54fab723a8c7 100644
> --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
> +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> @@ -2,10 +2,10 @@
>  #ifndef _ASM_POWERPC_BOOK3S_64_HASH_4K_H
>  #define _ASM_POWERPC_BOOK3S_64_HASH_4K_H
>
> -#define H_PTE_INDEX_SIZE  9
> -#define H_PMD_INDEX_SIZE  7
> -#define H_PUD_INDEX_SIZE  9
> -#define H_PGD_INDEX_SIZE  9
> +#define H_PTE_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x   4KB =   2MB
> +#define H_PMD_INDEX_SIZE  7  // size: 8B << 7 = 1KB, maps: 2^7 x   2MB = 256MB
> +#define H_PUD_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x 256MB = 128GB
> +#define H_PGD_INDEX_SIZE  9  // size: 8B << 9 = 4KB, maps: 2^9 x 128GB =  64TB
>
>  /*
>   * Each context is 512TB. But on 4k we restrict our max TASK size to 64TB
> diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> index f82ee8a3b561..81f4eb6e7da4 100644
> --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
> +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> @@ -2,10 +2,11 @@
>  #ifndef _ASM_POWERPC_BOOK3S_64_HASH_64K_H
>  #define _ASM_POWERPC_BOOK3S_64_HASH_64K_H
>
> -#define H_PTE_INDEX_SIZE  8
> -#define H_PMD_INDEX_SIZE  10
> -#define H_PUD_INDEX_SIZE  10
> -#define H_PGD_INDEX_SIZE  8
> +#define H_PTE_INDEX_SIZE   8  // size: 8B <<  8 = 2KB, maps 2^8  x 64KB = 16MB
> +#define H_PMD_INDEX_SIZE  10  // size: 8B << 10 = 8KB, maps 2^10 x 16MB = 16GB
> +#define H_PUD_INDEX_SIZE  10  // size: 8B << 10 = 8KB, maps 2^10 x 16GB = 16TB
> +#define H_PGD_INDEX_SIZE   8  // size: 8B <<  8 = 2KB, maps 2^8  x 16TB =  4PB
> +
>
>  /*
>   * Each context is 512TB size. SLB miss for first context/default context
> diff --git a/arch/powerpc/include/asm/book3s/64/radix-4k.h b/arch/powerpc/include/asm/book3s/64/radix-4k.h
> index 863c3e8286fb..d5f5ab73dc7f 100644
> --- a/arch/powerpc/include/asm/book3s/64/radix-4k.h
> +++ b/arch/powerpc/include/asm/book3s/64/radix-4k.h
> @@ -5,10 +5,11 @@
>  /*
>   * For 4K page size supported index is 13/9/9/9
>   */
> -#define RADIX_PTE_INDEX_SIZE  9  /* 2MB huge page */
> -#define RADIX_PMD_INDEX_SIZE  9  /* 1G huge page */
> -#define RADIX_PUD_INDEX_SIZE	 9
> -#define RADIX_PGD_INDEX_SIZE  13
> +#define RADIX_PTE_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x    4K =   2MB
> +#define RADIX_PMD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   2MB =   1GB
> +#define RADIX_PUD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   1GB = 512GB
> +#define RADIX_PGD_INDEX_SIZE  13  // size: 8B << 13 = 64KB, maps 2^13 x 512GB =   4PB
> +
>  /*
>   * One fragment per per page
>   */
> diff --git a/arch/powerpc/include/asm/book3s/64/radix-64k.h b/arch/powerpc/include/asm/book3s/64/radix-64k.h
> index ccb78ca9d0c5..54e33828b0fb 100644
> --- a/arch/powerpc/include/asm/book3s/64/radix-64k.h
> +++ b/arch/powerpc/include/asm/book3s/64/radix-64k.h
> @@ -5,10 +5,10 @@
>  /*
>   * For 64K page size supported index is 13/9/9/5
>   */
> -#define RADIX_PTE_INDEX_SIZE  5  /* 2MB huge page */
> -#define RADIX_PMD_INDEX_SIZE  9  /* 1G huge page */
> -#define RADIX_PUD_INDEX_SIZE	 9
> -#define RADIX_PGD_INDEX_SIZE  13
> +#define RADIX_PTE_INDEX_SIZE   5  // size: 8B <<  5 = 256B, maps 2^5  x   64K =   2MB
> +#define RADIX_PMD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   2MB =   1GB
> +#define RADIX_PUD_INDEX_SIZE   9  // size: 8B <<  9 =  4KB, maps 2^9  x   1GB = 512GB
> +#define RADIX_PGD_INDEX_SIZE  13  // size: 8B << 13 = 64KB, maps 2^13 x 512GB =   4PB
>
>  /*
>   * We use a 256 byte PTE page fragment in radix
> -- 
> 2.20.1


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

* Re: powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE
  2019-03-14 12:54 [PATCH] powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE Michael Ellerman
  2019-03-14 13:20 ` Aneesh Kumar K.V
@ 2019-04-21 14:18 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2019-04-21 14:18 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: aneesh.kumar

On Thu, 2019-03-14 at 12:54:53 UTC, Michael Ellerman wrote:
> Add comments describing the size in bytes of the various levels of the
> page table tree, and the size of the virtual address space mapped by
> each level, to make it clear what the sizes are without having to also
> look up other definitions.
> 
> The code that calculates the sizes actually uses sizeof(pgd_t) etc.,
> so in theory these comments could skew vs the code, but the size of
> pgd_t etc. is unlikely to change very often.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/eea86aa4171d4960f0fcdc99dab358c2

cheers

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

end of thread, other threads:[~2019-04-21 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 12:54 [PATCH] powerpc/mm/64: Document the sizes of/sizes mapped by Pxx_INDEX_SIZE Michael Ellerman
2019-03-14 13:20 ` Aneesh Kumar K.V
2019-04-21 14:18 ` Michael Ellerman

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.