linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown()
Date: Fri, 17 Feb 2017 22:30:33 +0800	[thread overview]
Message-ID: <20170217143033.95412-1-richard.weiyang@gmail.com> (raw)

In case (last_start <= step_size), start is for sure to be 0. So, it is
save to do the round_down for all cases and set start to map_start when
start is smaller than map_start.

>From the performance point of view, this also reduces the check on each
iteration.

This patch unifies the code on round_down memory range in
memory_map_top_doown() and also removes a redundant assignment of start
which will be assigned the correct value in each iteration.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 arch/x86/mm/init.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 22af912d66d2..d8ad5e825b10 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -514,7 +514,7 @@ static void __init memory_map_top_down(unsigned long map_start,
 	step_size = PMD_SIZE;
 	max_pfn_mapped = 0; /* will get exact value next */
 	min_pfn_mapped = real_end >> PAGE_SHIFT;
-	last_start = start = real_end;
+	last_start = real_end;
 
 	/*
 	 * We start from the top (end of memory) and go to the bottom.
@@ -523,12 +523,10 @@ static void __init memory_map_top_down(unsigned long map_start,
 	 * for page table.
 	 */
 	while (last_start > map_start) {
-		if (last_start > step_size) {
-			start = round_down(last_start - 1, step_size);
-			if (start < map_start)
-				start = map_start;
-		} else
+		start = round_down(last_start - 1, step_size);
+		if (start < map_start)
 			start = map_start;
+
 		mapped_ram_size += init_range_memory_mapping(start,
 							last_start);
 		last_start = start;
-- 
2.11.0

             reply	other threads:[~2017-02-17 14:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 14:30 Wei Yang [this message]
2017-03-13 18:50 ` [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown() Borislav Petkov
2017-03-14  3:56   ` Wei Yang
2017-03-20  2:26     ` Wei Yang
2017-05-02 13:26     ` Wei Yang
2017-08-03  7:12       ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170217143033.95412-1-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).