Skip to content

Commit 7fb0bc3

Browse files
committed
memblock: Implement memblock_add_node()
Implement memblock_add_node() which can add a new memblock memory region with specific node ID. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Yinghai Lu <yinghai@kernel.org>
1 parent 1aadc05 commit 7fb0bc3

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎include/linux/memblock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int memblock_free_reserved_regions(void);
5252
int memblock_reserve_reserved_regions(void);
5353

5454
void memblock_allow_resize(void);
55+
int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
5556
int memblock_add(phys_addr_t base, phys_addr_t size);
5657
int memblock_remove(phys_addr_t base, phys_addr_t size);
5758
int memblock_free(phys_addr_t base, phys_addr_t size);

‎mm/memblock.c‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type,
324324
* @type: memblock type to add new region into
325325
* @base: base address of the new region
326326
* @size: size of the new region
327+
* @nid: nid of the new region
327328
*
328329
* Add new memblock region [@base,@base+@size) into @type. The new region
329330
* is allowed to overlap with existing ones - overlaps don't affect already
@@ -334,7 +335,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type,
334335
* 0 on success, -errno on failure.
335336
*/
336337
static int __init_memblock memblock_add_region(struct memblock_type *type,
337-
phys_addr_t base, phys_addr_t size)
338+
phys_addr_t base, phys_addr_t size, int nid)
338339
{
339340
bool insert = false;
340341
phys_addr_t obase = base;
@@ -346,7 +347,7 @@ static int __init_memblock memblock_add_region(struct memblock_type *type,
346347
WARN_ON(type->cnt != 1 || type->total_size);
347348
type->regions[0].base = base;
348349
type->regions[0].size = size;
349-
memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
350+
memblock_set_region_node(&type->regions[0], nid);
350351
type->total_size = size;
351352
return 0;
352353
}
@@ -376,7 +377,7 @@ static int __init_memblock memblock_add_region(struct memblock_type *type,
376377
nr_new++;
377378
if (insert)
378379
memblock_insert_region(type, i++, base,
379-
rbase - base, MAX_NUMNODES);
380+
rbase - base, nid);
380381
}
381382
/* area below @rend is dealt with, forget about it */
382383
base = min(rend, end);
@@ -386,8 +387,7 @@ static int __init_memblock memblock_add_region(struct memblock_type *type,
386387
if (base < end) {
387388
nr_new++;
388389
if (insert)
389-
memblock_insert_region(type, i, base, end - base,
390-
MAX_NUMNODES);
390+
memblock_insert_region(type, i, base, end - base, nid);
391391
}
392392

393393
/*
@@ -406,9 +406,15 @@ static int __init_memblock memblock_add_region(struct memblock_type *type,
406406
}
407407
}
408408

409+
int __init_memblock memblock_add_node(phys_addr_t base, phys_addr_t size,
410+
int nid)
411+
{
412+
return memblock_add_region(&memblock.memory, base, size, nid);
413+
}
414+
409415
int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)
410416
{
411-
return memblock_add_region(&memblock.memory, base, size);
417+
return memblock_add_region(&memblock.memory, base, size, MAX_NUMNODES);
412418
}
413419

414420
/**
@@ -522,7 +528,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
522528
(void *)_RET_IP_);
523529
BUG_ON(0 == size);
524530

525-
return memblock_add_region(_rgn, base, size);
531+
return memblock_add_region(_rgn, base, size, MAX_NUMNODES);
526532
}
527533

528534
/**

0 commit comments

Comments
 (0)