[PATCH 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE

John Garry posted 4 patches 1 month ago
There is a newer version of this series
[PATCH 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
Posted by John Garry 1 month ago
The arch definition of cpumask_of_node() cannot handle NUMA_NO_NODE - which
is a valid index - so add a check for this.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 arch/loongarch/include/asm/topology.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
index f06e7ff25bb7c..9857e4c20023c 100644
--- a/arch/loongarch/include/asm/topology.h
+++ b/arch/loongarch/include/asm/topology.h
@@ -12,7 +12,9 @@
 
 extern cpumask_t cpus_on_node[];
 
-#define cpumask_of_node(node)  (&cpus_on_node[node])
+#define cpumask_of_node(node)  ((node) == NUMA_NO_NODE ?	\
+				cpu_all_mask :			\
+				&cpus_on_node[node])
 
 struct pci_bus;
 extern int pcibus_to_node(struct pci_bus *);
-- 
2.43.5
Re: [PATCH 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
Posted by Huacai Chen 1 month ago
Hi, John,

On Mon, Jan 5, 2026 at 6:07 PM John Garry <john.g.garry@oracle.com> wrote:
>
> The arch definition of cpumask_of_node() cannot handle NUMA_NO_NODE - which
> is a valid index - so add a check for this.
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>  arch/loongarch/include/asm/topology.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
> index f06e7ff25bb7c..9857e4c20023c 100644
> --- a/arch/loongarch/include/asm/topology.h
> +++ b/arch/loongarch/include/asm/topology.h
> @@ -12,7 +12,9 @@
>
>  extern cpumask_t cpus_on_node[];
>
> -#define cpumask_of_node(node)  (&cpus_on_node[node])
> +#define cpumask_of_node(node)  ((node) == NUMA_NO_NODE ?       \
> +                               cpu_all_mask :                  \
> +                               &cpus_on_node[node])
You can define it in one line, so does the MIPS version.

Huacai

>
>  struct pci_bus;
>  extern int pcibus_to_node(struct pci_bus *);
> --
> 2.43.5
>
Re: [PATCH 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
Posted by John Garry 1 month ago
On 05/01/2026 12:54, Huacai Chen wrote:
> Hi, John,
> 
> On Mon, Jan 5, 2026 at 6:07 PM John Garry <john.g.garry@oracle.com> wrote:
>>
>> The arch definition of cpumask_of_node() cannot handle NUMA_NO_NODE - which
>> is a valid index - so add a check for this.
>>
>> Signed-off-by: John Garry <john.g.garry@oracle.com>
>> ---
>>   arch/loongarch/include/asm/topology.h | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
>> index f06e7ff25bb7c..9857e4c20023c 100644
>> --- a/arch/loongarch/include/asm/topology.h
>> +++ b/arch/loongarch/include/asm/topology.h
>> @@ -12,7 +12,9 @@
>>
>>   extern cpumask_t cpus_on_node[];
>>
>> -#define cpumask_of_node(node)  (&cpus_on_node[node])
>> +#define cpumask_of_node(node)  ((node) == NUMA_NO_NODE ?       \
>> +                               cpu_all_mask :                  \
>> +                               &cpus_on_node[node])
> You can define it in one line, so does the MIPS version.
> 

ok, I can do it that way if you prefer. The reason I had it in flow was:
- a single line will overflow 80 characters, which some people still 
prefer not doing
- following example of other archs and general coding style to split 
macros functions across multiple lines.

Thanks,
John