Skip to content

Commit 74a5ed5

Browse files
thomastaioracledavem330
authored andcommitted
sparc64: Fix find_node warning if numa node cannot be found
When booting up LDOM, find_node() warns that a physical address doesn't match a NUMA node. WARNING: CPU: 0 PID: 0 at arch/sparc/mm/init_64.c:835 find_node+0xf4/0x120 find_node: A physical address doesn't match a NUMA node rule. Some physical memory will be owned by node 0.Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 4.9.0-rc3 #4 Call Trace: [0000000000468ba0] __warn+0xc0/0xe0 [0000000000468c74] warn_slowpath_fmt+0x34/0x60 [00000000004592f4] find_node+0xf4/0x120 [0000000000dd0774] add_node_ranges+0x38/0xe4 [0000000000dd0b1c] numa_parse_mdesc+0x268/0x2e4 [0000000000dd0e9c] bootmem_init+0xb8/0x160 [0000000000dd174c] paging_init+0x808/0x8fc [0000000000dcb0d0] setup_arch+0x2c8/0x2f0 [0000000000dc68a0] start_kernel+0x48/0x424 [0000000000dcb374] start_early_boot+0x27c/0x28c [0000000000a32c08] tlb_fixup_done+0x4c/0x64 [0000000000027f08] 0x27f08 It is because linux use an internal structure node_masks[] to keep the best memory latency node only. However, LDOM mdesc can contain single latency-group with multiple memory latency nodes. If the address doesn't match the best latency node within node_masks[], it should check for an alternative via mdesc. The warning message should only be printed if the address doesn't match any node_masks[] nor within mdesc. To minimize the impact of searching mdesc every time, the last matched mask and index is stored in a variable. Signed-off-by: Thomas Tai <[email protected]> Reviewed-by: Chris Hyser <[email protected]> Reviewed-by: Liam Merwick <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 27bcd37 commit 74a5ed5

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

arch/sparc/mm/init_64.c

+61-4
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ struct mdesc_mblock {
802802
};
803803
static struct mdesc_mblock *mblocks;
804804
static int num_mblocks;
805+
static int find_numa_node_for_addr(unsigned long pa,
806+
struct node_mem_mask *pnode_mask);
805807

806808
static unsigned long ra_to_pa(unsigned long addr)
807809
{
@@ -821,6 +823,9 @@ static unsigned long ra_to_pa(unsigned long addr)
821823

822824
static int find_node(unsigned long addr)
823825
{
826+
static bool search_mdesc = true;
827+
static struct node_mem_mask last_mem_mask = { ~0UL, ~0UL };
828+
static int last_index;
824829
int i;
825830

826831
addr = ra_to_pa(addr);
@@ -830,10 +835,27 @@ static int find_node(unsigned long addr)
830835
if ((addr & p->mask) == p->val)
831836
return i;
832837
}
833-
/* The following condition has been observed on LDOM guests.*/
834-
WARN_ONCE(1, "find_node: A physical address doesn't match a NUMA node"
835-
" rule. Some physical memory will be owned by node 0.");
836-
return 0;
838+
/* The following condition has been observed on LDOM guests because
839+
* node_masks only contains the best latency mask and value.
840+
* LDOM guest's mdesc can contain a single latency group to
841+
* cover multiple address range. Print warning message only if the
842+
* address cannot be found in node_masks nor mdesc.
843+
*/
844+
if ((search_mdesc) &&
845+
((addr & last_mem_mask.mask) != last_mem_mask.val)) {
846+
/* find the available node in the mdesc */
847+
last_index = find_numa_node_for_addr(addr, &last_mem_mask);
848+
numadbg("find_node: latency group for address 0x%lx is %d\n",
849+
addr, last_index);
850+
if ((last_index < 0) || (last_index >= num_node_masks)) {
851+
/* WARN_ONCE() and use default group 0 */
852+
WARN_ONCE(1, "find_node: A physical address doesn't match a NUMA node rule. Some physical memory will be owned by node 0.");
853+
search_mdesc = false;
854+
last_index = 0;
855+
}
856+
}
857+
858+
return last_index;
837859
}
838860

839861
static u64 memblock_nid_range(u64 start, u64 end, int *nid)
@@ -1160,6 +1182,41 @@ int __node_distance(int from, int to)
11601182
return numa_latency[from][to];
11611183
}
11621184

1185+
static int find_numa_node_for_addr(unsigned long pa,
1186+
struct node_mem_mask *pnode_mask)
1187+
{
1188+
struct mdesc_handle *md = mdesc_grab();
1189+
u64 node, arc;
1190+
int i = 0;
1191+
1192+
node = mdesc_node_by_name(md, MDESC_NODE_NULL, "latency-groups");
1193+
if (node == MDESC_NODE_NULL)
1194+
goto out;
1195+
1196+
mdesc_for_each_node_by_name(md, node, "group") {
1197+
mdesc_for_each_arc(arc, md, node, MDESC_ARC_TYPE_FWD) {
1198+
u64 target = mdesc_arc_target(md, arc);
1199+
struct mdesc_mlgroup *m = find_mlgroup(target);
1200+
1201+
if (!m)
1202+
continue;
1203+
if ((pa & m->mask) == m->match) {
1204+
if (pnode_mask) {
1205+
pnode_mask->mask = m->mask;
1206+
pnode_mask->val = m->match;
1207+
}
1208+
mdesc_release(md);
1209+
return i;
1210+
}
1211+
}
1212+
i++;
1213+
}
1214+
1215+
out:
1216+
mdesc_release(md);
1217+
return -1;
1218+
}
1219+
11631220
static int __init find_best_numa_node_for_mlgroup(struct mdesc_mlgroup *grp)
11641221
{
11651222
int i;

0 commit comments

Comments
 (0)