Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2454954ybc; Sun, 17 Nov 2019 22:16:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzU1pNG1+pAuKzi/5TyqQXK5SJ63RgLxEiSYmnuwP3txaiflSo68DSuePpLSzpl3V56J2Vp X-Received: by 2002:a17:907:216e:: with SMTP id rl14mr24271966ejb.291.1574057762256; Sun, 17 Nov 2019 22:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574057762; cv=none; d=google.com; s=arc-20160816; b=ietI3kUnM5E9A+vk5Aus7MzMVqHJHGfHrQb4VoxLWawB2c6Hp8DKrqqs10X60Nqd0l vz9dWHz0V64MfWlam4OJY1ywiDFUTt/dXGTyUUQe4Ij9KuFu5mL8e8r3vWt2h4lHS/fr XYx7oXJDPVndgyjuONoocyHkwq/tfU7flTG5oEEGAbMOUdOWgtFQK9nofyZGlVpQEvLl KF4KPzjVDkjVyb/TifkWRnLRLt5wri5DBVGl1kd3nZJY5/18j3TwclMMkpTUjAPKXH5g yFrzBEm5J1X+TlKJDnckieaTPQNJeCcaVIe1m0KAkI7sbEKwiJueeoSIVvL2kjkuXqP7 9kPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=dzhVBOMf59PHYjhcO5/bPOeyIO8A+TPlN5Z6xmX6Zfg=; b=AUfYKjc1QFkucJTN815msQgDa6a2edfuGzkrJXNKAOa7LQL38sAVkMV7tt3G3PmP3j 2/wGRbKLMNxeEg51AvXQ/TFY0X4FKRiUEtnfepDQp8cYcES1qfnzB6XZhSL3+WDtobjG HPRQEOFCAR0N78yTl8bzUhntsi6BuSrtPa2r1yoVZR/ZRBTCLWJewn7oBaVOA1bgxzxx f8yI9u3pu8kqrTNX2gjzI09nrWlIXGEcn/o2tWyuSWew7GBhZpL14iev45mPmx5zmsWV 2gRKMfnQoedU8ZLV4t2Nh+LXKnWmsB5eftBCLBjKCq+t0iIPafAXwLaBmQwv+YkYna0O uNHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=mUbuNpug; 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 br3si10851401ejb.436.2019.11.17.22.15.27; Sun, 17 Nov 2019 22:16:02 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=mUbuNpug; 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 S1726414AbfKRGM5 (ORCPT + 99 others); Mon, 18 Nov 2019 01:12:57 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40230 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfKRGM5 (ORCPT ); Mon, 18 Nov 2019 01:12:57 -0500 Received: by mail-wr1-f67.google.com with SMTP id q15so5123154wrw.7 for ; Sun, 17 Nov 2019 22:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dzhVBOMf59PHYjhcO5/bPOeyIO8A+TPlN5Z6xmX6Zfg=; b=mUbuNpugZTAnDNPQd9lieNDlt85CfqQ5HxNZOSP9AmjHYAi6SjRi99kn9IidBIRO/y nzWX4u6iJv3jxNH6Ebm8CnPahp9MXMG+rmb4i0k1gmRvkRsojYil4v294x+cCA73d/M1 Us3w7jQR2ohkELcopCpnoFTNzC3mSuK01Y9IvHC8sSVUCljzpsjr8GGit1OmpD0D+YXg W/5aMm/0YbvxkVD9FrAwPdS1Y1KuysOwOlWlg7aQy/uN765LkJrx/wDzh/U+m731G2ph iKLwDuP0Rk7eOLCRi+7hP1QR8HELJWzSN1tMuVxi3Cckij/mAA0xQsY65zhW6Y33o60a ATGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dzhVBOMf59PHYjhcO5/bPOeyIO8A+TPlN5Z6xmX6Zfg=; b=gTRnHwR574/RXUjViU2gmNfYYHpEWBk2K1nNvv29VuJUHoVD9j5FsVOc5UnDL6LcW6 a+CWSn/VY4Bt/14GbPPAJgN9TzWUHflJ2R8W2plD56WCux9rD+iXdiYgM8pdgNmbHOOG LJ0DT8yeBnALBLj1+xjHhYP2PMSrHXtGn0OZXvTSwyMyGoY2w9AyLBUAkks00E1CWb2r OE2yinuJUvfMOsOIfZuNPtY66ROqRJsV82WolbXhNsgqhwX2sXvcrgk0p1pJkuMzmmfJ poFkaU33lfsvnKCpnZXK4fMhFjqvzdiz/ajtS080L95DOwNmctm7pWaNP04bPtTPfq/A jV3w== X-Gm-Message-State: APjAAAW+naEP5FSF5S9tFRZ4IzrDSnzmq4kBx+kpVQizebf+1PMUu78n 8TEorCWmBKDXIlqKC6PfYS4/bA4qON0f7Xo03K56lw== X-Received: by 2002:a05:6000:104:: with SMTP id o4mr26662567wrx.309.1574057574393; Sun, 17 Nov 2019 22:12:54 -0800 (PST) MIME-Version: 1.0 References: <1574056694-28927-1-git-send-email-yash.shah@sifive.com> In-Reply-To: <1574056694-28927-1-git-send-email-yash.shah@sifive.com> From: Anup Patel Date: Mon, 18 Nov 2019 11:42:43 +0530 Message-ID: Subject: Re: [PATCH v2] RISC-V: Add address map dumper To: Yash Shah Cc: "Paul Walmsley ( Sifive)" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , "Anup.Patel@wdc.com" , "rppt@linux.ibm.com" , "logang@deltatee.com" , "ren_guo@c-sky.com" , "bmeng.cn@gmail.com" , "tglx@linutronix.de" , "wangkefeng.wang@huawei.com" , Sachin Ghadi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 18, 2019 at 11:28 AM 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 > --- > 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 Regards, Anup