aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2013-09-11 17:22:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:57:51 -0400
commite76b63f80d938a1319eb5fb0ae7ea69bddfbae38 (patch)
tree4480ea31ebd4cbae35fcf7fa75c834ab06e39ffd /mm/memblock.c
parent0bf598d863e3c741d47e3178d645f04c9d6c186c (diff)
memblock, numa: binary search node id
Current early_pfn_to_nid() on arch that support memblock go over memblock.memory one by one, so will take too many try near the end. We can use existing memblock_search to find the node id for given pfn, that could save some time on bigger system that have many entries memblock.memory array. Here are the timing differences for several machines. In each case with the patch less time was spent in __early_pfn_to_nid(). 3.11-rc5 with patch difference (%) -------- ---------- -------------- UV1: 256 nodes 9TB: 411.66 402.47 -9.19 (2.23%) UV2: 255 nodes 16TB: 1141.02 1138.12 -2.90 (0.25%) UV2: 64 nodes 2TB: 128.15 126.53 -1.62 (1.26%) UV2: 32 nodes 2TB: 121.87 121.07 -0.80 (0.66%) Time in seconds. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Tejun Heo <tj@kernel.org> Acked-by: Russ Anderson <rja@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index a847bfe6f3ba..0ac412a0a7ee 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -914,6 +914,24 @@ int __init_memblock memblock_is_memory(phys_addr_t addr)
914 return memblock_search(&memblock.memory, addr) != -1; 914 return memblock_search(&memblock.memory, addr) != -1;
915} 915}
916 916
917#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
918int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
919 unsigned long *start_pfn, unsigned long *end_pfn)
920{
921 struct memblock_type *type = &memblock.memory;
922 int mid = memblock_search(type, (phys_addr_t)pfn << PAGE_SHIFT);
923
924 if (mid == -1)
925 return -1;
926
927 *start_pfn = type->regions[mid].base >> PAGE_SHIFT;
928 *end_pfn = (type->regions[mid].base + type->regions[mid].size)
929 >> PAGE_SHIFT;
930
931 return type->regions[mid].nid;
932}
933#endif
934
917/** 935/**
918 * memblock_is_region_memory - check if a region is a subset of memory 936 * memblock_is_region_memory - check if a region is a subset of memory
919 * @base: base of region to check 937 * @base: base of region to check