Thread (7 messages) flat view 7 messages, 3 authors, 2017-06-07

Re: [PATCH] powerpc/numa: Fix percpu allocations to be NUMA aware

From: Nicholas Piggin <npiggin@gmail.com>
Date: 2017-06-02 12:50:34

On Fri, 02 Jun 2017 19:54:32 +1000
Michael Ellerman [off-list ref] wrote:
quoted
quoted
@@ -672,10 +672,19 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
 
 static int pcpu_cpu_distance(unsigned int from, unsigned int to)
 {
-	if (cpu_to_node(from) == cpu_to_node(to))
-		return LOCAL_DISTANCE;
-	else
-		return REMOTE_DISTANCE;
+#ifndef CONFIG_NUMA
+	return LOCAL_DISTANCE;
+#else
+	int from_nid, to_nid;
+
+	from_nid = early_cpu_to_node(from);
+	to_nid   = early_cpu_to_node(to);
+
+	if (from_nid == -1 || to_nid == -1)
+		return LOCAL_DISTANCE;	/* Or assume remote? */
+
+	return node_distance(from_nid, to_nid);  
If you made node_distance() return LOCAL_NODE for !NUMA, this
should fall out and not require the ifdef?  
Maybe yeah. This is designed to be minimal for backporting though.
Okay fair enough. Is it expected to get back -1 from this ever? I think
all we need is local vs not local to direct whether to pack CPUs into
the same chunks or not so I wonder if the equality test is simpler.

Probably not a big deal though. Patch looks good as is.

Thanks,
Nick
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help