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

Michael Ellerman mpe at ellerman.id.au
Tue Jun 6 20:05:19 AEST 2017


Nicholas Piggin <npiggin at gmail.com> writes:

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

Yeah you're right, I'll do a v2.

I think I was worried about the fact that our node_distance() does
complicated stuff for multi-level NUMA, but that doesn't actually matter
for the per-cpu calculation as you say so it's probably better to keep
it simple.

cheers


More information about the Linuxppc-dev mailing list