Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp660655yba; Wed, 24 Apr 2019 07:37:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+yayY9a8fkLcEc4+/InEklISD9Za+PZZGVRWoiVIMfjctUpOXEsg9ALnq3UxNQ8GlTyhy X-Received: by 2002:a63:c944:: with SMTP id y4mr31513296pgg.257.1556116631997; Wed, 24 Apr 2019 07:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556116631; cv=none; d=google.com; s=arc-20160816; b=RBWEo09F8cOF7jnaggbFwUf0DnuN2RQalvHNA9aeiOEESe0hRig9FacnQ56JHBxVpj gGq21sq+49fDtec92qTu0444D0gUdA44n4gT/AbvYxWjZ9AXjGpYiOGmZokDu5pj0oi1 xCyiRx6hJgNUhL1w/bS/SM2DL0vsb5i/H05FumhiNjpRZZ+4NXkxtmfEVE7oRgbzoEqT 8Mvcyo3HqEYVeXWeznU8aMUFbLODqp8Fnr4sQyxh3eyqHO3NpmXumkq5UHae5mR38dv3 hUAmz8JVSeDeEYisGJ8uru3BDvC5wX2mFUwlsHbuYROM1L2yAUT1MjApPx6lNJmva+45 uoSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Dg0jS/e6KyZQfSlGUUgaQ9gBLRxQL95NBWNKL/lRFIQ=; b=aAD1XXSXPOwg/7Ogj5hHKcHI++JjMDWdU2AbFvF72ibtL4mfEZEkvqT44Why6VFrzn LNjP0cd1nb5pcTFLIW/cb41JVoZt1OcZXpS7M5p43qxoic3FWW+M+SIFN0FTZ3T4w6PF n6zhZ/+60CPQt/XgN0rlkAGoe8NlXWuf+OYwCrIjpcTGb5+DKNzK3VidUcYHIAG3WF1B OcBybfFTm70Leif3XF4LbtL7ngt5891J+IlijW9l19k5nknGmUkQM8SlBMv9XoTIO45u Gw4VXLspvFEvDf28yvNtsJ4svuVUsKB7AxEpCFFh2Zo8qGSg3UCZKKJr2YK+V0oJpEk6 iIjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Z5Tj96r/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si18857164plr.376.2019.04.24.07.36.55; Wed, 24 Apr 2019 07:37:11 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="Z5Tj96r/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731363AbfDXOfY (ORCPT + 99 others); Wed, 24 Apr 2019 10:35:24 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45841 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731322AbfDXOfR (ORCPT ); Wed, 24 Apr 2019 10:35:17 -0400 Received: by mail-lj1-f196.google.com with SMTP id y6so17079372ljd.12; Wed, 24 Apr 2019 07:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Dg0jS/e6KyZQfSlGUUgaQ9gBLRxQL95NBWNKL/lRFIQ=; b=Z5Tj96r/vtMbuAq0GpwwChB4HPVtU9C2E+BY6DZEtTSlxrGzQmHCLgN5XqCsQ5n1sm ued5wfSpySFJPN2UckkJLRwUIHQSBdkECYVoNNwmHowgOMctFRGzCHDwLSIcrn0mjAVh apQ62RuB6tm+yq8KODPVlEDBb/bQE1nZhI14pwzrCaYK9aKb6W2wbOCiTVQMcuTe+ckt Qo74QfhLhOQzuAsuGhDyOwb0envbiEhSCc0Nv6owgIG/NC7ID0KyxsWSfx1baH/jsAmY Qn6W86v2Tlm4i4ISuDZE/Xcao2PCtfk2pq0cNWg5SH3qqCAPibD147ntzbPxgJiYdAGM ljYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Dg0jS/e6KyZQfSlGUUgaQ9gBLRxQL95NBWNKL/lRFIQ=; b=tT9TAUcNsqQhQFrOKX1vUHKNdjczR4coVGDDABcMqbnDMnX3nudWPvdSgq1rYhbcZg nHrGDKoZO+GcSh8gZcaFpKHrZFNzOns0H3+1cSmWFeLzjcws9VAXNJ9QXcXSBZqetUbc q/+n8oOTHTTzOxbAoPJBEEulQeWNDygUyIoXdRmUKzeojcKJURyAaHBpUyPfI8Hw9beR dU5ZuydUkJhy2PP3OmUU75YFHHf6XM/2iRWpsF26XS/LTh2+LkjBFGfg2zdJYMqgdV5O NwSZV0k7S0Ywc7eQ158BIXBnthNvaFIwkFCOnR/aGDJnAH5j7CKuvS+txpDGhc1G/xNk dB0A== X-Gm-Message-State: APjAAAUhDp5qMkRM4SPmFaHJnlWeqMCbSoozeeh+5mxnfi6XRAl+aZfI 5bN/iuVWfCSnmwkK7qINiWU= X-Received: by 2002:a2e:89da:: with SMTP id c26mr17341237ljk.186.1556116514540; Wed, 24 Apr 2019 07:35:14 -0700 (PDT) Received: from mobilestation ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id j13sm591869lfb.34.2019.04.24.07.35.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Apr 2019 07:35:13 -0700 (PDT) Date: Wed, 24 Apr 2019 17:35:11 +0300 From: Serge Semin To: Mike Rapoport Cc: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/12] mips: Print the kernel virtual mem layout on debugging Message-ID: <20190424143510.ahzq2hpdje7iddzm@mobilestation> References: <20190423224748.3765-1-fancer.lancer@gmail.com> <20190423224748.3765-11-fancer.lancer@gmail.com> <20190424134711.GE6278@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190424134711.GE6278@rapoport-lnx> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 24, 2019 at 04:47:11PM +0300, Mike Rapoport wrote: > On Wed, Apr 24, 2019 at 01:47:46AM +0300, Serge Semin wrote: > > It is useful at least for debugging to have the kernel virtual > > memory layout printed at boot time so to have the full information > > about the booted kernel. Make the printing optional and available > > only when DEBUG_KERNEL config is enabled so not to leak a sensitive > > kernel information. > > > > Signed-off-by: Serge Semin > > --- > > arch/mips/mm/init.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 49 insertions(+) > > > > diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c > > index bbb196ad5f26..c338bbd03b2a 100644 > > --- a/arch/mips/mm/init.c > > +++ b/arch/mips/mm/init.c > > @@ -31,6 +31,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -56,6 +57,53 @@ unsigned long empty_zero_page, zero_page_mask; > > EXPORT_SYMBOL_GPL(empty_zero_page); > > EXPORT_SYMBOL(zero_page_mask); > > > > +/* > > + * Print out the kernel virtual memory layout > > + */ > > +#define MLK(b, t) (void *)b, (void *)t, ((t) - (b)) >> 10 > > +#define MLM(b, t) (void *)b, (void *)t, ((t) - (b)) >> 20 > > +#define MLK_ROUNDUP(b, t) (void *)b, (void *)t, DIV_ROUND_UP(((t) - (b)), SZ_1K) > > +static void __init mem_print_kmap_info(void) > > +{ > > +#ifdef CONFIG_DEBUG_KERNEL > > Maybe CONFIG_DEBUG_VM? > Last time I posted this patch Matt suggested to use CONFIG_DEBUG_KERNEL [1]. On the other hand arm platform prints this table unconditionally, but uses %lx format for low-memory ranges and %p for kernel segments. I even more inclined in the arm solution. But if selecting between DEBUG_KERNEL and DEBUG_VM I'd stick with DEBUG_KERNEL, since VM-debug config help text states it is intended for special performance checks: "Enable this to turn on extended checks in the virtual-memory system that may impact performance," and not for memory layout. -Sergey [1] https://lkml.org/lkml/2018/2/13/494 > > + pr_notice("Kernel virtual memory layout:\n" > > + " lowmem : 0x%px - 0x%px (%4ld MB)\n" > > + " .text : 0x%px - 0x%px (%4td kB)\n" > > + " .data : 0x%px - 0x%px (%4td kB)\n" > > + " .init : 0x%px - 0x%px (%4td kB)\n" > > + " .bss : 0x%px - 0x%px (%4td kB)\n" > > + " vmalloc : 0x%px - 0x%px (%4ld MB)\n" > > +#ifdef CONFIG_HIGHMEM > > + " pkmap : 0x%px - 0x%px (%4ld MB)\n" > > +#endif > > + " fixmap : 0x%px - 0x%px (%4ld kB)\n", > > + MLM(PAGE_OFFSET, (unsigned long)high_memory), > > + MLK_ROUNDUP(_text, _etext), > > + MLK_ROUNDUP(_sdata, _edata), > > + MLK_ROUNDUP(__init_begin, __init_end), > > + MLK_ROUNDUP(__bss_start, __bss_stop), > > + MLM(VMALLOC_START, VMALLOC_END), > > +#ifdef CONFIG_HIGHMEM > > + MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE)), > > +#endif > > + MLK(FIXADDR_START, FIXADDR_TOP)); > > + > > + /* Check some fundamental inconsistencies. May add something else? */ > > +#ifdef CONFIG_HIGHMEM > > + BUILD_BUG_ON(VMALLOC_END < PAGE_OFFSET); > > + BUG_ON(VMALLOC_END < (unsigned long)high_memory); > > + BUILD_BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) < PAGE_OFFSET); > > + BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) < > > + (unsigned long)high_memory); > > +#endif > > + BUILD_BUG_ON(FIXADDR_TOP < PAGE_OFFSET); > > + BUG_ON(FIXADDR_TOP < (unsigned long)high_memory); > > +#endif /* CONFIG_DEBUG_KERNEL */ > > +} > > +#undef MLK > > +#undef MLM > > +#undef MLK_ROUNDUP > > + > > /* > > * Not static inline because used by IP27 special magic initialization code > > */ > > @@ -479,6 +527,7 @@ void __init mem_init(void) > > setup_zero_pages(); /* Setup zeroed pages. */ > > mem_init_free_highmem(); > > mem_init_print_info(NULL); > > + mem_print_kmap_info(); > > > > #ifdef CONFIG_64BIT > > if ((unsigned long) &_text > (unsigned long) CKSEG0) > > -- > > 2.21.0 > > > > -- > Sincerely yours, > Mike. >