diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-07-06 18:39:17 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-08-04 22:56:24 -0400 |
commit | 9d1e24928e6a0728d1c7c76818ccbd11b93e7ac9 (patch) | |
tree | f2c7173d47bf973d1a42ee249760b1c74d917009 | |
parent | c196f76fd5ece716ee3b7fa5dda3576961c0cecc (diff) |
memblock: Separate memblock_alloc_nid() and memblock_alloc_try_nid()
The former is now strict, it will fail if it cannot honor the allocation
within the node, while the later implements the previous semantic which
falls back to allocating anywhere.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/sparc/mm/init_64.c | 4 | ||||
-rw-r--r-- | include/linux/memblock.h | 6 | ||||
-rw-r--r-- | mm/memblock.c | 14 |
3 files changed, 21 insertions, 3 deletions
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 0883113624b9..dc584d26d597 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -820,7 +820,7 @@ static void __init allocate_node_data(int nid) | |||
820 | struct pglist_data *p; | 820 | struct pglist_data *p; |
821 | 821 | ||
822 | #ifdef CONFIG_NEED_MULTIPLE_NODES | 822 | #ifdef CONFIG_NEED_MULTIPLE_NODES |
823 | paddr = memblock_alloc_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid); | 823 | paddr = memblock_alloc_try_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid); |
824 | if (!paddr) { | 824 | if (!paddr) { |
825 | prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); | 825 | prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); |
826 | prom_halt(); | 826 | prom_halt(); |
@@ -840,7 +840,7 @@ static void __init allocate_node_data(int nid) | |||
840 | if (p->node_spanned_pages) { | 840 | if (p->node_spanned_pages) { |
841 | num_pages = bootmem_bootmap_pages(p->node_spanned_pages); | 841 | num_pages = bootmem_bootmap_pages(p->node_spanned_pages); |
842 | 842 | ||
843 | paddr = memblock_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid); | 843 | paddr = memblock_alloc_try_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid); |
844 | if (!paddr) { | 844 | if (!paddr) { |
845 | prom_printf("Cannot allocate bootmap for nid[%d]\n", | 845 | prom_printf("Cannot allocate bootmap for nid[%d]\n", |
846 | nid); | 846 | nid); |
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 82b030244aa7..c8da03eb7ba3 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -50,7 +50,11 @@ extern long __init memblock_reserve(phys_addr_t base, phys_addr_t size); | |||
50 | /* The numa aware allocator is only available if | 50 | /* The numa aware allocator is only available if |
51 | * CONFIG_ARCH_POPULATES_NODE_MAP is set | 51 | * CONFIG_ARCH_POPULATES_NODE_MAP is set |
52 | */ | 52 | */ |
53 | extern phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); | 53 | extern phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, |
54 | int nid); | ||
55 | extern phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, | ||
56 | int nid); | ||
57 | |||
54 | extern phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align); | 58 | extern phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align); |
55 | 59 | ||
56 | /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ | 60 | /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ |
diff --git a/mm/memblock.c b/mm/memblock.c index af7e4d9cf400..1802d97c7284 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -537,9 +537,23 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n | |||
537 | return ret; | 537 | return ret; |
538 | } | 538 | } |
539 | 539 | ||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid) | ||
544 | { | ||
545 | phys_addr_t res = memblock_alloc_nid(size, align, nid); | ||
546 | |||
547 | if (res) | ||
548 | return res; | ||
540 | return memblock_alloc(size, align); | 549 | return memblock_alloc(size, align); |
541 | } | 550 | } |
542 | 551 | ||
552 | |||
553 | /* | ||
554 | * Remaining API functions | ||
555 | */ | ||
556 | |||
543 | /* You must call memblock_analyze() before this. */ | 557 | /* You must call memblock_analyze() before this. */ |
544 | phys_addr_t __init memblock_phys_mem_size(void) | 558 | phys_addr_t __init memblock_phys_mem_size(void) |
545 | { | 559 | { |