public inbox for linux-mips@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE
@ 2026-01-07  9:40 John Garry
  2026-01-07  9:40 ` [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node() John Garry
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: John Garry @ 2026-01-07  9:40 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr, John Garry

This series aims to remedy an issue that not all per-arch versions of
cpumask_of_node() are robust against NUMA_NO_NODE.

In my view, cpumask_of_node() should be able to handle NUMA_NO_NODE. This
is because NUMA_NO_NODE is a valid index from the following flow, where
the device NUMA node is not set (from default):

device_initialize(dev)
	set_dev_node(dev, NUMA_NO_NODE);

mask = cpumask_of_node(dev_to_node(dev));

The CONFIG_DEBUG_PER_CPU_MAPS=n x86 version cpumask_of_node() would
produce an array out-of-index issue (when passed NUMA_NO_NODE), which I
think is attempted to be worked around here:
https://lore.kernel.org/linux-scsi/cf0f9085-6c87-4dd5-9114-925723e68495@oracle.com/T/#mdedb68052e419b4bfca9ce45bb33b58988018945

I also see a CVE which also looks related:
https://nvd.nist.gov/vuln/detail/cve-2024-39277

Each per-arch version could be picked up separately, as can the
asm-generic change.

Differences to v1:
- Put mips and loongarch definition on a single line (Huacai)

John Garry (4):
  include/asm-generic/topology.h: Remove unused definition of
    cpumask_of_node()
  LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
  MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  x86/cpu/topology: Make cpumask_of_node() robust against NUMA_NO_NODE

 arch/loongarch/include/asm/topology.h            | 2 +-
 arch/mips/include/asm/mach-loongson64/topology.h | 2 +-
 arch/x86/include/asm/topology.h                  | 2 ++
 arch/x86/mm/numa.c                               | 2 ++
 include/asm-generic/topology.h                   | 8 ++------
 5 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.43.5


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node()
  2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
@ 2026-01-07  9:40 ` John Garry
  2026-01-30 12:24   ` John Garry
  2026-01-07  9:40 ` [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2026-01-07  9:40 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr, John Garry

The definition of cpumask_of_node() in question is guarded by conflicting
CONFIG_NUMA and !CONFIG_NUMA checks, so remove it.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 include/asm-generic/topology.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 4dbe715be65b4..9865ba48c5b16 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -45,11 +45,7 @@
 #endif
 
 #ifndef cpumask_of_node
-  #ifdef CONFIG_NUMA
-    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_none_mask)
-  #else
-    #define cpumask_of_node(node)	((void)(node), cpu_online_mask)
-  #endif
+#define cpumask_of_node(node)	((void)(node), cpu_online_mask)
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)	((void)(bus), -1)
@@ -61,7 +57,7 @@
 				 cpumask_of_node(pcibus_to_node(bus)))
 #endif
 
-#endif	/* CONFIG_NUMA */
+#endif	/* !CONFIG_NUMA */
 
 #if !defined(CONFIG_NUMA) || !defined(CONFIG_HAVE_MEMORYLESS_NODES)
 
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
  2026-01-07  9:40 ` [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node() John Garry
@ 2026-01-07  9:40 ` John Garry
  2026-01-25  3:55   ` Huacai Chen
  2026-01-07  9:40 ` [PATCH v2 3/4] MIPS: Loongson: " John Garry
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2026-01-07  9:40 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr, John Garry

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
index f06e7ff25bb7c..6b79d6183085a 100644
--- a/arch/loongarch/include/asm/topology.h
+++ b/arch/loongarch/include/asm/topology.h
@@ -12,7 +12,7 @@
 
 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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 3/4] MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
  2026-01-07  9:40 ` [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node() John Garry
  2026-01-07  9:40 ` [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
@ 2026-01-07  9:40 ` John Garry
  2026-01-25  3:55   ` Huacai Chen
  2026-01-30 14:34   ` Thomas Bogendoerfer
  2026-01-07  9:40 ` [PATCH v2 4/4] x86/cpu/topology: " John Garry
  2026-01-19  8:38 ` [PATCH v2 0/4] " John Garry
  4 siblings, 2 replies; 15+ messages in thread
From: John Garry @ 2026-01-07  9:40 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr, John Garry

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/mips/include/asm/mach-loongson64/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h
index 3414a1fd17835..89bb4deab98a6 100644
--- a/arch/mips/include/asm/mach-loongson64/topology.h
+++ b/arch/mips/include/asm/mach-loongson64/topology.h
@@ -7,7 +7,7 @@
 #define cpu_to_node(cpu)	(cpu_logical_map(cpu) >> 2)
 
 extern cpumask_t __node_cpumask[];
-#define cpumask_of_node(node)	(&__node_cpumask[node])
+#define cpumask_of_node(node)	  ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])
 
 struct pci_bus;
 extern int pcibus_to_node(struct pci_bus *);
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 4/4] x86/cpu/topology: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
                   ` (2 preceding siblings ...)
  2026-01-07  9:40 ` [PATCH v2 3/4] MIPS: Loongson: " John Garry
@ 2026-01-07  9:40 ` John Garry
  2026-01-19  8:38 ` [PATCH v2 0/4] " John Garry
  4 siblings, 0 replies; 15+ messages in thread
From: John Garry @ 2026-01-07  9:40 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr, John Garry

The arch definitions of cpumask_of_node() cannot handle NUMA_NO_NODE -
which is a valid index - so add checks for this.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 arch/x86/include/asm/topology.h | 2 ++
 arch/x86/mm/numa.c              | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 1fadf0cf520c5..b51f2e771a582 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -69,6 +69,8 @@ extern const struct cpumask *cpumask_of_node(int node);
 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
 static inline const struct cpumask *cpumask_of_node(int node)
 {
+	if (node == NUMA_NO_NODE)
+		return cpu_all_mask;
 	return node_to_cpumask_map[node];
 }
 #endif
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 7a97327140df8..0be94f4682232 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -408,6 +408,8 @@ void numa_remove_cpu(unsigned int cpu)
  */
 const struct cpumask *cpumask_of_node(int node)
 {
+	if (node == NUMA_NO_NODE)
+		return cpu_all_mask;
 	if ((unsigned)node >= nr_node_ids) {
 		printk(KERN_WARNING
 			"cpumask_of_node(%d): (unsigned)node >= nr_node_ids(%u)\n",
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
                   ` (3 preceding siblings ...)
  2026-01-07  9:40 ` [PATCH v2 4/4] x86/cpu/topology: " John Garry
@ 2026-01-19  8:38 ` John Garry
  4 siblings, 0 replies; 15+ messages in thread
From: John Garry @ 2026-01-19  8:38 UTC (permalink / raw)
  To: chenhuacai, kernel, jiaxun.yang, tsbogend, tglx, mingo, bp,
	dave.hansen, hpa, luto, peterz, arnd, x86
  Cc: loongarch, linux-kernel, linux-mips, linux-arch, vulab, gregkh,
	rafael, dakr

On 07/01/2026 09:40, John Garry wrote:

A friendly reminder on this one.

Thanks

> This series aims to remedy an issue that not all per-arch versions of
> cpumask_of_node() are robust against NUMA_NO_NODE.
> 
> In my view, cpumask_of_node() should be able to handle NUMA_NO_NODE. This
> is because NUMA_NO_NODE is a valid index from the following flow, where
> the device NUMA node is not set (from default):
> 
> device_initialize(dev)
> 	set_dev_node(dev, NUMA_NO_NODE);
> 
> mask = cpumask_of_node(dev_to_node(dev));
> 
> The CONFIG_DEBUG_PER_CPU_MAPS=n x86 version cpumask_of_node() would
> produce an array out-of-index issue (when passed NUMA_NO_NODE), which I
> think is attempted to be worked around here:
> https://lore.kernel.org/linux-scsi/cf0f9085-6c87-4dd5-9114-925723e68495@oracle.com/T/#mdedb68052e419b4bfca9ce45bb33b58988018945
> 
> I also see a CVE which also looks related:
> https://nvd.nist.gov/vuln/detail/cve-2024-39277
> 
> Each per-arch version could be picked up separately, as can the
> asm-generic change.
> 
> Differences to v1:
> - Put mips and loongarch definition on a single line (Huacai)
> 
> John Garry (4):
>    include/asm-generic/topology.h: Remove unused definition of
>      cpumask_of_node()
>    LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
>    MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
>    x86/cpu/topology: Make cpumask_of_node() robust against NUMA_NO_NODE
> 
>   arch/loongarch/include/asm/topology.h            | 2 +-
>   arch/mips/include/asm/mach-loongson64/topology.h | 2 +-
>   arch/x86/include/asm/topology.h                  | 2 ++
>   arch/x86/mm/numa.c                               | 2 ++
>   include/asm-generic/topology.h                   | 8 ++------
>   5 files changed, 8 insertions(+), 8 deletions(-)
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 ` [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
@ 2026-01-25  3:55   ` Huacai Chen
  2026-01-30 12:20     ` John Garry
  0 siblings, 1 reply; 15+ messages in thread
From: Huacai Chen @ 2026-01-25  3:55 UTC (permalink / raw)
  To: John Garry
  Cc: kernel, jiaxun.yang, tsbogend, tglx, mingo, bp, dave.hansen, hpa,
	luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

On Wed, Jan 7, 2026 at 5:48 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
> index f06e7ff25bb7c..6b79d6183085a 100644
> --- a/arch/loongarch/include/asm/topology.h
> +++ b/arch/loongarch/include/asm/topology.h
> @@ -12,7 +12,7 @@
>
>  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
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 ` [PATCH v2 3/4] MIPS: Loongson: " John Garry
@ 2026-01-25  3:55   ` Huacai Chen
  2026-01-30 12:21     ` John Garry
  2026-01-30 14:34   ` Thomas Bogendoerfer
  1 sibling, 1 reply; 15+ messages in thread
From: Huacai Chen @ 2026-01-25  3:55 UTC (permalink / raw)
  To: John Garry
  Cc: kernel, jiaxun.yang, tsbogend, tglx, mingo, bp, dave.hansen, hpa,
	luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

On Wed, Jan 7, 2026 at 5:51 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/mips/include/asm/mach-loongson64/topology.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h
> index 3414a1fd17835..89bb4deab98a6 100644
> --- a/arch/mips/include/asm/mach-loongson64/topology.h
> +++ b/arch/mips/include/asm/mach-loongson64/topology.h
> @@ -7,7 +7,7 @@
>  #define cpu_to_node(cpu)       (cpu_logical_map(cpu) >> 2)
>
>  extern cpumask_t __node_cpumask[];
> -#define cpumask_of_node(node)  (&__node_cpumask[node])
> +#define cpumask_of_node(node)    ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])
>
>  struct pci_bus;
>  extern int pcibus_to_node(struct pci_bus *);
> --
> 2.43.5
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-25  3:55   ` Huacai Chen
@ 2026-01-30 12:20     ` John Garry
  2026-01-31  8:50       ` Huacai Chen
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2026-01-30 12:20 UTC (permalink / raw)
  To: Huacai Chen
  Cc: kernel, jiaxun.yang, tsbogend, tglx, mingo, bp, dave.hansen, hpa,
	luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

On 25/01/2026 03:55, Huacai Chen wrote:
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

Thanks

So can a loongarch maintainer pick this up please?

> 
> On Wed, Jan 7, 2026 at 5:48 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 | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
>> index f06e7ff25bb7c..6b79d6183085a 100644
>> --- a/arch/loongarch/include/asm/topology.h
>> +++ b/arch/loongarch/include/asm/topology.h
>> @@ -12,7 +12,7 @@
>>
>>   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
>>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-25  3:55   ` Huacai Chen
@ 2026-01-30 12:21     ` John Garry
  2026-01-30 12:40       ` Thomas Bogendoerfer
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2026-01-30 12:21 UTC (permalink / raw)
  To: Huacai Chen
  Cc: kernel, jiaxun.yang, tsbogend, tglx, mingo, bp, dave.hansen, hpa,
	luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

On 25/01/2026 03:55, Huacai Chen wrote:
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

Thanks

So can a loongarch or mips maintainer pick this up please?

> 
> On Wed, Jan 7, 2026 at 5:51 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/mips/include/asm/mach-loongson64/topology.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h
>> index 3414a1fd17835..89bb4deab98a6 100644
>> --- a/arch/mips/include/asm/mach-loongson64/topology.h
>> +++ b/arch/mips/include/asm/mach-loongson64/topology.h
>> @@ -7,7 +7,7 @@
>>   #define cpu_to_node(cpu)       (cpu_logical_map(cpu) >> 2)
>>
>>   extern cpumask_t __node_cpumask[];
>> -#define cpumask_of_node(node)  (&__node_cpumask[node])
>> +#define cpumask_of_node(node)    ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])
>>
>>   struct pci_bus;
>>   extern int pcibus_to_node(struct pci_bus *);
>> --
>> 2.43.5
>>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node()
  2026-01-07  9:40 ` [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node() John Garry
@ 2026-01-30 12:24   ` John Garry
  2026-01-30 16:12     ` Arnd Bergmann
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2026-01-30 12:24 UTC (permalink / raw)
  To: arnd
  Cc: loongarch, peterz, linux-kernel, linux-mips, linux-arch, vulab,
	gregkh, x86, rafael, dakr, luto, hpa, tsbogend, mingo,
	dave.hansen, bp, jiaxun.yang, kernel, chenhuacai, tglx

On 07/01/2026 09:40, John Garry wrote:
> The definition of cpumask_of_node() in question is guarded by conflicting
> CONFIG_NUMA and !CONFIG_NUMA checks, so remove it.

Arnd, can you consider picking this up please?

Thanks

> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>   include/asm-generic/topology.h | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
> index 4dbe715be65b4..9865ba48c5b16 100644
> --- a/include/asm-generic/topology.h
> +++ b/include/asm-generic/topology.h
> @@ -45,11 +45,7 @@
>   #endif
>   
>   #ifndef cpumask_of_node
> -  #ifdef CONFIG_NUMA
> -    #define cpumask_of_node(node)	((node) == 0 ? cpu_online_mask : cpu_none_mask)
> -  #else
> -    #define cpumask_of_node(node)	((void)(node), cpu_online_mask)
> -  #endif
> +#define cpumask_of_node(node)	((void)(node), cpu_online_mask)
>   #endif
>   #ifndef pcibus_to_node
>   #define pcibus_to_node(bus)	((void)(bus), -1)
> @@ -61,7 +57,7 @@
>   				 cpumask_of_node(pcibus_to_node(bus)))
>   #endif
>   
> -#endif	/* CONFIG_NUMA */
> +#endif	/* !CONFIG_NUMA */
>   
>   #if !defined(CONFIG_NUMA) || !defined(CONFIG_HAVE_MEMORYLESS_NODES)
>   


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-30 12:21     ` John Garry
@ 2026-01-30 12:40       ` Thomas Bogendoerfer
  0 siblings, 0 replies; 15+ messages in thread
From: Thomas Bogendoerfer @ 2026-01-30 12:40 UTC (permalink / raw)
  To: John Garry
  Cc: Huacai Chen, kernel, jiaxun.yang, tglx, mingo, bp, dave.hansen,
	hpa, luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

On Fri, Jan 30, 2026 at 12:21:45PM +0000, John Garry wrote:
> On 25/01/2026 03:55, Huacai Chen wrote:
> > Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> 
> Thanks
> 
> So can a loongarch or mips maintainer pick this up please?

I'll take MIPS patch.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] MIPS: Loongson: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-07  9:40 ` [PATCH v2 3/4] MIPS: Loongson: " John Garry
  2026-01-25  3:55   ` Huacai Chen
@ 2026-01-30 14:34   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 15+ messages in thread
From: Thomas Bogendoerfer @ 2026-01-30 14:34 UTC (permalink / raw)
  To: John Garry
  Cc: chenhuacai, kernel, jiaxun.yang, tglx, mingo, bp, dave.hansen,
	hpa, luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

On Wed, Jan 07, 2026 at 09:40:06AM +0000, John Garry 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/mips/include/asm/mach-loongson64/topology.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h
> index 3414a1fd17835..89bb4deab98a6 100644
> --- a/arch/mips/include/asm/mach-loongson64/topology.h
> +++ b/arch/mips/include/asm/mach-loongson64/topology.h
> @@ -7,7 +7,7 @@
>  #define cpu_to_node(cpu)	(cpu_logical_map(cpu) >> 2)
>  
>  extern cpumask_t __node_cpumask[];
> -#define cpumask_of_node(node)	(&__node_cpumask[node])
> +#define cpumask_of_node(node)	  ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])
>  
>  struct pci_bus;
>  extern int pcibus_to_node(struct pci_bus *);
> -- 
> 2.43.5

applied to mips-next
Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node()
  2026-01-30 12:24   ` John Garry
@ 2026-01-30 16:12     ` Arnd Bergmann
  0 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2026-01-30 16:12 UTC (permalink / raw)
  To: John Garry
  Cc: loongarch, Peter Zijlstra, linux-kernel, linux-mips, Linux-Arch,
	vulab, Greg Kroah-Hartman, x86, Rafael J . Wysocki,
	Danilo Krummrich, Andy Lutomirski, H. Peter Anvin,
	Thomas Bogendoerfer, Ingo Molnar, Dave Hansen, Borislav Petkov,
	Jiaxun Yang, WANG Xuerui, Huacai Chen, Thomas Gleixner

On Fri, Jan 30, 2026, at 13:24, John Garry wrote:
> On 07/01/2026 09:40, John Garry wrote:
>> The definition of cpumask_of_node() in question is guarded by conflicting
>> CONFIG_NUMA and !CONFIG_NUMA checks, so remove it.
>
> Arnd, can you consider picking this up please?

Merged now, sorry missing this earlier.

     Arnd

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
  2026-01-30 12:20     ` John Garry
@ 2026-01-31  8:50       ` Huacai Chen
  0 siblings, 0 replies; 15+ messages in thread
From: Huacai Chen @ 2026-01-31  8:50 UTC (permalink / raw)
  To: John Garry
  Cc: kernel, jiaxun.yang, tsbogend, tglx, mingo, bp, dave.hansen, hpa,
	luto, peterz, arnd, x86, loongarch, linux-kernel, linux-mips,
	linux-arch, vulab, gregkh, rafael, dakr

On Fri, Jan 30, 2026 at 8:21 PM John Garry <john.g.garry@oracle.com> wrote:
>
> On 25/01/2026 03:55, Huacai Chen wrote:
> > Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>
> Thanks
>
> So can a loongarch maintainer pick this up please?
OK, applied.

Huacai

>
> >
> > On Wed, Jan 7, 2026 at 5:48 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 | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h
> >> index f06e7ff25bb7c..6b79d6183085a 100644
> >> --- a/arch/loongarch/include/asm/topology.h
> >> +++ b/arch/loongarch/include/asm/topology.h
> >> @@ -12,7 +12,7 @@
> >>
> >>   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
> >>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-01-31  8:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07  9:40 [PATCH v2 0/4] Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
2026-01-07  9:40 ` [PATCH v2 1/4] include/asm-generic/topology.h: Remove unused definition of cpumask_of_node() John Garry
2026-01-30 12:24   ` John Garry
2026-01-30 16:12     ` Arnd Bergmann
2026-01-07  9:40 ` [PATCH v2 2/4] LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE John Garry
2026-01-25  3:55   ` Huacai Chen
2026-01-30 12:20     ` John Garry
2026-01-31  8:50       ` Huacai Chen
2026-01-07  9:40 ` [PATCH v2 3/4] MIPS: Loongson: " John Garry
2026-01-25  3:55   ` Huacai Chen
2026-01-30 12:21     ` John Garry
2026-01-30 12:40       ` Thomas Bogendoerfer
2026-01-30 14:34   ` Thomas Bogendoerfer
2026-01-07  9:40 ` [PATCH v2 4/4] x86/cpu/topology: " John Garry
2026-01-19  8:38 ` [PATCH v2 0/4] " John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox