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

Nicholas Piggin npiggin at gmail.com
Fri Jun 2 22:50:16 AEST 2017


On Fri, 02 Jun 2017 19:54:32 +1000
Michael Ellerman <mpe at ellerman.id.au> wrote:

> >> @@ -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


More information about the Linuxppc-dev mailing list