Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d1e2492 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt
Browse files

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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent c196f76f
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -820,7 +820,7 @@ static void __init allocate_node_data(int nid)
	struct pglist_data *p;
	struct pglist_data *p;


#ifdef CONFIG_NEED_MULTIPLE_NODES
#ifdef CONFIG_NEED_MULTIPLE_NODES
	paddr = memblock_alloc_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid);
	paddr = memblock_alloc_try_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid);
	if (!paddr) {
	if (!paddr) {
		prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid);
		prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid);
		prom_halt();
		prom_halt();
@@ -840,7 +840,7 @@ static void __init allocate_node_data(int nid)
	if (p->node_spanned_pages) {
	if (p->node_spanned_pages) {
		num_pages = bootmem_bootmap_pages(p->node_spanned_pages);
		num_pages = bootmem_bootmap_pages(p->node_spanned_pages);


		paddr = memblock_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid);
		paddr = memblock_alloc_try_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid);
		if (!paddr) {
		if (!paddr) {
			prom_printf("Cannot allocate bootmap for nid[%d]\n",
			prom_printf("Cannot allocate bootmap for nid[%d]\n",
				  nid);
				  nid);
+5 −1
Original line number Original line Diff line number Diff line
@@ -50,7 +50,11 @@ extern long __init memblock_reserve(phys_addr_t base, phys_addr_t size);
/* The numa aware allocator is only available if
/* The numa aware allocator is only available if
 * CONFIG_ARCH_POPULATES_NODE_MAP is set
 * CONFIG_ARCH_POPULATES_NODE_MAP is set
 */
 */
extern phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
extern phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align,
					int nid);
extern phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align,
					    int nid);

extern phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align);
extern phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align);


/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
+14 −0
Original line number Original line Diff line number Diff line
@@ -537,9 +537,23 @@ phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int n
			return ret;
			return ret;
	}
	}


	return 0;
}

phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
{
	phys_addr_t res = memblock_alloc_nid(size, align, nid);

	if (res)
		return res;
	return memblock_alloc(size, align);
	return memblock_alloc(size, align);
}
}



/*
 * Remaining API functions
 */

/* You must call memblock_analyze() before this. */
/* You must call memblock_analyze() before this. */
phys_addr_t __init memblock_phys_mem_size(void)
phys_addr_t __init memblock_phys_mem_size(void)
{
{