Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1440020ybl; Thu, 5 Dec 2019 01:14:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwEv3xOrTIMYMM+Il4SOpGfx65V5KSZrVmBmj2s51/Gw49K51hN+KAqpQZY7nUth4WqA9iz X-Received: by 2002:a9d:1ea9:: with SMTP id n38mr5489399otn.38.1575537243530; Thu, 05 Dec 2019 01:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575537243; cv=none; d=google.com; s=arc-20160816; b=MkqH1qNJunnN6zYx4gMM4+QroLM5sWXHGcBDfGtKqATgW3alcntLjyBpC5B5MUZ9fv Q8zchXXU4j12P3v/furzQ8MUUlT6PpSMhlBuIe8qd3Ro49zB7H64bUD3lokqj3PECp0A Fs/Lbb2Tu06Uc+foryiNZnwGQjg8WjvQMeNgwzJa76fhhGx2wmHRSOAfd6qfrYaYTeBz u9X1b2ITMTEeBv743QHReFLnmLNIdjUTUtjTnuM70lHNwL7XamcRuCy1ogUncNGFfTcN Qhz5lu/OYsoI8vlQWFc1OGw8uwMBdEy+6pi8rtRTkUG1x4cDPLdfaIAWsbfKemg9EwD/ LI0w== 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=9SKkEwleM0Kgl1HXUfSvMknCeedbxkFPyHrx58igVDY=; b=bXhp4Y+c1pqFnFalgkICU4Kjsz16GKcl3DoMORI8HioX6ZRUNp07e6/t0FwcAAZEbL Awq70fGROZU0NZmUve6DJBW/EDdEwI0XPzA+IsVaCcT6Z8EMkiuMk4H0VC1604jSqv/h 6PLQgysoPz/wfXHzQKoTOn40urPE9RulN/b5ZC8Hyx9b2rsdYcsuI8awlZSIPvoiH6T1 IrPM2JyYVoFcyQDnaE6qFQ3DYs70svojnv0C/8+YMIBHedZZEoDFwK5o1i1obWzmvgbT lCL6UFjpKyTMc1x2L0uk9oU3YrvP2v+LdTzWedFyjmu2G1Okskd+/65n2dGgr0VsSVve 517g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Ak2B3Pk9; 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 w17si2692591otp.185.2019.12.05.01.13.49; Thu, 05 Dec 2019 01:14:03 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Ak2B3Pk9; 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 S1728794AbfLEJNR (ORCPT + 99 others); Thu, 5 Dec 2019 04:13:17 -0500 Received: from merlin.infradead.org ([205.233.59.134]:40678 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfLEJNQ (ORCPT ); Thu, 5 Dec 2019 04:13:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9SKkEwleM0Kgl1HXUfSvMknCeedbxkFPyHrx58igVDY=; b=Ak2B3Pk9llVBxc4o4HhKJcqKX wYef7Nnmugzro6QjTQnYauxWqfalj8fK1zWN6rCNC37knhfi8WKM8NXtZZlxxPvZ6IfRSi8szXYbR 4HzSIc8QRSCvTIKdWAuKiTymcsvBYmGTYK6UI3bAGf18JMMa5jz09xr0vo8MIV6pm9ZnT3hvtmIYA zBYVxVDwhzOXLkhEb2RtxUftPc8p//eS1P1MnUta0Fq10BT+tGQxcoeONr+olR1qY8AjIJ0RzHuWq TphJUqFBa+GY4YTJ+xo7GDpLKw9NitH9wN7Ke6karckE9LHarfTG/AscHYEBbArBZfJwDHR0thI9M l5Un2m2lg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1icnCD-00029R-9b; Thu, 05 Dec 2019 09:13:13 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D651C3011E0; Thu, 5 Dec 2019 10:11:54 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 03AD120B8E996; Thu, 5 Dec 2019 10:13:11 +0100 (CET) Date: Thu, 5 Dec 2019 10:13:11 +0100 From: Peter Zijlstra To: Wei Yang Cc: x86@kernel.org, linux-kernel@vger.kernel.org, richard.weiyang@gmail.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.or, tglx@linutronix.de Subject: Re: [Patch v2 4/6] x86/mm: Refine debug print string retrieval function Message-ID: <20191205091311.GD2810@hirez.programming.kicks-ass.net> References: <20191205021403.25606-1-richardw.yang@linux.intel.com> <20191205021403.25606-5-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191205021403.25606-5-richardw.yang@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 05, 2019 at 10:14:01AM +0800, Wei Yang wrote: > Generally, the mapping page size are: > > 4K, 2M, 1G > > except in case 32-bit without PAE, the mapping page size are: > > 4K, 4M > > Based on PG_LEVEL_X definition and mr->page_size_mask, we can calculate > the mapping page size from a predefined string array. > > Signed-off-by: Wei Yang > --- > arch/x86/mm/init.c | 39 +++++++++++++-------------------------- > 1 file changed, 13 insertions(+), 26 deletions(-) > > diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c > index 0eb5edb63fa2..ded58a31c679 100644 > --- a/arch/x86/mm/init.c > +++ b/arch/x86/mm/init.c > @@ -308,29 +308,20 @@ static void __ref adjust_range_page_size_mask(struct map_range *mr, > } > } > > +static void __meminit mr_print(struct map_range *mr, unsigned int maxidx) > { > +#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) > + static const char *sz[2] = { "4K", "4M" }; > +#else > + static const char *sz[4] = { "4K", "2M", "1G", "" }; > +#endif > + unsigned int idx, s; > > + for (idx = 0; idx < maxidx; idx++, mr++) { > + s = (mr->page_size_mask >> PG_LEVEL_2M) & (ARRAY_SIZE(sz) - 1); Is it at all possible for !PAE to have 1G here, if you use the sz[4] definition unconditionally? > + pr_debug(" [mem %#010lx-%#010lx] page size %s\n", > + mr->start, mr->end - 1, sz[s]); > + } > }