diff mbox series

[1/2] powerpc/numa: Return the first online node instead of 0

Message ID 20220623125442.645240-1-aneesh.kumar@linux.ibm.com (mailing list archive)
State Changes Requested
Headers show
Series [1/2] powerpc/numa: Return the first online node instead of 0 | expand

Commit Message

Aneesh Kumar K V June 23, 2022, 12:54 p.m. UTC
If early cpu to node mapping finds an invalid node id, return
the first online node instead of node 0.

With commit e75130f20b1f ("powerpc/numa: Offline memoryless cpuless node 0")
the kernel marks node 0 offline in certain scenarios.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 arch/powerpc/include/asm/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Srikar Dronamraju June 24, 2022, 8:39 a.m. UTC | #1
* Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> [2022-06-23 18:24:41]:

> If early cpu to node mapping finds an invalid node id, return
> the first online node instead of node 0.
> 
> With commit e75130f20b1f ("powerpc/numa: Offline memoryless cpuless node 0")
> the kernel marks node 0 offline in certain scenarios.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/topology.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
> index 8a4d4f4d9749..704088b1d53c 100644
> --- a/arch/powerpc/include/asm/topology.h
> +++ b/arch/powerpc/include/asm/topology.h
> @@ -60,7 +60,7 @@ static inline int early_cpu_to_node(int cpu)
>  	 * Fall back to node 0 if nid is unset (it should be, except bugs).
>  	 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
>  	 */
> -	return (nid < 0) ? 0 : nid;
> +	return (nid < 0) ? first_online_node : nid;

Looks good but just two queries.

1. Is there a possibility of early_cpu_to_node() being called before any
node is online?

2. first_online_node is actually not a variable, it returns the lowest
online node. Right? If lets a early_cpu_to_node() for the same CPU across a
node online/offline may end up giving two different nids. Right?


>  }
> 
>  int of_drconf_to_nid_single(struct drmem_lmb *lmb);
> -- 
> 2.36.1
>
Aneesh Kumar K V June 27, 2022, 2:05 p.m. UTC | #2
Srikar Dronamraju <srikar@linux.vnet.ibm.com> writes:

> * Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> [2022-06-23 18:24:41]:
>
>> If early cpu to node mapping finds an invalid node id, return
>> the first online node instead of node 0.
>> 
>> With commit e75130f20b1f ("powerpc/numa: Offline memoryless cpuless node 0")
>> the kernel marks node 0 offline in certain scenarios.
>> 
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> ---
>>  arch/powerpc/include/asm/topology.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
>> index 8a4d4f4d9749..704088b1d53c 100644
>> --- a/arch/powerpc/include/asm/topology.h
>> +++ b/arch/powerpc/include/asm/topology.h
>> @@ -60,7 +60,7 @@ static inline int early_cpu_to_node(int cpu)
>>  	 * Fall back to node 0 if nid is unset (it should be, except bugs).
>>  	 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
>>  	 */
>> -	return (nid < 0) ? 0 : nid;
>> +	return (nid < 0) ? first_online_node : nid;
>
> Looks good but just two queries.
>
> 1. Is there a possibility of early_cpu_to_node() being called before any
> node is online?

The kernel operate with node 0 online most of the early boot and mark it offline
in mem_topology_setup() just before parse_numa_properties(). So we
should find some nodes set online.

>
> 2. first_online_node is actually not a variable, it returns the lowest
> online node. Right? If lets a early_cpu_to_node() for the same CPU across a
> node online/offline may end up giving two different nids. Right?
>

The change is specific to a case where we find uninitialized
numa_cpu_lookup_table. ie, the firmware didn't specify the mapping for
the cpu. I do agree that for such cpus the node mapping can change
because of the above. I am not sure whether this can cause any issue in
practice. But returning node 0 which can be marked offline can result
in crashes? 

>
>>  }
>> 
>>  int of_drconf_to_nid_single(struct drmem_lmb *lmb);
>> -- 
>> 2.36.1
>> 
>
> -- 
> Thanks and Regards
> Srikar Dronamraju
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 8a4d4f4d9749..704088b1d53c 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -60,7 +60,7 @@  static inline int early_cpu_to_node(int cpu)
 	 * Fall back to node 0 if nid is unset (it should be, except bugs).
 	 * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)).
 	 */
-	return (nid < 0) ? 0 : nid;
+	return (nid < 0) ? first_online_node : nid;
 }
 
 int of_drconf_to_nid_single(struct drmem_lmb *lmb);