From: Wanpeng Li Date: Wed, 26 Sep 2012 01:33:47 +0000 (+1000) Subject: mm/memblock: reduce overhead in binary search X-Git-Tag: next-20120926~2^2~248 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ecfef4cbb88b062fb1d40b5e69db4796bc87627b;p=karo-tx-linux.git mm/memblock: reduce overhead in binary search 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 Cc: Michal Hocko Cc: KAMEZAWA Hiroyuki Cc: Minchan Kim Cc: Gavin Shan Cc: Yinghai Lu Signed-off-by: Andrew Morton --- diff --git a/mm/memblock.c b/mm/memblock.c index 82aa349d2f7a..d48985e533eb 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -888,6 +888,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; }