Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] RISC-V: Add address map dumper
@ 2019-11-18  5:58 Yash Shah
  2019-11-18  6:12 ` Anup Patel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yash Shah @ 2019-11-18  5:58 UTC (permalink / raw)
  To: Paul Walmsley ( Sifive), linux-riscv, linux-kernel
  Cc: wangkefeng.wang, aou, Anup.Patel, rppt, Sachin Ghadi, Yash Shah,
	palmer, ren_guo, tglx, bmeng.cn, logang

Add support for dumping the kernel address space layout to the console.
User can enable CONFIG_DEBUG_VM to dump the virtual memory region into
dmesg buffer during boot-up.

Signed-off-by: Yash Shah <yash.shah@sifive.com>
---
This patch is based on Linux 5.4-rc6 and tested on SiFive HiFive
Unleashed board.

Changes in v2:
- Avoid #ifdefs inside functions
- Helper functions instead of macros
- Drop newly added CONFIG_DEBUG_VM_LAYOUT, instead use CONFIG_DEBUG_VM
---
 arch/riscv/mm/init.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 573463d..7828136 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -45,6 +45,41 @@ void setup_zero_page(void)
 	memset((void *)empty_zero_page, 0, PAGE_SIZE);
 }
 
+#ifdef CONFIG_DEBUG_VM
+static inline void print_mlk(char *name, unsigned long b, unsigned long t)
+{
+	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
+		  (((t) - (b)) >> 10));
+}
+
+static inline void print_mlm(char *name, unsigned long b, unsigned long t)
+{
+	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld MB)\n", name, b, t,
+		  (((t) - (b)) >> 20));
+}
+
+static void print_vm_layout(void)
+{
+	pr_notice("Virtual kernel memory layout:\n");
+	print_mlk("fixmap", (unsigned long)FIXADDR_START,
+		  (unsigned long)FIXADDR_TOP);
+	print_mlm("vmemmap", (unsigned long)VMEMMAP_START,
+		  (unsigned long)VMEMMAP_END);
+	print_mlm("vmalloc", (unsigned long)VMALLOC_START,
+		  (unsigned long)VMALLOC_END);
+	print_mlm("lowmem", (unsigned long)PAGE_OFFSET,
+		  (unsigned long)high_memory);
+	print_mlk(".init", (unsigned long)__init_begin,
+		  (unsigned long)__init_end);
+	print_mlk(".text", (unsigned long)_text, (unsigned long)_etext);
+	print_mlk(".data", (unsigned long)_sdata, (unsigned long)_edata);
+	print_mlk(".bss", (unsigned long)__bss_start,
+		  (unsigned long)__bss_stop);
+}
+#else
+static void print_vm_layout(void) { }
+#endif /* CONFIG_DEBUG_VM */
+
 void __init mem_init(void)
 {
 #ifdef CONFIG_FLATMEM
@@ -55,6 +90,7 @@ void __init mem_init(void)
 	memblock_free_all();
 
 	mem_init_print_info(NULL);
+	print_vm_layout();
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
2.7.4


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

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

* Re: [PATCH v2] RISC-V: Add address map dumper
  2019-11-18  5:58 [PATCH v2] RISC-V: Add address map dumper Yash Shah
@ 2019-11-18  6:12 ` Anup Patel
  2019-11-18 16:44 ` Logan Gunthorpe
  2019-11-23  2:57 ` Paul Walmsley
  2 siblings, 0 replies; 4+ messages in thread
From: Anup Patel @ 2019-11-18  6:12 UTC (permalink / raw)
  To: Yash Shah
  Cc: wangkefeng.wang, aou, Anup.Patel, linux-kernel, rppt,
	Sachin Ghadi, palmer, ren_guo, Paul Walmsley \( Sifive\),
	linux-riscv, bmeng.cn, logang, tglx

On Mon, Nov 18, 2019 at 11:28 AM Yash Shah <yash.shah@sifive.com> wrote:
>
> Add support for dumping the kernel address space layout to the console.
> User can enable CONFIG_DEBUG_VM to dump the virtual memory region into
> dmesg buffer during boot-up.
>
> Signed-off-by: Yash Shah <yash.shah@sifive.com>
> ---
> This patch is based on Linux 5.4-rc6 and tested on SiFive HiFive
> Unleashed board.
>
> Changes in v2:
> - Avoid #ifdefs inside functions
> - Helper functions instead of macros
> - Drop newly added CONFIG_DEBUG_VM_LAYOUT, instead use CONFIG_DEBUG_VM
> ---
>  arch/riscv/mm/init.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 573463d..7828136 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -45,6 +45,41 @@ void setup_zero_page(void)
>         memset((void *)empty_zero_page, 0, PAGE_SIZE);
>  }
>
> +#ifdef CONFIG_DEBUG_VM
> +static inline void print_mlk(char *name, unsigned long b, unsigned long t)
> +{
> +       pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
> +                 (((t) - (b)) >> 10));
> +}
> +
> +static inline void print_mlm(char *name, unsigned long b, unsigned long t)
> +{
> +       pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld MB)\n", name, b, t,
> +                 (((t) - (b)) >> 20));
> +}
> +
> +static void print_vm_layout(void)
> +{
> +       pr_notice("Virtual kernel memory layout:\n");
> +       print_mlk("fixmap", (unsigned long)FIXADDR_START,
> +                 (unsigned long)FIXADDR_TOP);
> +       print_mlm("vmemmap", (unsigned long)VMEMMAP_START,
> +                 (unsigned long)VMEMMAP_END);
> +       print_mlm("vmalloc", (unsigned long)VMALLOC_START,
> +                 (unsigned long)VMALLOC_END);
> +       print_mlm("lowmem", (unsigned long)PAGE_OFFSET,
> +                 (unsigned long)high_memory);
> +       print_mlk(".init", (unsigned long)__init_begin,
> +                 (unsigned long)__init_end);
> +       print_mlk(".text", (unsigned long)_text, (unsigned long)_etext);
> +       print_mlk(".data", (unsigned long)_sdata, (unsigned long)_edata);
> +       print_mlk(".bss", (unsigned long)__bss_start,
> +                 (unsigned long)__bss_stop);
> +}
> +#else
> +static void print_vm_layout(void) { }
> +#endif /* CONFIG_DEBUG_VM */
> +
>  void __init mem_init(void)
>  {
>  #ifdef CONFIG_FLATMEM
> @@ -55,6 +90,7 @@ void __init mem_init(void)
>         memblock_free_all();
>
>         mem_init_print_info(NULL);
> +       print_vm_layout();
>  }
>
>  #ifdef CONFIG_BLK_DEV_INITRD
> --
> 2.7.4
>

LGTM.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

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

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

* Re: [PATCH v2] RISC-V: Add address map dumper
  2019-11-18  5:58 [PATCH v2] RISC-V: Add address map dumper Yash Shah
  2019-11-18  6:12 ` Anup Patel
@ 2019-11-18 16:44 ` Logan Gunthorpe
  2019-11-23  2:57 ` Paul Walmsley
  2 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2019-11-18 16:44 UTC (permalink / raw)
  To: Yash Shah, Paul Walmsley ( Sifive), linux-riscv, linux-kernel
  Cc: wangkefeng.wang, aou, Anup.Patel, rppt, Sachin Ghadi, palmer,
	ren_guo, tglx, bmeng.cn



On 2019-11-17 10:58 p.m., Yash Shah wrote:
> Add support for dumping the kernel address space layout to the console.
> User can enable CONFIG_DEBUG_VM to dump the virtual memory region into
> dmesg buffer during boot-up.
> 
> Signed-off-by: Yash Shah <yash.shah@sifive.com>

Looks good to me, thanks.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

> ---
> This patch is based on Linux 5.4-rc6 and tested on SiFive HiFive
> Unleashed board.
> 
> Changes in v2:
> - Avoid #ifdefs inside functions
> - Helper functions instead of macros
> - Drop newly added CONFIG_DEBUG_VM_LAYOUT, instead use CONFIG_DEBUG_VM
> ---
>  arch/riscv/mm/init.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 573463d..7828136 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -45,6 +45,41 @@ void setup_zero_page(void)
>  	memset((void *)empty_zero_page, 0, PAGE_SIZE);
>  }
>  
> +#ifdef CONFIG_DEBUG_VM
> +static inline void print_mlk(char *name, unsigned long b, unsigned long t)
> +{
> +	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
> +		  (((t) - (b)) >> 10));
> +}
> +
> +static inline void print_mlm(char *name, unsigned long b, unsigned long t)
> +{
> +	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld MB)\n", name, b, t,
> +		  (((t) - (b)) >> 20));
> +}
> +
> +static void print_vm_layout(void)
> +{
> +	pr_notice("Virtual kernel memory layout:\n");
> +	print_mlk("fixmap", (unsigned long)FIXADDR_START,
> +		  (unsigned long)FIXADDR_TOP);
> +	print_mlm("vmemmap", (unsigned long)VMEMMAP_START,
> +		  (unsigned long)VMEMMAP_END);
> +	print_mlm("vmalloc", (unsigned long)VMALLOC_START,
> +		  (unsigned long)VMALLOC_END);
> +	print_mlm("lowmem", (unsigned long)PAGE_OFFSET,
> +		  (unsigned long)high_memory);
> +	print_mlk(".init", (unsigned long)__init_begin,
> +		  (unsigned long)__init_end);
> +	print_mlk(".text", (unsigned long)_text, (unsigned long)_etext);
> +	print_mlk(".data", (unsigned long)_sdata, (unsigned long)_edata);
> +	print_mlk(".bss", (unsigned long)__bss_start,
> +		  (unsigned long)__bss_stop);
> +}
> +#else
> +static void print_vm_layout(void) { }
> +#endif /* CONFIG_DEBUG_VM */
> +
>  void __init mem_init(void)
>  {
>  #ifdef CONFIG_FLATMEM
> @@ -55,6 +90,7 @@ void __init mem_init(void)
>  	memblock_free_all();
>  
>  	mem_init_print_info(NULL);
> +	print_vm_layout();
>  }
>  
>  #ifdef CONFIG_BLK_DEV_INITRD
> 

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

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

* Re: [PATCH v2] RISC-V: Add address map dumper
  2019-11-18  5:58 [PATCH v2] RISC-V: Add address map dumper Yash Shah
  2019-11-18  6:12 ` Anup Patel
  2019-11-18 16:44 ` Logan Gunthorpe
@ 2019-11-23  2:57 ` Paul Walmsley
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2019-11-23  2:57 UTC (permalink / raw)
  To: Yash Shah
  Cc: wangkefeng.wang, aou, Anup.Patel, linux-kernel, rppt,
	Sachin Ghadi, palmer, ren_guo, linux-riscv, bmeng.cn, logang,
	tglx

Hi Yash,

On Mon, 18 Nov 2019, Yash Shah wrote:

> Add support for dumping the kernel address space layout to the console.
> User can enable CONFIG_DEBUG_VM to dump the virtual memory region into
> dmesg buffer during boot-up.
> 
> Signed-off-by: Yash Shah <yash.shah@sifive.com>

Thanks, I've queued up the following patch.  I added the PCI I/O region,
and also dropped some of the .init/.text/etc. prints since they duplicate 
the output from mem_init_print_info().


- Paul

From: Yash Shah <yash.shah@sifive.com>
Date: Mon, 18 Nov 2019 05:58:34 +0000
Subject: [PATCH] RISC-V: Add address map dumper

Add support for dumping the kernel address space layout to the console.
User can enable CONFIG_DEBUG_VM to dump the virtual memory region into
dmesg buffer during boot-up.

Signed-off-by: Yash Shah <yash.shah@sifive.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
[paul.walmsley@sifive.com: dropped .init/.text/.data/.bss prints;
 added PCI legacy I/O region display]
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
---
 arch/riscv/mm/init.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 573463d1c799..c2c0e244555f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -45,6 +45,37 @@ void setup_zero_page(void)
 	memset((void *)empty_zero_page, 0, PAGE_SIZE);
 }
 
+#ifdef CONFIG_DEBUG_VM
+static inline void print_mlk(char *name, unsigned long b, unsigned long t)
+{
+	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
+		  (((t) - (b)) >> 10));
+}
+
+static inline void print_mlm(char *name, unsigned long b, unsigned long t)
+{
+	pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld MB)\n", name, b, t,
+		  (((t) - (b)) >> 20));
+}
+
+static void print_vm_layout(void)
+{
+	pr_notice("Virtual kernel memory layout:\n");
+	print_mlk("fixmap", (unsigned long)FIXADDR_START,
+		  (unsigned long)FIXADDR_TOP);
+	print_mlm("pci io", (unsigned long)PCI_IO_START,
+		  (unsigned long)PCI_IO_END);
+	print_mlm("vmemmap", (unsigned long)VMEMMAP_START,
+		  (unsigned long)VMEMMAP_END);
+	print_mlm("vmalloc", (unsigned long)VMALLOC_START,
+		  (unsigned long)VMALLOC_END);
+	print_mlm("lowmem", (unsigned long)PAGE_OFFSET,
+		  (unsigned long)high_memory);
+}
+#else
+static void print_vm_layout(void) { }
+#endif /* CONFIG_DEBUG_VM */
+
 void __init mem_init(void)
 {
 #ifdef CONFIG_FLATMEM
@@ -55,6 +86,7 @@ void __init mem_init(void)
 	memblock_free_all();
 
 	mem_init_print_info(NULL);
+	print_vm_layout();
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
2.24.0.rc0


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

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  5:58 [PATCH v2] RISC-V: Add address map dumper Yash Shah
2019-11-18  6:12 ` Anup Patel
2019-11-18 16:44 ` Logan Gunthorpe
2019-11-23  2:57 ` Paul Walmsley

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git