Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3302187imj; Mon, 11 Feb 2019 18:15:48 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib47SFfSIokk5aoOBzxRbyUgnjlhYVLlHH0Wnrxd2D0Yh/ghKeLPX0V3ma8AsML6dmp0XbR X-Received: by 2002:a17:902:129:: with SMTP id 38mr1541117plb.140.1549937748147; Mon, 11 Feb 2019 18:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549937748; cv=none; d=google.com; s=arc-20160816; b=0P0Vota/zMp9zFh3XdseYUEVuxsYzh0eQXxXFH+UJ/cZJKUTrjxvUnEo185oT0Il0e Q3KgXBjONEW39k/vjKamXoXRGXEfk9TSmXAeTIN3r2QSlk574PBcrGX05TmDQIWvOru2 FDNn4u+93i/tFnzeKDwXERrWO4TJ4xAFis1iDZyooMy5YMeuPFaUbAR26mHNBkze7p2k 4Ti5bcGGML/jwxh+auNoo0x5xLTl99zkCtjBpkQdAngq6fR4HF7v/0azrsuIv5gRvfX1 gMVGTelA3JnmrPt0I3qZ6x4ZC9KJ1+KdHnjlaNIyqeNudBvnx+BSQM84k42Qm/7gV+xr zO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yfaYNE4fLgxPsONlRQlk6dCzfIyoDqGK1Lpb5rdWdQM=; b=lmip76y+cLR1AtxYTkbYcgI3vGYfX7Mh2sVakknk65wDCeD4lg9MMxWuTexPolc/4s ehcj7QRNRkX0/9z1+dr6QbVU5nKEOuJVL6nGUbvG+M9XIK9NduYNDntgHCCBvIf1yvvC NhpWaezeDkk8xrCxfviHCBycO6dR+tBOj3IW+5w+e/RSXCkt7003h5lY0oeAdHqDGolm iHzCMVd4i6YhdQkD9CE0amMCeDlCYmfb5jwpCpxEWl16w+g0jIH3WPwRQRdkkKrQtNnf snnb+UGOvOX2izH+4OMSI4nJUa/fgLXzyVswS8sIYyP8N1i4apqhZHG2RcgP/gT9XIvP peLA== 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 h8si9440904pgs.235.2019.02.11.18.15.32; Mon, 11 Feb 2019 18:15:48 -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 S1727890AbfBLCNA (ORCPT + 99 others); Mon, 11 Feb 2019 21:13:00 -0500 Received: from mga09.intel.com ([134.134.136.24]:26871 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbfBLCM5 (ORCPT ); Mon, 11 Feb 2019 21:12:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 18:12:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,361,1544515200"; d="scan'208";a="146057858" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 11 Feb 2019 18:12:56 -0800 From: Wei Yang To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.or, tglx@linutronix.de, Wei Yang Subject: [PATCH 4/6] x86, mm: make split_mem_range() more easy to read Date: Tue, 12 Feb 2019 10:12:13 +0800 Message-Id: <20190212021215.13247-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190212021215.13247-1-richardw.yang@linux.intel.com> References: <20190212021215.13247-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the comment explains, there are at most 5 possible ranges: kkkmmmGGGmmmkkk (A)(B)(C)(D)(E) While there are two ways to perceive: * C & D are extra ranges on X86_64 * B & C are extra ranges on X86_64 Current implementation takes the first way, which leads to handling end_pfn of B differently: * align to PMD on X86_32 * align to PUD on X86_64 If we take the second way, we don't need to handle it differently. * the end_pfn of B only need to align to PUD * the end_pfn of D only need to align to PMD This patch changes the implementation from the first perception to the second to reduce one different handling on end_pfn. After doing so, the code is easier to read. Signed-off-by: Wei Yang --- arch/x86/mm/init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 2b782dcd6d71..87275238dbb0 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -389,25 +389,21 @@ static int __meminit split_mem_range(struct map_range *mr, pfn = end_pfn; } +#ifdef CONFIG_X86_64 /* * Range (B): * big page (2M) range */ start_pfn = round_up(pfn, PFN_DOWN(PMD_SIZE)); -#ifdef CONFIG_X86_32 - end_pfn = round_down(limit_pfn, PFN_DOWN(PMD_SIZE)); -#else /* CONFIG_X86_64 */ end_pfn = round_up(pfn, PFN_DOWN(PUD_SIZE)); if (end_pfn > round_down(limit_pfn, PFN_DOWN(PMD_SIZE))) end_pfn = round_down(limit_pfn, PFN_DOWN(PMD_SIZE)); -#endif if (start_pfn < end_pfn) { nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, page_size_mask & (1<