Commit 9d1e24928e6a0728d1c7c76818ccbd11b93e7ac9
1 parent
c196f76fd5
Exists in
master
and in
4 other branches
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>
Showing 3 changed files with 21 additions and 3 deletions Side-by-side Diff
arch/sparc/mm/init_64.c
... | ... | @@ -820,7 +820,7 @@ |
820 | 820 | struct pglist_data *p; |
821 | 821 | |
822 | 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 | 824 | if (!paddr) { |
825 | 825 | prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); |
826 | 826 | prom_halt(); |
... | ... | @@ -840,7 +840,7 @@ |
840 | 840 | if (p->node_spanned_pages) { |
841 | 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 | 844 | if (!paddr) { |
845 | 845 | prom_printf("Cannot allocate bootmap for nid[%d]\n", |
846 | 846 | nid); |
include/linux/memblock.h
... | ... | @@ -50,7 +50,11 @@ |
50 | 50 | /* The numa aware allocator is only available if |
51 | 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 | 58 | extern phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align); |
55 | 59 | |
56 | 60 | /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ |
mm/memblock.c
... | ... | @@ -537,8 +537,22 @@ |
537 | 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 | 549 | return memblock_alloc(size, align); |
541 | 550 | } |
551 | + | |
552 | + | |
553 | +/* | |
554 | + * Remaining API functions | |
555 | + */ | |
542 | 556 | |
543 | 557 | /* You must call memblock_analyze() before this. */ |
544 | 558 | phys_addr_t __init memblock_phys_mem_size(void) |