Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3052216ybc; Mon, 18 Nov 2019 08:47:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxAtdTzceFI4peQnzwYfLU+C5IoBrTqD4eH71RFsMCvbTIQS/UwQGJ+cYP56wIbRWJ0niZh X-Received: by 2002:a17:906:edd5:: with SMTP id sb21mr27230336ejb.138.1574095653587; Mon, 18 Nov 2019 08:47:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574095653; cv=none; d=google.com; s=arc-20160816; b=FbNEE8Yvb9onpWiatsu+dBLT0GZSuB9iCFhenv4R7KaeIlgrasNeUi4vWdC6IzeyR/ feRT7+DLCDLKcI/4ww/JnfHoTMcjerMlmGMKzBL4g1L51RubY4SULeY6WaDdqizUBr3A ZRkhZkZot4NQcshtk4Xg3bn7xVzpAR5klt2S+P08bs7+XUrvD17ZdfqswU8iCdvL5Veg 1OzHEbhBJ+pG0QACJtT9a8vjZImmfBx0ZSH09hiJr79jLh0R5iEsfTcb4rB09npdsB7X SlZOJNGK6bbucelrRUtDzRV5Fqyygng+XD7ZzinvzNij+62ulfO8csv8UzCHrUdmXsYD AGMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=ZIatk1vs4qaWh8+Q9j0CxsigNwHg7QeDELCEUqqp7SQ=; b=VexidEI7ea+sOOJn2d+bikWMFCU7zksdDTwQPKQo+Ft1dj2kX9FKUgeIrjnPfemtMo IPZAjs5231wIDtYABBd9hsYEbvc/q73DcKArwbWzHLgRCfi0Zw7pvAvbum5U0Yq91QzY j51vdCSGdTXJm16jtcUS1BZCTE/1fgtMTI5MFRd7gLamD8l+VS1yKPfrpqG4t02XHteP lLmUuWgE6AD/8aWaLYvO7F+O2curivCVoTB2Npogstep0qcjvt85T+UMC5LVlV/1TZGx BiBlrPus/m+uqPIs+YwtJmMinu6BD01xWLd5ke5BWVQmBQ4+jckPcBQLDSTUNXg4d75a epNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 27si13407605eji.207.2019.11.18.08.47.09; Mon, 18 Nov 2019 08:47:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbfKRQoh (ORCPT + 99 others); Mon, 18 Nov 2019 11:44:37 -0500 Received: from ale.deltatee.com ([207.54.116.67]:44868 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfKRQoh (ORCPT ); Mon, 18 Nov 2019 11:44:37 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1iWk8Q-0000Vr-JU; Mon, 18 Nov 2019 09:44:19 -0700 To: Yash Shah , "Paul Walmsley ( Sifive)" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Cc: "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , "Anup.Patel@wdc.com" , "rppt@linux.ibm.com" , "ren_guo@c-sky.com" , "bmeng.cn@gmail.com" , "tglx@linutronix.de" , "wangkefeng.wang@huawei.com" , Sachin Ghadi References: <1574056694-28927-1-git-send-email-yash.shah@sifive.com> From: Logan Gunthorpe Message-ID: <86b0a2c6-91ee-6ea6-92e7-1e5235b559f5@deltatee.com> Date: Mon, 18 Nov 2019 09:44:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <1574056694-28927-1-git-send-email-yash.shah@sifive.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: sachin.ghadi@sifive.com, wangkefeng.wang@huawei.com, tglx@linutronix.de, bmeng.cn@gmail.com, ren_guo@c-sky.com, rppt@linux.ibm.com, Anup.Patel@wdc.com, aou@eecs.berkeley.edu, palmer@dabbelt.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, paul.walmsley@sifive.com, yash.shah@sifive.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v2] RISC-V: Add address map dumper X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Looks good to me, thanks. Reviewed-by: Logan Gunthorpe > --- > 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 >