diff mbox series

[v2,1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

Message ID 20220921020213.868124-1-nicholas@linux.ibm.com (mailing list archive)
State Changes Requested
Headers show
Series [v2,1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix | expand

Commit Message

Nicholas Miehlbradt Sept. 21, 2022, 2:02 a.m. UTC
There is support for DEBUG_PAGEALLOC on hash but not on radix.
Add support on radix.

Signed-off-by: Nicholas Miehlbradt <nicholas@linux.ibm.com>
---
v2: Revert change to radix_memory_block_size, instead set the size
in radix_init_pgtable and radix__create_section_mapping directly.
---
 arch/powerpc/mm/book3s64/radix_pgtable.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

Comments

Michael Ellerman Sept. 21, 2022, 3:31 a.m. UTC | #1
Nicholas Miehlbradt <nicholas@linux.ibm.com> writes:
> There is support for DEBUG_PAGEALLOC on hash but not on radix.
> Add support on radix.
>
> Signed-off-by: Nicholas Miehlbradt <nicholas@linux.ibm.com>
> ---
> v2: Revert change to radix_memory_block_size, instead set the size
> in radix_init_pgtable and radix__create_section_mapping directly.
> ---
>  arch/powerpc/mm/book3s64/radix_pgtable.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
> index db2f3d193448..623455c195d8 100644
> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> @@ -30,6 +30,7 @@
>  #include <asm/trace.h>
>  #include <asm/uaccess.h>
>  #include <asm/ultravisor.h>
> +#include <asm/set_memory.h>
>  
>  #include <trace/events/thp.h>
>  
> @@ -332,6 +333,10 @@ static void __init radix_init_pgtable(void)
>  	unsigned long rts_field;
>  	phys_addr_t start, end;
>  	u64 i;
> +	unsigned long size = radix_mem_block_size;
> +
> +	if (debug_pagealloc_enabled())
> +		size = PAGE_SIZE;
>  
>  	/* We don't support slb for radix */
>  	slb_set_size(0);
> @@ -352,7 +357,7 @@ static void __init radix_init_pgtable(void)
>  		}
>  
>  		WARN_ON(create_physical_mapping(start, end,
> -						radix_mem_block_size,
> +						size,
>  						-1, PAGE_KERNEL));
>  	}

There's only two calls to create_physical_mapping().

Both pass the same value for size, and now both needed updating for
debug page alloc.

Seems like create_physical_mapping() doesn't need the size passed to it
at all, it may as well just use the right value.

> @@ -844,13 +849,18 @@ int __meminit radix__create_section_mapping(unsigned long start,
>  					    unsigned long end, int nid,
>  					    pgprot_t prot)
>  {
> +	unsigned long size = radix_mem_block_size;
> +
> +	if (debug_pagealloc_enabled())
> +		size = PAGE_SIZE;
> +
>  	if (end >= RADIX_VMALLOC_START) {
>  		pr_warn("Outside the supported range\n");
>  		return -1;
>  	}
>  
>  	return create_physical_mapping(__pa(start), __pa(end),
> -				       radix_mem_block_size, nid, prot);
> +				       size, nid, prot);
>  }

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index db2f3d193448..623455c195d8 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -30,6 +30,7 @@ 
 #include <asm/trace.h>
 #include <asm/uaccess.h>
 #include <asm/ultravisor.h>
+#include <asm/set_memory.h>
 
 #include <trace/events/thp.h>
 
@@ -332,6 +333,10 @@  static void __init radix_init_pgtable(void)
 	unsigned long rts_field;
 	phys_addr_t start, end;
 	u64 i;
+	unsigned long size = radix_mem_block_size;
+
+	if (debug_pagealloc_enabled())
+		size = PAGE_SIZE;
 
 	/* We don't support slb for radix */
 	slb_set_size(0);
@@ -352,7 +357,7 @@  static void __init radix_init_pgtable(void)
 		}
 
 		WARN_ON(create_physical_mapping(start, end,
-						radix_mem_block_size,
+						size,
 						-1, PAGE_KERNEL));
 	}
 
@@ -844,13 +849,18 @@  int __meminit radix__create_section_mapping(unsigned long start,
 					    unsigned long end, int nid,
 					    pgprot_t prot)
 {
+	unsigned long size = radix_mem_block_size;
+
+	if (debug_pagealloc_enabled())
+		size = PAGE_SIZE;
+
 	if (end >= RADIX_VMALLOC_START) {
 		pr_warn("Outside the supported range\n");
 		return -1;
 	}
 
 	return create_physical_mapping(__pa(start), __pa(end),
-				       radix_mem_block_size, nid, prot);
+				       size, nid, prot);
 }
 
 int __meminit radix__remove_section_mapping(unsigned long start, unsigned long end)
@@ -899,7 +909,14 @@  void __meminit radix__vmemmap_remove_mapping(unsigned long start, unsigned long
 #ifdef CONFIG_DEBUG_PAGEALLOC
 void radix__kernel_map_pages(struct page *page, int numpages, int enable)
 {
-	pr_warn_once("DEBUG_PAGEALLOC not supported in radix mode\n");
+	unsigned long addr;
+
+	addr = (unsigned long)page_address(page);
+
+	if (enable)
+		set_memory_p(addr, numpages);
+	else
+		set_memory_np(addr, numpages);
 }
 #endif