diff mbox series

[v3,6/6] xen: introduce a Kconfig option to configure NUMA nodes number

Message ID 20220822025810.2240707-7-wei.chen@arm.com (mailing list archive)
State Superseded
Headers show
Series Device tree based NUMA support for Arm - Part#2 | expand

Commit Message

Wei Chen Aug. 22, 2022, 2:58 a.m. UTC
Current NUMA nodes number is a hardcode configuration. This
configuration is difficult for an administrator to change
unless changing the code.

So in this patch, we introduce this new Kconfig option for
administrators to change NUMA nodes number conveniently.
Also considering that not all architectures support NUMA,
this Kconfig option only can be visible on NUMA enabled
architectures. Non-NUMA supported architectures can still
use 1 as MAX_NUMNODES.

As NODES_SHIFT is currently unused, we're taking this
opportunity to remove it.

Signed-off-by: Wei Chen <wei.chen@arm.com>
---
v2 -> v3:
1. Fix indent.
2. Use 2-64 for node range.
v1 -> v2:
1. Add NODES_SHIFT remove message in commit log
2. Change NR_NUMA_NODES upper bound from 4095 to 255.
---
 xen/arch/Kconfig                | 11 +++++++++++
 xen/arch/x86/include/asm/numa.h |  2 --
 xen/include/xen/numa.h          | 11 ++++++-----
 3 files changed, 17 insertions(+), 7 deletions(-)

Comments

Jan Beulich Aug. 25, 2022, 1:05 p.m. UTC | #1
On 22.08.2022 04:58, Wei Chen wrote:
> Current NUMA nodes number is a hardcode configuration. This
> configuration is difficult for an administrator to change
> unless changing the code.
> 
> So in this patch, we introduce this new Kconfig option for
> administrators to change NUMA nodes number conveniently.
> Also considering that not all architectures support NUMA,
> this Kconfig option only can be visible on NUMA enabled
> architectures. Non-NUMA supported architectures can still
> use 1 as MAX_NUMNODES.

Especially the uses of "NUMA nodes number" make this read somewhat
odd. If I was to re-write all of this, it would become something
like:

Currently the maximum number of NUMA nodes is a hardcoded value.
This provides little flexibility unless changing the code.

Introduce a new Kconfig option to change the maximum number of
NUMA nodes conveniently. Also considering that not all
architectures support NUMA, this Kconfig option is only visible
on NUMA enabled architectures. Architectures not supporting NUMA
still use 1 for MAX_NUMNODES.

> As NODES_SHIFT is currently unused, we're taking this
> opportunity to remove it.
> 
> Signed-off-by: Wei Chen <wei.chen@arm.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

Note that there's an alternative with less #ifdef-ary:

config NR_NUMA_NODES
	int "Maximum number of NUMA nodes supported" if NUMA
	range 2 64 if NUMA
	default "1" if !NUMA
	default "64"

But I can see reasons why one might deem it better for there to
not be any CONFIG_NR_NUMA_NODES in the resulting .config when
!NUMA.

Jan
Wei Chen Aug. 29, 2022, 11 a.m. UTC | #2
Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 2022年8月25日 21:06
> To: Wei Chen <Wei.Chen@arm.com>
> Cc: nd <nd@arm.com>; Andrew Cooper <andrew.cooper3@citrix.com>; George
> Dunlap <george.dunlap@citrix.com>; Julien Grall <julien@xen.org>; Stefano
> Stabellini <sstabellini@kernel.org>; Wei Liu <wl@xen.org>; Roger Pau Monné
> <roger.pau@citrix.com>; xen-devel@lists.xenproject.org
> Subject: Re: [PATCH v3 6/6] xen: introduce a Kconfig option to configure
> NUMA nodes number
> 
> On 22.08.2022 04:58, Wei Chen wrote:
> > Current NUMA nodes number is a hardcode configuration. This
> > configuration is difficult for an administrator to change
> > unless changing the code.
> >
> > So in this patch, we introduce this new Kconfig option for
> > administrators to change NUMA nodes number conveniently.
> > Also considering that not all architectures support NUMA,
> > this Kconfig option only can be visible on NUMA enabled
> > architectures. Non-NUMA supported architectures can still
> > use 1 as MAX_NUMNODES.
> 
> Especially the uses of "NUMA nodes number" make this read somewhat
> odd. If I was to re-write all of this, it would become something
> like:
> 
> Currently the maximum number of NUMA nodes is a hardcoded value.
> This provides little flexibility unless changing the code.
> 
> Introduce a new Kconfig option to change the maximum number of
> NUMA nodes conveniently. Also considering that not all
> architectures support NUMA, this Kconfig option is only visible
> on NUMA enabled architectures. Architectures not supporting NUMA
> still use 1 for MAX_NUMNODES.
> 

Thanks, I will update the commit log.

> > As NODES_SHIFT is currently unused, we're taking this
> > opportunity to remove it.
> >
> > Signed-off-by: Wei Chen <wei.chen@arm.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 

Thanks!

> Note that there's an alternative with less #ifdef-ary:
> 
> config NR_NUMA_NODES
> 	int "Maximum number of NUMA nodes supported" if NUMA
> 	range 2 64 if NUMA
> 	default "1" if !NUMA
> 	default "64"
> 
> But I can see reasons why one might deem it better for there to
> not be any CONFIG_NR_NUMA_NODES in the resulting .config when
> !NUMA.
> 

Is it because there are many places where alternative patches need to
be added for #ifndef CONFIG_NR_NUMA_NODES?

Cheers,
Wei Chen

> Jan
Jan Beulich Sept. 6, 2022, 7:12 a.m. UTC | #3
On 29.08.2022 13:00, Wei Chen wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@suse.com>
>> Sent: 2022年8月25日 21:06
>>
>> Note that there's an alternative with less #ifdef-ary:
>>
>> config NR_NUMA_NODES
>> 	int "Maximum number of NUMA nodes supported" if NUMA
>> 	range 2 64 if NUMA
>> 	default "1" if !NUMA
>> 	default "64"
>>
>> But I can see reasons why one might deem it better for there to
>> not be any CONFIG_NR_NUMA_NODES in the resulting .config when
>> !NUMA.
>>
> 
> Is it because there are many places where alternative patches need to
> be added for #ifndef CONFIG_NR_NUMA_NODES?

Well, yes - that's why I said "with less #ifdef-ary". As you may have
noticed, excessive use of #ifdef easily makes code hard to read.

Jan
diff mbox series

Patch

diff --git a/xen/arch/Kconfig b/xen/arch/Kconfig
index f16eb0df43..7028f7b74f 100644
--- a/xen/arch/Kconfig
+++ b/xen/arch/Kconfig
@@ -17,3 +17,14 @@  config NR_CPUS
 	  For CPU cores which support Simultaneous Multi-Threading or similar
 	  technologies, this the number of logical threads which Xen will
 	  support.
+
+config NR_NUMA_NODES
+	int "Maximum number of NUMA nodes supported"
+	range 2 64
+	default "64"
+	depends on NUMA
+	help
+	  Controls the build-time size of various arrays and bitmaps
+	  associated with multiple-nodes management. It is the upper bound of
+	  the number of NUMA nodes that the scheduler, memory allocation and
+	  other NUMA-aware components can handle.
diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/numa.h
index 2ca3475271..7866afa408 100644
--- a/xen/arch/x86/include/asm/numa.h
+++ b/xen/arch/x86/include/asm/numa.h
@@ -3,8 +3,6 @@ 
 
 #include <xen/cpumask.h>
 
-#define NODES_SHIFT 6
-
 typedef u8 nodeid_t;
 
 extern int srat_rev;
diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index b5c9de24ed..3363718b02 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -3,14 +3,15 @@ 
 
 #include <asm/numa.h>
 
-#ifndef NODES_SHIFT
-#define NODES_SHIFT     0
-#endif
-
 #define NUMA_NO_NODE     0xFF
 #define NUMA_NO_DISTANCE 0xFF
 
-#define MAX_NUMNODES    (1 << NODES_SHIFT)
+#ifdef CONFIG_NR_NUMA_NODES
+#define MAX_NUMNODES CONFIG_NR_NUMA_NODES
+#else
+#define MAX_NUMNODES 1
+#endif
+
 #define NR_NODE_MEMBLKS (MAX_NUMNODES * 2)
 
 #define vcpu_to_node(v) (cpu_to_node((v)->processor))