Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1154638ybl; Wed, 4 Dec 2019 18:17:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyo9HTBt7wWDWpr3MeaBDimvdG1Hh1eDWbeHCrL2F8jpq25vNLE3IKs++c1bi4xzWicMql7 X-Received: by 2002:aca:c256:: with SMTP id s83mr4563666oif.57.1575512250465; Wed, 04 Dec 2019 18:17:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575512250; cv=none; d=google.com; s=arc-20160816; b=Myx/ePaEw4mAU4T0F0MNuKF1+KDoag1kxlKzFkO26GS5P7zIEuXX/dZNbJeo+Q3ln2 RF+ORR/orC9qaqzFlCHwuOBSYWJY+nPEcInXdI7yJceGaivH5+TWDF1wCM9U7B93oo0X VvYiftV5/QhZZKdLXDjomQ0NKwstsNyd7keG69iC/AOxx9J1TPbDH7LbzI8qMJdGFZGo cxoDO7fLFV0u1xhIwG8dT0VoRPTl+86V6p9had43N1Eq6e14PKKKK/9Z/HMGhiG7v6rx mkxBNuihrvHcFXHuEgs1ZBrpvM+0UAx74w9woHnk2Ret57P4liN0TTYV4DADrIIj9dez Vx2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=KtO1tDSTxwA9TicalHRU+++zDzAJJ8Cc5xD7eilP+WI=; b=EnqMBfw8c/60txvx6+Np5yZh6PwjJiGhaggyn0yI86IBc/TedMMLWrBw8NQc+5qFEI klRMGmnYIrxnkJzlaP4tTJjjy2FDmXMexjHoSgW2KjTeXVm1fZv+F0fyaFTk1MCrmbRW 6Vz6tCVdL7JywvnQuYf9WfNF8EjEALgCNWjJVMiWoKSq/xXhYSnSOhGEwp6ZD0FaOtpt IVfs7xVpKrHheZip+JRK97J50dipzggFR4/Osu9EBjj5A+IA3whANM6CsJbahtTxDk4I 3ax7HwIvePhlh2q6W/CXKvcmyWnUYQF5Oshi1vOJVpP9n079tYw5silNez16uUpJYEz1 jPPQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d95si4404948otb.258.2019.12.04.18.17.18; Wed, 04 Dec 2019 18:17:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728916AbfLECPv (ORCPT + 99 others); Wed, 4 Dec 2019 21:15:51 -0500 Received: from mga02.intel.com ([134.134.136.20]:44510 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbfLECPu (ORCPT ); Wed, 4 Dec 2019 21:15:50 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2019 18:15:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,279,1571727600"; d="scan'208";a="263147679" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by FMSMGA003.fm.intel.com with ESMTP; 04 Dec 2019 18:15:48 -0800 From: Wei Yang To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: richard.weiyang@gmail.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.or, tglx@linutronix.de, Wei Yang Subject: [Patch v2 4/6] x86/mm: Refine debug print string retrieval function Date: Thu, 5 Dec 2019 10:14:01 +0800 Message-Id: <20191205021403.25606-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191205021403.25606-1-richardw.yang@linux.intel.com> References: <20191205021403.25606-1-richardw.yang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 const char *page_size_string(struct map_range *mr) +static void __meminit mr_print(struct map_range *mr, unsigned int maxidx) { - static const char str_1g[] = "1G"; - static const char str_2m[] = "2M"; - static const char str_4m[] = "4M"; - static const char str_4k[] = "4k"; - - if (mr->page_size_mask & (1U<page_size_mask & (1U<page_size_mask & (1U<page_size_mask >> PG_LEVEL_2M) & (ARRAY_SIZE(sz) - 1); + pr_debug(" [mem %#010lx-%#010lx] page size %s\n", + mr->start, mr->end - 1, sz[s]); + } } static int __meminit split_mem_range(struct map_range *mr, @@ -425,11 +416,7 @@ static int __meminit split_mem_range(struct map_range *mr, nr_range--; } - for (i = 0; i < nr_range; i++) - pr_debug(" [mem %#010lx-%#010lx] page %s\n", - mr[i].start, mr[i].end - 1, - page_size_string(&mr[i])); - + mr_print(mr, nr_range); return nr_range; } -- 2.17.1