]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/memblock: reduce overhead in binary search
authorWanpeng Li <liwanp@linux.vnet.ibm.com>
Thu, 25 Oct 2012 01:14:54 +0000 (12:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 31 Oct 2012 05:49:48 +0000 (16:49 +1100)
When checking that the indicated address belongs to the memory region, the
memory regions are checked one by one through a binary search, which will
be time consuming.

If the indicated address isn't in the memory region, then we needn't do
the time-consuming search.  Add a check on the indicated address for that
purpose.

Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memblock.c

index 625905523c2a1592f539c46f6721723d62376648..10ea908fd555727a676147c347abbf805dfff8c8 100644 (file)
@@ -889,6 +889,11 @@ int __init memblock_is_reserved(phys_addr_t addr)
 
 int __init_memblock memblock_is_memory(phys_addr_t addr)
 {
+
+       if (unlikely(addr < memblock_start_of_DRAM() ||
+               addr >= memblock_end_of_DRAM()))
+               return 0;
+
        return memblock_search(&memblock.memory, addr) != -1;
 }