linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, Michal Hocko <mhocko@suse.cz>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Minchan Kim <minchan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Gavin Shan <shangw@linux.vnet.ibm.com>,
	Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [PATCH 3/5] mm/memblock: reduce overhead in binary search
Date: Fri, 24 Aug 2012 22:33:38 +0800	[thread overview]
Message-ID: <1345818820-12102-3-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
In-Reply-To: <1345818820-12102-1-git-send-email-liwanp@linux.vnet.ibm.com>

From: Wanpeng Li <liwanp@linux.vnet.ibm.com>

When checking the indicated address belongs to the memory
or reserved region, the memory or reserved regions are checked
one by one through binary search, which would be a little
time consuming. If the indicated address isn't in memory
region, then we needn't do the time-sonsuming search. The
patch adds more check on the indicated address for that purpose.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/memblock.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 2feff8d..880e461 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -871,6 +871,10 @@ static int __init_memblock memblock_search(struct memblock_type *type, phys_addr
 {
 	unsigned int left = 0, right = type->cnt;
 
+	if (unlikely(addr < memblock_start_of_DRAM() ||
+		addr >= memblock_end_of_DRAM()))
+			return 0;
+
 	do {
 		unsigned int mid = (right + left) / 2;
 
-- 
1.7.5.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-08-24 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24 14:33 [PATCH 1/5] mm/memblock: truncate memblock if necessary Wanpeng Li
2012-08-24 14:33 ` [PATCH 2/5] mm/memblock: rename get_allocated_memblock_reserved_regions_info() Wanpeng Li
2012-08-24 15:39   ` Sam Ravnborg
2012-08-24 14:33 ` Wanpeng Li [this message]
2012-08-24 14:33 ` [PATCH 4/5] mm/memblock: use existing interface to set nid Wanpeng Li
2012-08-24 14:33 ` [PATCH 5/5] mm/memblock: cleanup early_node_map[] related comments Wanpeng Li

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=1345818820-12102-3-git-send-email-liwanp@linux.vnet.ibm.com \
    --to=liwanp@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=minchan@kernel.org \
    --cc=shangw@linux.vnet.ibm.com \
    /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).