x86-64, NUMA: Seperate out numa_alloc_distance() from numa_set_distance()
Alloc code is much bigger the distance setting. Separate it out into numa_alloc_distance() for readability. -v2: Let alloc_numa_distance to return -ENOMEM on failing path, requested by tj. -tj: Description update. Minor tweaks including function name, location and return value check. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
90e6b677b4
commit
2bf50555b0
@ -401,19 +401,8 @@ void __init numa_reset_distance(void)
|
|||||||
numa_distance = NULL;
|
numa_distance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int __init numa_alloc_distance(void)
|
||||||
* numa_set_distance - Set NUMA distance from one NUMA to another
|
|
||||||
* @from: the 'from' node to set distance
|
|
||||||
* @to: the 'to' node to set distance
|
|
||||||
* @distance: NUMA distance
|
|
||||||
*
|
|
||||||
* Set the distance from node @from to @to to @distance. If distance table
|
|
||||||
* doesn't exist, one which is large enough to accomodate all the currently
|
|
||||||
* known nodes will be created.
|
|
||||||
*/
|
|
||||||
void __init numa_set_distance(int from, int to, int distance)
|
|
||||||
{
|
{
|
||||||
if (!numa_distance) {
|
|
||||||
nodemask_t nodes_parsed;
|
nodemask_t nodes_parsed;
|
||||||
size_t size;
|
size_t size;
|
||||||
int i, j, cnt = 0;
|
int i, j, cnt = 0;
|
||||||
@ -427,14 +416,13 @@ void __init numa_set_distance(int from, int to, int distance)
|
|||||||
cnt = i;
|
cnt = i;
|
||||||
size = ++cnt * sizeof(numa_distance[0]);
|
size = ++cnt * sizeof(numa_distance[0]);
|
||||||
|
|
||||||
phys = memblock_find_in_range(0,
|
phys = memblock_find_in_range(0, (u64)max_pfn_mapped << PAGE_SHIFT,
|
||||||
(u64)max_pfn_mapped << PAGE_SHIFT,
|
|
||||||
size, PAGE_SIZE);
|
size, PAGE_SIZE);
|
||||||
if (phys == MEMBLOCK_ERROR) {
|
if (phys == MEMBLOCK_ERROR) {
|
||||||
pr_warning("NUMA: Warning: can't allocate distance table!\n");
|
pr_warning("NUMA: Warning: can't allocate distance table!\n");
|
||||||
/* don't retry until explicitly reset */
|
/* don't retry until explicitly reset */
|
||||||
numa_distance = (void *)1LU;
|
numa_distance = (void *)1LU;
|
||||||
return;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memblock_x86_reserve_range(phys, phys + size, "NUMA DIST");
|
memblock_x86_reserve_range(phys, phys + size, "NUMA DIST");
|
||||||
|
|
||||||
@ -447,8 +435,25 @@ void __init numa_set_distance(int from, int to, int distance)
|
|||||||
numa_distance[i * cnt + j] = i == j ?
|
numa_distance[i * cnt + j] = i == j ?
|
||||||
LOCAL_DISTANCE : REMOTE_DISTANCE;
|
LOCAL_DISTANCE : REMOTE_DISTANCE;
|
||||||
printk(KERN_DEBUG "NUMA: Initialized distance table, cnt=%d\n", cnt);
|
printk(KERN_DEBUG "NUMA: Initialized distance table, cnt=%d\n", cnt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* numa_set_distance - Set NUMA distance from one NUMA to another
|
||||||
|
* @from: the 'from' node to set distance
|
||||||
|
* @to: the 'to' node to set distance
|
||||||
|
* @distance: NUMA distance
|
||||||
|
*
|
||||||
|
* Set the distance from node @from to @to to @distance. If distance table
|
||||||
|
* doesn't exist, one which is large enough to accomodate all the currently
|
||||||
|
* known nodes will be created.
|
||||||
|
*/
|
||||||
|
void __init numa_set_distance(int from, int to, int distance)
|
||||||
|
{
|
||||||
|
if (!numa_distance && numa_alloc_distance() < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (from >= numa_distance_cnt || to >= numa_distance_cnt) {
|
if (from >= numa_distance_cnt || to >= numa_distance_cnt) {
|
||||||
printk_once(KERN_DEBUG "NUMA: Debug: distance out of bound, from=%d to=%d distance=%d\n",
|
printk_once(KERN_DEBUG "NUMA: Debug: distance out of bound, from=%d to=%d distance=%d\n",
|
||||||
from, to, distance);
|
from, to, distance);
|
||||||
|
Loading…
Reference in New Issue
Block a user