Add device tree based NUMA support to Arm
Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
In reply to Wei ChenQuoted 234 lines · On Mon, 27 Sep 2021, 08:53 Wei Chen, <[email protected]> wrote:
Hi Julien,
Quoted 2 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf OfWei
Quoted 9 lines
Chen
Sent: 2021年9月27日 14:46
To: Stefano Stabellini <[email protected]>
Cc: [email protected]; [email protected]; Bertrand Marquis <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKSQuoted 11 lines
Hi Stefano, Julien,
Quoted 9 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月27日 13:00
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen- [email protected]; [email protected]; Bertrand Marquis <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 17 lines
Quoted 17 lines
NR_NODE_MEMBLKS+x86 maintainers
Quoted 8 lines · Wei Chen
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月27日 11:26
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen- [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 3 lines
Quoted 3 lines
NR_NODE_MEMBLKSOn Sun, 26 Sep 2021, Wei Chen wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 9:35
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected];Quoted 2 lines
Quoted 2 lines
Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKStooverride
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
default
Quoted 4 lines
Quoted 4 lines
NR_NODE_MEMBLKSQuoted 1 line · Wei Chen
As a memory range described in device tree cannot be split
across
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
multiple nodes. So we define
NR_NODE_MEMBLKSasNR_MEM_BANKSin
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
arch header.
This statement is true but what is the goal of this patch? Is
it
Quoted 5 lines
Quoted 5 lines
to
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
reduce code size and memory consumption?
No, when Julien and I discussed this in last version[1], we
hadn't
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
thought
Quoted 1 line
so deeply. We just thought a memory range described in DT cannot
be
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
split
Quoted 1 line
across multiple nodes. So
NR_MEM_BANKSshould be equal to
NR_MEM_BANKS.Quoted 9 lines
Quoted 9 lines
08/msg00974.html
Quoted 6 lines
Quoted 6 lines
I am asking because
NR_MEM_BANKSis 128 and NR_NODE_MEMBLKS=2*MAX_NUMNODES which is 64 by default so againNR_NODE_MEMBLKSis 128 before this patch.In other words, this patch alone doesn't make any difference;
at
Quoted 5 lines
Quoted 5 lines
least
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
doesn't make any difference unless
CONFIG_NR_NUMA_NODESisincreased.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So, is the goal to reduce memory usage when
CONFIG_NR_NUMA_NODESQuoted 23 lines
Quoted 4 lines
is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
higher than 64?
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
I also thought about this problem when I was writing this patch.
CONFIG_NR_NUMA_NODESis increasing, butNR_MEM_BANKSis a fixed value, thenNR_MEM_BANKScan be smaller thanCONFIG_NR_NUMA_NODESat one point.But I agree with Julien's suggestion,
NR_MEM_BANKSand
NR_NODE_MEMBLKSQuoted 1 line
Quoted 1 line
Quoted 1 line
must be aware of each other. I had thought to add some ASSERT
check,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
but I don't know how to do it better. So I post this patch for
more
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
suggestion.
OK. In that case I'd say to get rid of the previous definition of
NR_NODE_MEMBLKSas it is probably not necessary, see below.Quoted 1 line
Quoted 1 line
Quoted 63 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
And keep default
NR_NODE_MEMBLKSin common header
for those architectures NUMA is disabled.This last sentence is not accurate: on x86 NUMA is enabled and
NR_NODE_MEMBLKSis still defined inxen/include/xen/numa.h(there
Quoted 57 lines
is
Quoted 7 lines
Quoted 7 lines
no
Quoted 6 lines
Quoted 2 lines
x86 definition of it)
Yes.
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/include/asm-
Quoted 7 lines
Signed-off-by Wei Chen <[email protected]>--- xen/include/asm-arm/numa.h | 8 +++++++- xen/include/xen/numa.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-)xen/include/asm- renamed from xen/include/asm-arm/numa.h +0
-0
arm/numa.hQuoted 41 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
index
8f1c67e3eb..21569e634b100644xen/include/asm-arm/numa.h +7
-1@@ -3,9 +3,15 @@#include <xen/mm.h> +#include <asm/setup.h> +typedef u8 nodeid_t ; -#ifndef CONFIG_NUMA +#ifdef CONFIG_NUMA + +#define NR_NODE_MEMBLKS NR_MEM_BANKS + +#else /* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0xen/include/xen/numa.h +0
-0@@ -12,7 +12,9 @@#define MAX_NUMNODES 1#endif Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
xen/include/xen/numa.h line 17
Quoted 3 lines
xen/include/xen/numa.h +2
-0+#ifndef NR_NODE_MEMBLKS #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) +#endif This one we can remove it completely right?
How about define
NR_MEM_BANKSto:
#ifdefCONFIG_NR_NUMA_NODES
#defineNR_MEM_BANKS(CONFIG_NR_NUMA_NODES* 2)
#else
#defineNR_MEM_BANKS128
#endif
for both x86 and Arm. For those architectures do not support orenable
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
NUMA, they can still use "
NR_MEM_BANKS128". And replace all
NR_NODE_MEMBLKSQuoted 2 lines
in NUMA code to
NR_MEM_BANKSto removeNR_NODE_MEMBLKScompletely. In this case,NR_MEM_BANKScan be aware of the changes ofQuoted 9 lines
Quoted 5 lines
CONFIG_NR_NUMA_NODES.x86 doesn't have
NR_MEM_BANKSas far as I can tell. I guess you also meant to renameNR_NODE_MEMBLKStoNR_MEM_BANKS?Yes.
Quoted 1 line
But
NR_MEM_BANKSis not directly related toCONFIG_NR_NUMA_NODESbecause
Quoted 24 lines
Quoted 8 lines
there can be many memory banks for each numa node, certainly more than
2. The existing definition on x86:#define
NR_NODE_MEMBLKS(MAX_NUMNODES*2)Doesn't make a lot of sense to me. Was it just an arbitrary limit for the lack of a better way to set a maximum?
At that time, this was probably the most cost-effective approach. Enough and easy. But, if more nodes need to be supported in the future, it may bring more memory blocks. And this maximum value might not apply. The maximum may need to support dynamic extension.
Quoted 10 lines
On the other hand,
NR_MEM_BANKSandNR_NODE_MEMBLKSseem to be related. In fact, what's the difference?
NR_MEM_BANKSis the max number of memory banks (with or without numa-node-id).
NR_NODE_MEMBLKSis the max number of memory banks with NUMA support (with numa-node-id)?Quoted 11 lines
Quoted 2 lines
They are basically the same thing. On ARM I would just do:
Probably not,
NR_MEM_BANKSwill count those memory ranges without numa-node-id in boot memory parsing stage (process_memory_nodeor EFI parser). ButNR_NODE_MEMBLKSwill only count those memory ranges with numa-node-id.Quoted 3 lines
#define
NR_NODE_MEMBLKSMAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))Quote Julien's comment from HTML email to here:
" As you wrote above, the second part of the MAX is totally arbitrary. In fact, it is very likely than if you have more than 64 nodes, you may need a lot more than 2 regions per node.
Quoted 8 lines
So, for Arm, I would just define
NR_NODE_MEMBLKSas an alias toNR_MEM_BANKS
so it can be used by common code.
"But here comes the problem:
How can we set theNR_MEM_BANKSmaximum value, 128 seems an arbitrary too?
This is based on hardware we currently support (the last time we bumped the value was, IIRC, for Thunder-X). In the case of booting UEFI, we can get a lot of small ranges as we discover the RAM using the UEFI memory map.
If #define NR_MEM_BANKS (CONFIG_NR_NUMA_NODES * N)? And what N should be.
N would have to be the maximum number of ranges you can find in a NUMA node.
We would also need to make sure this doesn't break existing platforms. So N would have to be quite large or we need a MAX as Stefano suggested.
But I would prefer to keep the existing 128 and allow to configure it at build time (not necessarily in this series). This avoid to have different way to define the value based NUMA vs non-NUMA.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
And maybe the definition could be common with x86 if we define
NR_MEM_BANKSto 128 on x86 too.Julien had comment here, I will continue in that email.
RE: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
Hi Julien,
From: Julien Grall <[email protected]>
Sent: 2021年9月27日 15:36
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen-devel <[email protected]>; Bertrand Marquis <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monné <[email protected]>; Andrew Cooper <[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
On Mon, 27 Sep 2021, 08:53 Wei Chen, <mailto:[email protected]> wrote:
Hi Julien,
Quoted 223 lines
-----Original Message-----
From: Xen-devel <mailto:[email protected]> On Behalf Of Wei Chen
Sent: 2021年9月27日 14:46
To: Stefano Stabellini <mailto:[email protected]>
Cc: mailto:[email protected]; mailto:[email protected]; Bertrand Marquis <mailto:[email protected]>; mailto:[email protected]; mailto:[email protected]; mailto:[email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKSHi Stefano, Julien,
Quoted 32 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月27日 13:00
To: Wei Chen <mailto:[email protected]>
Cc: Stefano Stabellini <mailto:[email protected]>; xen- mailto:[email protected]; mailto:[email protected]; Bertrand Marquis <mailto:[email protected]>; mailto:[email protected]; mailto:[email protected]; mailto:[email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKS+x86 maintainers
Quoted 8 lines · Wei Chen
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月27日 11:26
To: Wei Chen <mailto:[email protected]>
Cc: Stefano Stabellini <mailto:[email protected]>; xen- mailto:[email protected]; mailto:[email protected]; Bertrand Marquis <mailto:[email protected]>
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 9 lines
Quoted 9 lines
NR_NODE_MEMBLKSQuoted 5 lines · Wei Chen
Quoted 5 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月24日 9:35
To: Wei Chen <mailto:[email protected]>
Cc: mailto:[email protected]; mailto:[email protected];mailto:[email protected];
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Bertrand Marquis <mailto:[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 4 lines
Quoted 4 lines
NR_NODE_MEMBLKSQuoted 1 line · Wei Chen
As a memory range described in device tree cannot be split
across
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
multiple nodes. So we define
NR_NODE_MEMBLKSasNR_MEM_BANKSin
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
arch header.
This statement is true but what is the goal of this patch? Is it
to
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
reduce code size and memory consumption?
No, when Julien and I discussed this in last version[1], we hadn't
thought
Quoted 1 line
so deeply. We just thought a memory range described in DT cannot
be
Quoted 21 lines
Quoted 2 lines
Quoted 2 lines
split
Quoted 1 line
across multiple nodes. So
NR_MEM_BANKSshould be equal to
NR_MEM_BANKS.Quoted 9 lines
Quoted 9 lines
08/msg00974.html
Quoted 6 lines
Quoted 6 lines
I am asking because
NR_MEM_BANKSis 128 and NR_NODE_MEMBLKS=2*MAX_NUMNODES which is 64 by default so againNR_NODE_MEMBLKSis 128 before this patch.In other words, this patch alone doesn't make any difference; at
least
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
doesn't make any difference unless
CONFIG_NR_NUMA_NODESisincreased.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So, is the goal to reduce memory usage when
CONFIG_NR_NUMA_NODESis
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
higher than 64?
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
I also thought about this problem when I was writing this patch.
CONFIG_NR_NUMA_NODESis increasing, butNR_MEM_BANKSis a fixed value, thenNR_MEM_BANKScan be smaller thanCONFIG_NR_NUMA_NODESat one point.But I agree with Julien's suggestion,
NR_MEM_BANKSand
NR_NODE_MEMBLKSQuoted 1 line
Quoted 1 line
Quoted 1 line
must be aware of each other. I had thought to add some ASSERT
check,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
but I don't know how to do it better. So I post this patch for
more
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
suggestion.
OK. In that case I'd say to get rid of the previous definition of
NR_NODE_MEMBLKSas it is probably not necessary, see below.Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
And keep default
NR_NODE_MEMBLKSin common header
for those architectures NUMA is disabled.This last sentence is not accurate: on x86 NUMA is enabled and
NR_NODE_MEMBLKSis still defined inxen/include/xen/numa.h(there
Quoted 58 lines
is
Quoted 7 lines
Quoted 7 lines
no
Quoted 6 lines
Quoted 2 lines
x86 definition of it)
Yes.
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/include/asm-
Quoted 7 lines
Signed-off-by Wei Chen <mailto:[email protected]>---
xen/include/asm-arm/numa.h| 8 +++++++-
xen/include/xen/numa.h | 2 ++2 files changed, 9 insertions(+), 1 deletion(-)xen/include/asm- renamed from xen/include/asm-arm/numa.h +0
-0
arm/numa.hQuoted 34 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
index
8f1c67e3eb..21569e634b100644xen/include/asm-arm/numa.h +7
-1@@ -3,9 +3,15 @@ #include <xen/mm.h> +#include <asm/setup.h> + typedef u8 nodeid_t; -#ifndef CONFIG_NUMA +#ifdef CONFIG_NUMA + +#define NR_NODE_MEMBLKS NR_MEM_BANKS + +#else /* Fake one node for now. See also node_online_map. */ #define cpu_to_node(cpu) 0xen/include/xen/numa.h +0
-0@@ -12,7 +12,9 @@ #define MAX_NUMNODES 1 #endifQuoted 5 lines
Quoted 3 lines
Quoted 3 lines
xen/include/xen/numa.h line 17
Quoted 3 lines
xen/include/xen/numa.h +2
-0+#ifndef NR_NODE_MEMBLKS #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) +#endif This one we can remove it completely right?
Quoted 8 lines
How about define
NR_MEM_BANKSto:
#ifdefCONFIG_NR_NUMA_NODES
#defineNR_MEM_BANKS(CONFIG_NR_NUMA_NODES* 2)
#else
#defineNR_MEM_BANKS128
#endif
for both x86 and Arm. For those architectures do not support or enable NUMA, they can still use "NR_MEM_BANKS128". And replace allQuoted 8 lines
NR_NODE_MEMBLKSQuoted 2 lines
in NUMA code to
NR_MEM_BANKSto removeNR_NODE_MEMBLKScompletely. In this case,NR_MEM_BANKScan be aware of the changes of
CONFIG_NR_NUMA_NODES.x86 doesn't have
NR_MEM_BANKSas far as I can tell. I guess you also meant to renameNR_NODE_MEMBLKStoNR_MEM_BANKS?Yes.
Quoted 9 lines
But
NR_MEM_BANKSis not directly related toCONFIG_NR_NUMA_NODESbecause there can be many memory banks for each numa node, certainly more than
2. The existing definition on x86:#define
NR_NODE_MEMBLKS(MAX_NUMNODES*2)Doesn't make a lot of sense to me. Was it just an arbitrary limit for the lack of a better way to set a maximum?
At that time, this was probably the most cost-effective approach. Enough and easy. But, if more nodes need to be supported in the future, it may bring more memory blocks. And this maximum value might not apply. The maximum may need to support dynamic extension.
Quoted 4 lines
On the other hand,
NR_MEM_BANKSandNR_NODE_MEMBLKSseem to be related. In fact, what's the difference?Quoted 8 lines
NR_MEM_BANKSis the max number of memory banks (with or without numa-node-id).
NR_NODE_MEMBLKSis the max number of memory banks with NUMA support (with numa-node-id)?They are basically the same thing. On ARM I would just do:
Probably not,
NR_MEM_BANKSwill count those memory ranges without numa-node-id in boot memory parsing stage (process_memory_nodeor EFI parser). ButNR_NODE_MEMBLKSwill only count those memory ranges with numa-node-id.Quoted 3 lines
#define
NR_NODE_MEMBLKSMAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))Quote Julien's comment from HTML email to here:
" As you wrote above, the second part of the MAX is totally arbitrary. In fact, it is very likely than if you have more than 64 nodes, you may need a lot more than 2 regions per node.
Quoted 9 lines
So, for Arm, I would just define
NR_NODE_MEMBLKSas an alias toNR_MEM_BANKSso it can be used by common code.
"Quoted 2 lines
But here comes the problem:
How can we set theNR_MEM_BANKSmaximum value, 128 seems an arbitrary too?This is based on hardware we currently support (the last time we bumped the value was, IIRC, for Thunder-X). In the case of booting UEFI, we can get a lot of small ranges as we discover the RAM using the UEFI memory map.
Thanks for the background.
Quoted 8 lines
Quoted 2 lines
If #define
NR_MEM_BANKS(CONFIG_NR_NUMA_NODES* N)? And what N should be.N would have to be the maximum number of ranges you can find in a NUMA node.
We would also need to make sure this doesn't break existing platforms. So N would have to be quite large or we need a MAX as Stefano suggested.
But I would prefer to keep the existing 128 and allow to configure it at build time (not necessarily in this series). This avoid to have different way to define the value based NUMA vs non-NUMA.
In this case, can we use Stefano's
"#define NR_NODE_MEMBLKS MAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))" in next version. If yes, should we change x86 part? Because NR_MEM_BANKS has not been defined in x86.
Quoted 4 lines
Quoted 2 lines
And maybe the definition could be common with x86 if we define
NR_MEM_BANKSto 128 on x86 too.Julien had comment here, I will continue in that email.
Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
Quoted 280 lines · On Mon, 27 Sep 2021, 12:22 Wei Chen, <[email protected]> wrote:
Hi Julien,
From: Julien Grall <[email protected]>
Sent: 2021年9月27日 15:36
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen-devel < [email protected]>; Bertrand Marquis < [email protected]>; Jan Beulich <[email protected]>; Roger Pau Monné <[email protected]>; Andrew Cooper <[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKSOn Mon, 27 Sep 2021, 08:53 Wei Chen, <mailto:[email protected]> wrote:
Hi Julien,Quoted 2 lines
-----Original Message-----
From: Xen-devel <mailto:[email protected]> OnBehalf Of Wei
Quoted 4 lines
Chen
Sent: 2021年9月27日 14:46
To: Stefano Stabellini <mailto:[email protected]>
Cc: mailto:[email protected]; mailto:[email protected];Bertrand Marquis
Quoted 1 line
<mailto:[email protected]>; mailto:[email protected]; mailto:
Quoted 4 lines
mailto:[email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKSQuoted 8 lines
Hi Stefano, Julien,
Quoted 6 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月27日 13:00
To: Wei Chen <mailto:[email protected]>
Cc: Stefano Stabellini <mailto:[email protected]>; xen- mailto:[email protected]; mailto:[email protected]; BertrandMarquis
Quoted 1 line
Quoted 1 line
<mailto:[email protected]>; mailto:[email protected]; mailto:
Quoted 2 lines
Quoted 2 lines
mailto:[email protected]
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 11 lines
Quoted 11 lines
NR_NODE_MEMBLKS+x86 maintainers
Quoted 6 lines · Wei Chen
Quoted 6 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月27日 11:26
To: Wei Chen <mailto:[email protected]>
Cc: Stefano Stabellini <mailto:[email protected]>; xen- mailto:[email protected]; mailto:[email protected];Bertrand Marquis
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
<mailto:[email protected]>
Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 8 lines
Quoted 8 lines
NR_NODE_MEMBLKSQuoted 5 lines · Wei Chen
Quoted 5 lines
-----Original Message-----
From: Stefano Stabellini <mailto:[email protected]>
Sent: 2021年9月24日 9:35
To: Wei Chen <mailto:[email protected]>
Cc: mailto:[email protected]; mailto:Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
mailto:[email protected];
Quoted 2 lines
Quoted 2 lines
Bertrand Marquis <mailto:[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKStooverride
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
default
Quoted 4 lines
Quoted 4 lines
NR_NODE_MEMBLKSQuoted 1 line · Wei Chen
As a memory range described in device tree cannot be split
across
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
multiple nodes. So we define
NR_NODE_MEMBLKSasNR_MEM_BANKSin
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
arch header.
This statement is true but what is the goal of this patch? Is
it
Quoted 5 lines
Quoted 5 lines
to
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
reduce code size and memory consumption?
No, when Julien and I discussed this in last version[1], we
hadn't
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
thought
Quoted 1 line
so deeply. We just thought a memory range described in DT cannot
be
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
split
Quoted 1 line
across multiple nodes. So
NR_MEM_BANKSshould be equal to
NR_MEM_BANKS.Quoted 9 lines
Quoted 9 lines
08/msg00974.html
Quoted 6 lines
Quoted 6 lines
I am asking because
NR_MEM_BANKSis 128 and NR_NODE_MEMBLKS=2*MAX_NUMNODES which is 64 by default so againNR_NODE_MEMBLKSis 128 before this patch.In other words, this patch alone doesn't make any difference;
at
Quoted 5 lines
Quoted 5 lines
least
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
doesn't make any difference unless
CONFIG_NR_NUMA_NODESisincreased.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So, is the goal to reduce memory usage when
CONFIG_NR_NUMA_NODESQuoted 23 lines
Quoted 4 lines
is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
higher than 64?
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
I also thought about this problem when I was writing this patch.
CONFIG_NR_NUMA_NODESis increasing, butNR_MEM_BANKSis a fixed value, thenNR_MEM_BANKScan be smaller thanCONFIG_NR_NUMA_NODESat one point.But I agree with Julien's suggestion,
NR_MEM_BANKSand
NR_NODE_MEMBLKSQuoted 1 line
Quoted 1 line
Quoted 1 line
must be aware of each other. I had thought to add some ASSERT
check,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
but I don't know how to do it better. So I post this patch for
more
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
suggestion.
OK. In that case I'd say to get rid of the previous definition of
NR_NODE_MEMBLKSas it is probably not necessary, see below.Quoted 1 line
Quoted 1 line
Quoted 63 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
And keep default
NR_NODE_MEMBLKSin common header
for those architectures NUMA is disabled.This last sentence is not accurate: on x86 NUMA is enabled and
NR_NODE_MEMBLKSis still defined inxen/include/xen/numa.h(there
Quoted 57 lines
is
Quoted 7 lines
Quoted 7 lines
no
Quoted 6 lines
Quoted 2 lines
x86 definition of it)
Yes.
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/include/asm-
Quoted 7 lines
Signed-off-by Wei Chen <mailto:[email protected]>--- xen/include/asm-arm/numa.h | 8 +++++++- xen/include/xen/numa.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-)xen/include/asm- renamed from xen/include/asm-arm/numa.h +0
-0
arm/numa.hQuoted 41 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
index
8f1c67e3eb..21569e634b100644xen/include/asm-arm/numa.h +7
-1@@ -3,9 +3,15 @@#include <xen/mm.h> +#include <asm/setup.h> +typedef u8 nodeid_t ; -#ifndef CONFIG_NUMA +#ifdef CONFIG_NUMA + +#define NR_NODE_MEMBLKS NR_MEM_BANKS + +#else /* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0xen/include/xen/numa.h +0
-0@@ -12,7 +12,9 @@#define MAX_NUMNODES 1#endif Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
xen/include/xen/numa.h line 17
Quoted 3 lines
xen/include/xen/numa.h +2
-0+#ifndef NR_NODE_MEMBLKS #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) +#endif This one we can remove it completely right?
How about define
NR_MEM_BANKSto:
#ifdefCONFIG_NR_NUMA_NODES
#defineNR_MEM_BANKS(CONFIG_NR_NUMA_NODES* 2)
#else
#defineNR_MEM_BANKS128
#endif
for both x86 and Arm. For those architectures do not support orenable
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
NUMA, they can still use "
NR_MEM_BANKS128". And replace all
NR_NODE_MEMBLKSQuoted 2 lines
in NUMA code to
NR_MEM_BANKSto removeNR_NODE_MEMBLKScompletely. In this case,NR_MEM_BANKScan be aware of the changes ofQuoted 9 lines
Quoted 5 lines
CONFIG_NR_NUMA_NODES.x86 doesn't have
NR_MEM_BANKSas far as I can tell. I guess you also meant to renameNR_NODE_MEMBLKStoNR_MEM_BANKS?Yes.
Quoted 1 line
But
NR_MEM_BANKSis not directly related toCONFIG_NR_NUMA_NODESbecause
Quoted 36 lines
Quoted 8 lines
there can be many memory banks for each numa node, certainly more than
2. The existing definition on x86:#define
NR_NODE_MEMBLKS(MAX_NUMNODES*2)Doesn't make a lot of sense to me. Was it just an arbitrary limit for the lack of a better way to set a maximum?
At that time, this was probably the most cost-effective approach. Enough and easy. But, if more nodes need to be supported in the future, it may bring more memory blocks. And this maximum value might not apply. The maximum may need to support dynamic extension.
Quoted 4 lines
On the other hand,
NR_MEM_BANKSandNR_NODE_MEMBLKSseem to be related. In fact, what's the difference?Quoted 8 lines
NR_MEM_BANKSis the max number of memory banks (with or without numa-node-id).
NR_NODE_MEMBLKSis the max number of memory banks with NUMA support (with numa-node-id)?They are basically the same thing. On ARM I would just do:
Probably not,
NR_MEM_BANKSwill count those memory ranges without numa-node-id in boot memory parsing stage (process_memory_nodeor EFI parser). ButNR_NODE_MEMBLKSwill only count those memory ranges with numa-node-id.Quoted 3 lines
#define
NR_NODE_MEMBLKSMAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))Quoted 6 lines
Quote Julien's comment from HTML email to here:
" As you wrote above, the second part of the MAX is totally arbitrary. In fact, it is very likely than if you have more than 64 nodes, you may need a lot more than 2 regions per node.So, for Arm, I would just define
NR_NODE_MEMBLKSas an alias to
NR_MEM_BANKSQuoted 5 lines
so it can be used by common code.
"Quoted 2 lines
But here comes the problem:
How can we set theNR_MEM_BANKSmaximum value, 128 seems an arbitrarytoo?
Quoted 2 lines
This is based on hardware we currently support (the last time we bumped
the value was, IIRC, for Thunder-X). In the case of booting UEFI, we can get a lot of small ranges as we discover the RAM using the UEFI memory map.
Quoted 1 line
Thanks for the background.
Quoted 2 lines
Quoted 2 lines
If #define
NR_MEM_BANKS(CONFIG_NR_NUMA_NODES* N)? And what N shouldbe.
Quoted 2 lines
N would have to be the maximum number of ranges you can find in a NUMA
node.
Quoted 2 lines
We would also need to make sure this doesn't break existing platforms.
So N would have to be quite large or we need a MAX as Stefano suggested.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
But I would prefer to keep the existing 128 and allow to configure it at
build time (not necessarily in this series). This avoid to have different way to define the value based NUMA vs non-NUMA.
In this case, can we use Stefano's
"#defineNR_NODE_MEMBLKSMAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))" in next version. If yes, should we change x86 part? BecauseNR_MEM_BANKShas not been defined in x86.
What I meant by configuring dynamically is allowing NR_MEM_BANKS to be set by the user.
The second part of the MAX makes no sense to me (at least on Arm). So I really prefer if this is not part of the initial version.
We can refine the value, or introduce the MAX in the future if we have a justification for it.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
And maybe the definition could be common with x86 if we define
NR_MEM_BANKSto 128 on x86 too.Julien had comment here, I will continue in that email.
Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
Quoted 268 lines · Julien Grall
On Mon, 27 Sep 2021, 12:22 Wei Chen, <[email protected]> wrote:
Hi Julien, From: Julien Grall <[email protected]> Sent: 2021年9月27日 15:36 To: Wei Chen <[email protected]> Cc: Stefano Stabellini <[email protected]>; xen-devel <[email protected]>; Bertrand Marquis <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monné <[email protected]>; Andrew Cooper <[email protected]> Subject: Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS On Mon, 27 Sep 2021, 08:53 Wei Chen, <mailto:[email protected]> wrote: Hi Julien, > -----Original Message----- > From: Xen-devel <mailto:[email protected]> On Behalf Of Wei > Chen > Sent: 2021年9月27日 14:46 > To: Stefano Stabellini <mailto:[email protected]> > Cc: mailto:[email protected]; mailto:[email protected]; Bertrand Marquis > <mailto:[email protected]>; mailto:[email protected]; mailto:[email protected]; > mailto:[email protected] > Subject: RE: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default > NR_NODE_MEMBLKS > > Hi Stefano, Julien, > > > -----Original Message----- > > From: Stefano Stabellini <mailto:[email protected]> > > Sent: 2021年9月27日 13:00 > > To: Wei Chen <mailto:[email protected]> > > Cc: Stefano Stabellini <mailto:[email protected]>; xen- > > mailto:[email protected]; mailto:[email protected]; Bertrand Marquis > > <mailto:[email protected]>; mailto:[email protected]; mailto:[email protected]; > > mailto:[email protected] > > Subject: RE: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default > > NR_NODE_MEMBLKS > > > > +x86 maintainers > > > > On Mon, 27 Sep 2021, Wei Chen wrote: > > > > -----Original Message----- > > > > From: Stefano Stabellini <mailto:[email protected]> > > > > Sent: 2021年9月27日 11:26 > > > > To: Wei Chen <mailto:[email protected]> > > > > Cc: Stefano Stabellini <mailto:[email protected]>; xen- > > > > mailto:[email protected]; mailto:[email protected]; Bertrand Marquis > > > > <mailto:[email protected]> > > > > Subject: RE: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override > > default > > > > NR_NODE_MEMBLKS > > > > > > > > On Sun, 26 Sep 2021, Wei Chen wrote: > > > > > > -----Original Message----- > > > > > > From: Stefano Stabellini <mailto:[email protected]> > > > > > > Sent: 2021年9月24日 9:35 > > > > > > To: Wei Chen <mailto:[email protected]> > > > > > > Cc: mailto:[email protected]; mailto:[email protected]; > > > > mailto:[email protected]; > > > > > > Bertrand Marquis <mailto:[email protected]> > > > > > > Subject: Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override > > > > default > > > > > > NR_NODE_MEMBLKS > > > > > > > > > > > > On Thu, 23 Sep 2021, Wei Chen wrote: > > > > > > > As a memory range described in device tree cannot be split > > across > > > > > > > multiple nodes. So we define NR_NODE_MEMBLKS as NR_MEM_BANKS > in > > > > > > > arch header. > > > > > > > > > > > > This statement is true but what is the goal of this patch? Is it > > to > > > > > > reduce code size and memory consumption? > > > > > > > > > > > > > > > > No, when Julien and I discussed this in last version[1], we hadn't > > > > thought > > > > > so deeply. We just thought a memory range described in DT cannot > be > > > > split > > > > > across multiple nodes. So NR_MEM_BANKS should be equal to > > NR_MEM_BANKS. > > > > > > > > > > https://lists.xenproject.org/archives/html/xen-devel/2021- > > > > 08/msg00974.html > > > > > > > > > > > I am asking because NR_MEM_BANKS is 128 and > > > > > > NR_NODE_MEMBLKS=2*MAX_NUMNODES which is 64 by default so again > > > > > > NR_NODE_MEMBLKS is 128 before this patch. > > > > > > > > > > > > In other words, this patch alone doesn't make any difference; at > > least > > > > > > doesn't make any difference unless CONFIG_NR_NUMA_NODES is > > increased. > > > > > > > > > > > > So, is the goal to reduce memory usage when CONFIG_NR_NUMA_NODES > > is > > > > > > higher than 64? > > > > > > > > > > > > > > > > I also thought about this problem when I was writing this patch. > > > > > CONFIG_NR_NUMA_NODES is increasing, but NR_MEM_BANKS is a fixed > > > > > value, then NR_MEM_BANKS can be smaller than CONFIG_NR_NUMA_NODES > > > > > at one point. > > > > > > > > > > But I agree with Julien's suggestion, NR_MEM_BANKS and > > NR_NODE_MEMBLKS > > > > > must be aware of each other. I had thought to add some ASSERT > check, > > > > > but I don't know how to do it better. So I post this patch for > more > > > > > suggestion. > > > > > > > > OK. In that case I'd say to get rid of the previous definition of > > > > NR_NODE_MEMBLKS as it is probably not necessary, see below. > > > > > > > > > > > > > > > > > > > > > > > > > And keep default NR_NODE_MEMBLKS in common header > > > > > > > for those architectures NUMA is disabled. > > > > > > > > > > > > This last sentence is not accurate: on x86 NUMA is enabled and > > > > > > NR_NODE_MEMBLKS is still defined in xen/include/xen/numa.h > (there > > is > > > > no > > > > > > x86 definition of it) > > > > > > > > > > > > > > > > Yes. > > > > > > > > > > > > > > > > > > Signed-off-by: Wei Chen <mailto:[email protected]> > > > > > > > --- > > > > > > > xen/include/asm-arm/numa.h | 8 +++++++- > > > > > > > xen/include/xen/numa.h | 2 ++ > > > > > > > 2 files changed, 9 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm- > > arm/numa.h > > > > > > > index 8f1c67e3eb..21569e634b 100644 > > > > > > > --- a/xen/include/asm-arm/numa.h > > > > > > > +++ b/xen/include/asm-arm/numa.h > > > > > > > @@ -3,9 +3,15 @@ > > > > > > > > > > > > > > #include <xen/mm.h> > > > > > > > > > > > > > > +#include <asm/setup.h> > > > > > > > + > > > > > > > typedef u8 nodeid_t; > > > > > > > > > > > > > > -#ifndef CONFIG_NUMA > > > > > > > +#ifdef CONFIG_NUMA > > > > > > > + > > > > > > > +#define NR_NODE_MEMBLKS NR_MEM_BANKS > > > > > > > + > > > > > > > +#else > > > > > > > > > > > > > > /* Fake one node for now. See also node_online_map. */ > > > > > > > #define cpu_to_node(cpu) 0 > > > > > > > diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h > > > > > > > index 1978e2be1b..1731e1cc6b 100644 > > > > > > > --- a/xen/include/xen/numa.h > > > > > > > +++ b/xen/include/xen/numa.h > > > > > > > @@ -12,7 +12,9 @@ > > > > > > > #define MAX_NUMNODES 1 > > > > > > > #endif > > > > > > > > > > > > > > +#ifndef NR_NODE_MEMBLKS > > > > > > > #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) > > > > > > > +#endif > > > > > > > > This one we can remove it completely right? > > > > > > How about define NR_MEM_BANKS to: > > > #ifdef CONFIG_NR_NUMA_NODES > > > #define NR_MEM_BANKS (CONFIG_NR_NUMA_NODES * 2) > > > #else > > > #define NR_MEM_BANKS 128 > > > #endif > > > for both x86 and Arm. For those architectures do not support or enable > > > NUMA, they can still use "NR_MEM_BANKS 128". And replace all > > NR_NODE_MEMBLKS > > > in NUMA code to NR_MEM_BANKS to remove NR_NODE_MEMBLKS completely. > > > In this case, NR_MEM_BANKS can be aware of the changes of > > CONFIG_NR_NUMA_NODES. > > > > x86 doesn't have NR_MEM_BANKS as far as I can tell. I guess you also > > meant to rename NR_NODE_MEMBLKS to NR_MEM_BANKS? > > > > Yes. > > > But NR_MEM_BANKS is not directly related to CONFIG_NR_NUMA_NODES because > > there can be many memory banks for each numa node, certainly more than > > 2. The existing definition on x86: > > > > #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) > > > > Doesn't make a lot of sense to me. Was it just an arbitrary limit for > > the lack of a better way to set a maximum? > > > > At that time, this was probably the most cost-effective approach. > Enough and easy. But, if more nodes need to be supported in the > future, it may bring more memory blocks. And this maximum value > might not apply. The maximum may need to support dynamic extension. > > > > > On the other hand, NR_MEM_BANKS and NR_NODE_MEMBLKS seem to be related. > > In fact, what's the difference? > > > > NR_MEM_BANKS is the max number of memory banks (with or without > > numa-node-id). > > > > NR_NODE_MEMBLKS is the max number of memory banks with NUMA support > > (with numa-node-id)? > > > > They are basically the same thing. On ARM I would just do: > > > > Probably not, NR_MEM_BANKS will count those memory ranges without > numa-node-id in boot memory parsing stage (process_memory_node or > EFI parser). But NR_NODE_MEMBLKS will only count those memory ranges > with numa-node-id. > > > #define NR_NODE_MEMBLKS MAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2)) > > > > > Quote Julien's comment from HTML email to here: > " As you wrote above, the second part of the MAX is totally arbitrary. > In fact, it is very likely than if you have more than 64 nodes, you may > need a lot more than 2 regions per node. > > So, for Arm, I would just define NR_NODE_MEMBLKS as an alias to NR_MEM_BANKS > so it can be used by common code. > " > > > But here comes the problem: > > How can we set the NR_MEM_BANKS maximum value, 128 seems an arbitrary too? > > This is based on hardware we currently support (the last time we bumped the value was, IIRC, for Thunder-X). In the case of booting UEFI, we can get a lot of small ranges as we discover the RAM using the UEFI memory map. > Thanks for the background. > > > If #define NR_MEM_BANKS (CONFIG_NR_NUMA_NODES * N)? And what N should be. > > N would have to be the maximum number of ranges you can find in a NUMA node. > > We would also need to make sure this doesn't break existing platforms. So N would have to be quite large or we need a MAX as Stefano suggested. > > But I would prefer to keep the existing 128 and allow to configure it at build time (not necessarily in this series). This avoid to have different way to define the value based NUMA vs non-NUMA. In this case, can we use Stefano's "#define NR_NODE_MEMBLKS MAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES * 2))" in next version. If yes, should we change x86 part? Because NR_MEM_BANKS has not been defined in x86.
Quoted 5 lines
What I meant by configuring dynamically is allowing
NR_MEM_BANKSto be set by the user.The second part of the MAX makes no sense to me (at least on Arm). So I really prefer if this is not part of the initial version.
We can refine the value, or introduce the MAX in the future if we have a justification for it.
OK, so for clarity the suggestion is:
- define NR_NODE_MEMBLKS as NR_MEM_BANKS on ARM in this series
- in the future make NR_MEM_BANKS user-configurable via kconfig
- for now leave NR_MEM_BANKS as 128 on ARM
That's fine by me.
RE: [PATCH 22/37] xen/arm: use NR_MEM_BANKS to override default NR_NODE_MEMBLKS
Hi Stefano, Julien,
Quoted 356 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月28日 0:58
To: Julien Grall <[email protected]>
Cc: Wei Chen <[email protected]>; Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>; Bertrand Marquis <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monné <[email protected]>; Andrew Cooper <[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto override defaultNR_NODE_MEMBLKSQuoted 7 lines · Julien Grall
On Mon, 27 Sep 2021, 12:22 Wei Chen, <[email protected]> wrote:
Hi Julien,From: Julien Grall <[email protected]>
Sent: 2021年9月27日 15:36
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen-devel <xen-[email protected]>; Bertrand Marquis
Quoted 1 line
<[email protected]>; Jan Beulich <[email protected]>; Roger
Pau Monné <[email protected]>; Andrew Cooper
Quoted 2 lines
<[email protected]>
Subject: Re: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
NR_NODE_MEMBLKSQuoted 3 lines
On Mon, 27 Sep 2021, 08:53 Wei Chen, <mailto:[email protected]>Quoted 4 lines · wrote:
Hi Julien,
> -----Original Message-----
> From: Xen-devel <mailto:[email protected]>On Behalf Of Wei
Quoted 4 lines
> Chen > Sent: 2021年9月27日 14:46 > To: Stefano Stabellini <mailto:[email protected]> > Cc: mailto:[email protected]; mailto:[email protected];Bertrand Marquis
Quoted 1 line
> <mailto:[email protected]>; mailto:[email protected];mailto:[email protected];
Quoted 2 lines
> mailto:[email protected]
> Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKSto overridedefault
Quoted 10 lines
> NR_NODE_MEMBLKS > > Hi Stefano, Julien, > > > -----Original Message----- > > From: Stefano Stabellini <mailto:[email protected]> > > Sent: 2021年9月27日 13:00 > > To: Wei Chen <mailto:[email protected]> > > Cc: Stefano Stabellini <mailto:[email protected]>; xen- > > mailto:[email protected]; mailto:[email protected];Bertrand Marquis
Quoted 1 line
> > <mailto:[email protected]>; mailto:[email protected];mailto:[email protected];
Quoted 2 lines
> > mailto:[email protected]
> > Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKStooverride default
Quoted 10 lines
> > NR_NODE_MEMBLKS > > > > +x86 maintainers > > > > On Mon, 27 Sep 2021, Wei Chen wrote: > > > > -----Original Message----- > > > > From: Stefano Stabellini <mailto:[email protected]> > > > > Sent: 2021年9月27日 11:26 > > > > To: Wei Chen <mailto:[email protected]> > > > > Cc: Stefano Stabellini <mailto:[email protected]>;xen-
Quoted 1 line
> > > > mailto:[email protected]; mailto:[email protected];Bertrand Marquis
Quoted 2 lines
> > > > <mailto:[email protected]>
> > > > Subject: RE: [PATCH 22/37] xen/arm: useNR_MEM_BANKStooverride
Quoted 6 lines
> > default > > > > NR_NODE_MEMBLKS > > > > > > > > On Sun, 26 Sep 2021, Wei Chen wrote: > > > > > > -----Original Message----- > > > > > > From: Stefano Stabellini<mailto:[email protected]>
Quoted 3 lines
> > > > > > Sent: 2021年9月24日 9:35 > > > > > > To: Wei Chen <mailto:[email protected]> > > > > > > Cc: mailto:[email protected];mailto:[email protected];
Quoted 3 lines
> > > > mailto:[email protected]; > > > > > > Bertrand Marquis <mailto:[email protected]> > > > > > > Subject: Re: [PATCH 22/37] xen/arm: use NR_MEM_BANKSto override
Quoted 5 lines
> > > > default > > > > > > NR_NODE_MEMBLKS > > > > > > > > > > > > On Thu, 23 Sep 2021, Wei Chen wrote: > > > > > > > As a memory range described in device tree cannot besplit
Quoted 2 lines
> > across
> > > > > > > multiple nodes. So we defineNR_NODE_MEMBLKSas
NR_MEM_BANKSQuoted 4 lines
> in > > > > > > > arch header. > > > > > > > > > > > > This statement is true but what is the goal of thispatch? Is it
Quoted 5 lines
> > to > > > > > > reduce code size and memory consumption? > > > > > > > > > > > > > > > > No, when Julien and I discussed this in last version[1],we hadn't
Quoted 2 lines
> > > > thought
> > > > > so deeply. We just thought a memory range described inDT cannot
Quoted 3 lines
> be
> > > > split
> > > > > across multiple nodes. SoNR_MEM_BANKSshould be equalto
Quoted 3 lines
> > NR_MEM_BANKS. > > > > > > > > > > https://lists.xenproject.org/archives/html/xen-devel/2021-
Quoted 4 lines
> > > > 08/msg00974.html
> > > > >
> > > > > > I am asking becauseNR_MEM_BANKSis 128 and > > > > > > NR_NODE_MEMBLKS=2*MAX_NUMNODES which is 64 by defaultso again
Quoted 3 lines
> > > > > >
NR_NODE_MEMBLKSis 128 before this patch. > > > > > >
> > > > > > In other words, this patch alone doesn't make anydifference; at
Quoted 2 lines
> > least
> > > > > > doesn't make any difference unless
CONFIG_NR_NUMA_NODESisQuoted 3 lines
> > increased.
> > > > > >
> > > > > > So, is the goal to reduce memory usage when
CONFIG_NR_NUMA_NODESQuoted 5 lines
> > is > > > > > > higher than 64? > > > > > > > > > > > > > > > > I also thought about this problem when I was writingthis patch.
Quoted 1 line
> > > > >
CONFIG_NR_NUMA_NODESis increasing, butNR_MEM_BANKSisa fixed
Quoted 1 line
> > > > > value, then
NR_MEM_BANKScan be smaller than
CONFIG_NR_NUMA_NODESQuoted 5 lines
> > > > > at one point.
> > > > >
> > > > > But I agree with Julien's suggestion,NR_MEM_BANKSand > >NR_NODE_MEMBLKS
> > > > > must be aware of each other. I had thought to add someASSERT
Quoted 2 lines
> check,
> > > > > but I don't know how to do it better. So I post thispatch for
Quoted 4 lines
> more > > > > > suggestion. > > > > > > > > OK. In that case I'd say to get rid of the previousdefinition of
Quoted 9 lines
> > > > NR_NODE_MEMBLKS as it is probably not necessary, see below. > > > > > > > > > > > > > > > > > > > > > > > > > And keep default NR_NODE_MEMBLKS in common header > > > > > > > for those architectures NUMA is disabled. > > > > > > > > > > > > This last sentence is not accurate: on x86 NUMA isenabled and
Quoted 1 line
> > > > > >
NR_NODE_MEMBLKSis still defined in
xen/include/xen/numa.hQuoted 8 lines
> (there > > is > > > > no > > > > > > x86 definition of it) > > > > > > > > > > > > > > > > Yes. > > > > >Quoted 8 lines
> > > > > > > > > > > > > Signed-off-by: Wei Chen <mailto:[email protected]> > > > > > > > --- > > > > > > > xen/include/asm-arm/numa.h | 8 +++++++- > > > > > > > xen/include/xen/numa.h | 2 ++ > > > > > > > 2 files changed, 9 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > diff --git a/xen/include/asm-arm/numa.hb/xen/include/asm-
Quoted 12 lines
> > arm/numa.h > > > > > > > index 8f1c67e3eb..21569e634b 100644 > > > > > > > --- a/xen/include/asm-arm/numa.h > > > > > > > +++ b/xen/include/asm-arm/numa.h > > > > > > > @@ -3,9 +3,15 @@ > > > > > > > > > > > > > > #include <xen/mm.h> > > > > > > > > > > > > > > +#include <asm/setup.h> > > > > > > > + > > > > > > > typedef u8 nodeid_t; > > > > > > >Quoted 8 lines
> > > > > > > -#ifndef CONFIG_NUMA > > > > > > > +#ifdef CONFIG_NUMA > > > > > > > + > > > > > > > +#define NR_NODE_MEMBLKS NR_MEM_BANKS > > > > > > > + > > > > > > > +#else > > > > > > > > > > > > > > /* Fake one node for now. See also node_online_map.*/
Quoted 2 lines
> > > > > > > #define cpu_to_node(cpu) 0 > > > > > > > diff --git a/xen/include/xen/numa.h
b/xen/include/xen/numa.hQuoted 12 lines
> > > > > > > index 1978e2be1b..1731e1cc6b 100644 > > > > > > > --- a/xen/include/xen/numa.h > > > > > > > +++ b/xen/include/xen/numa.h > > > > > > > @@ -12,7 +12,9 @@ > > > > > > > #define MAX_NUMNODES 1 > > > > > > > #endif > > > > > > > > > > > > > > +#ifndef NR_NODE_MEMBLKS > > > > > > > #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) > > > > > > > +#endif > > > > > > > > This one we can remove it completely right?Quoted 8 lines
> > > > > > How about define NR_MEM_BANKS to: > > > #ifdef CONFIG_NR_NUMA_NODES > > > #define NR_MEM_BANKS (CONFIG_NR_NUMA_NODES * 2) > > > #else > > > #define NR_MEM_BANKS 128 > > > #endif > > > for both x86 and Arm. For those architectures do not supportor enable
Quoted 3 lines
> > > NUMA, they can still use "
NR_MEM_BANKS128". And replace all > >NR_NODE_MEMBLKS
> > > in NUMA code toNR_MEM_BANKSto removeNR_NODE_MEMBLKScompletely.
Quoted 4 lines
> > > In this case,
NR_MEM_BANKScan be aware of the changes of > >CONFIG_NR_NUMA_NODES.
> >
> > x86 doesn't haveNR_MEM_BANKSas far as I can tell. I guessyou also
Quoted 6 lines
> > meant to rename NR_NODE_MEMBLKS to NR_MEM_BANKS? > > > > Yes. > > > But NR_MEM_BANKS is not directly related to
CONFIG_NR_NUMA_NODESbecauseQuoted 1 line
> > there can be many memory banks for each numa node, certainly
more than
Quoted 5 lines
> > 2. The existing definition on x86:
> >
> > #defineNR_NODE_MEMBLKS(MAX_NUMNODES*2)
> >
> > Doesn't make a lot of sense to me. Was it just an arbitrarylimit for
Quoted 7 lines
> > the lack of a better way to set a maximum?
> >
>
> At that time, this was probably the most cost-effective approach. > Enough and easy. But, if more nodes need to be supported in the > future, it may bring more memory blocks. And this maximum value > might not apply. The maximum may need to support dynamicextension.
Quoted 3 lines
> > > > > On the other hand, NR_MEM_BANKS and NR_NODE_MEMBLKS seem to berelated.
Quoted 3 lines
> > In fact, what's the difference?
> >
> >NR_MEM_BANKSis the max number of memory banks (with orwithout
Quoted 3 lines
> > numa-node-id). > > > > NR_NODE_MEMBLKS is the max number of memory banks with NUMAsupport
Quoted 6 lines
> > (with numa-node-id)? > > > > They are basically the same thing. On ARM I would just do: > > > > Probably not, NR_MEM_BANKS will count those memory rangeswithout
Quoted 1 line
> numa-node-id in boot memory parsing stage (
process_memory_nodeor
Quoted 1 line
> EFI parser). But
NR_NODE_MEMBLKSwill only count those memoryranges
Quoted 3 lines
> with numa-node-id.
>
> > #defineNR_NODE_MEMBLKSMAX(NR_MEM_BANKS,(
CONFIG_NR_NUMA_NODES* 2))Quoted 5 lines
> >
> >> Quote Julien's comment from HTML email to here:
> " As you wrote above, the second part of the MAX is totallyarbitrary.
Quoted 1 line
> In fact, it is very likely than if you have more than 64 nodes,
you may
Quoted 3 lines
> need a lot more than 2 regions per node.
>
> So, for Arm, I would just defineNR_NODE_MEMBLKSas an alias to
NR_MEM_BANKSQuoted 5 lines
> so it can be used by common code.
> "
>
> > But here comes the problem:
> > How can we set theNR_MEM_BANKSmaximum value, 128 seems anarbitrary too?
Quoted 2 lines
>
> This is based on hardware we currently support (the last time webumped the value was, IIRC, for Thunder-X). In the case of
Quoted 1 line
booting UEFI, we can get a lot of small ranges as we discover the
RAM using the UEFI memory map.
Quoted 6 lines
>
Thanks for the background.
>
> > If #defineNR_MEM_BANKS(CONFIG_NR_NUMA_NODES* N)? And what Nshould be.
Quoted 2 lines
>
> N would have to be the maximum number of ranges you can find ina NUMA node.
Quoted 2 lines
>
> We would also need to make sure this doesn't break existingplatforms. So N would have to be quite large or we need a MAX as
Quoted 3 lines
Stefano suggested.
>
> But I would prefer to keep the existing 128 and allow toconfigure it at build time (not necessarily in this series). This
Quoted 1 line
avoid to have different way to define the value based NUMA vs non-
NUMA.
Quoted 3 lines
In this case, can we use Stefano's
"#defineNR_NODE_MEMBLKSMAX(NR_MEM_BANKS, (CONFIG_NR_NUMA_NODES*2))"
Quoted 1 line
in next version. If yes, should we change x86 part? Because
NR_MEM_BANKSQuoted 4 lines
has not been defined in x86.
What I meant by configuring dynamically is allowing
NR_MEM_BANKSto beset by the user.
Quoted 2 lines
The second part of the MAX makes no sense to me (at least on Arm). So I
really prefer if this is not part of the initial version.
Quoted 2 lines
We can refine the value, or introduce the MAX in the future if we have a
justification for it.
Quoted 7 lines
OK, so for clarity the suggestion is:
- define
NR_NODE_MEMBLKSasNR_MEM_BANKSon ARM in this series
- in the future makeNR_MEM_BANKSuser-configurable via kconfig
- for now leaveNR_MEM_BANKSas 128 on ARMThat's fine by me.
Ok, I will only keep
#define NR_NODE_MEMBLKS NR_MEM_BANKS in asm-arm/numa.h, and left x86 NR_NODE_MEMBLKS definition as it was in asm-x86/numa.h Because in current stage, we can not unify them in on place. And I will update the commit message to log some of our discussion in this tthread.
PATCH 23/37 xen/arm: implement node distance helpers for Arm
In reply to Wei ChenWe will parse NUMA nodes distances from device tree or ACPI table. So we need a matrix to record the distances between any two nodes we parsed. Accordingly, we provide this node_set_distance API for device tree or ACPI table parsers to set the distance for any two nodes in this patch. When NUMA initialization failed, __node_distance will return NUMA_REMOTE_DISTANCE, this will help us avoid doing rollback for distance maxtrix when NUMA initialization failed.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa.c | 69 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 13 +++++++ 3 files changed, 83 insertions(+) create mode 100644 xen/arch/arm/numa.c
xen/arch/arm/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o +obj-$(CONFIG_NUMA) += numa.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.o
xen/arch/arm/numa.c new file +69 -0
69 lines not on this page · raw message
xen/include/asm-arm/numa.h +13 -0
@@ -9,8 +9,21 @@ typedef u8 nodeid_t;#ifdef CONFIG_NUMA +/* +* In ACPI spec, 0-9 are the reserved values for node distance, +* 10 indicates local node distance, 20 indicates remote node +* distance. Set node distance map in device tree will follow +* the ACPI's definition. +*/ +#define NUMA_DISTANCE_UDF_MIN 0 +#define NUMA_DISTANCE_UDF_MAX 9 +#define NUMA_LOCAL_DISTANCE 10 +#define NUMA_REMOTE_DISTANCE 20 +#define NR_NODE_MEMBLKS NR_MEM_BANKS +extern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance); +#else /* Fake one node for now. See also node_online_map. */
Signature · 1 line
2.25.1
Re: [PATCH 23/37] xen/arm: implement node distance helpers for Arm
Quoted 81 lines · Wei Chen
We will parse NUMA nodes distances from device tree or ACPI table. So we need a matrix to record the distances between any two nodes we parsed. Accordingly, we provide this
node_set_distanceAPI for device tree or ACPI table parsers to set the distance for any two nodes in this patch. When NUMA initialization failed,__node_distancewill returnNUMA_REMOTE_DISTANCE, this will help us avoid doing rollback for distance maxtrix when NUMA initialization failed.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa.c | 69 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 13 +++++++ 3 files changed, 83 insertions(+) create mode 100644 xen/arch/arm/numa.cxen/arch/arm/Makefile +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o +obj-$(CONFIG_NUMA) += numa.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.oxen/arch/arm/numa.c new file +46
-0@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +*/ +#include <xen/init.h> +#include <xen/numa.h> + +static uint8_t __read_mostly +node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = { + {0 } +}; + +void __init numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance) +{ +if ( from >=MAX_NUMNODES || to >=MAX_NUMNODES ) + { +printk (KERN_WARNING +"NUMA: invalid nodes: from=%" PRIu8" to=%" PRIu8" MAX=%" PRIu8"\n" , + from, to,MAX_NUMNODES ); +return ; + } + +/* NUMA defines 0xff as an unreachable node and 0-9 are undefined */ +if ( distance >=NUMA_NO_DISTANCE || + (distance >=NUMA_DISTANCE_UDF_MIN && + distance <=NUMA_DISTANCE_UDF_MAX ) || + (from == to && distance !=NUMA_LOCAL_DISTANCE ) ) + { +printk (KERN_WARNING +"NUMA: invalid distance: from=%" PRIu8" to=%" PRIu8" distance=%" PRIu32"\n" , + from, to, distance);
xen/arch/arm/numa.c line 56
Quoted 10 lines
xen/arch/arm/numa.c new file +10
-0+return ; + } + + node_distance_map[from][to] = distance; +} + +uint8_t __node_distance (nodeid_t from,nodeid_t to) +{ +/* When NUMA is off, any distance will be treated as remote. */ +if (srat_disabled () )
Given that this is ARM specific code and specific to ACPI, I don't think we should have any call to something called "srat_disabled".
I suggest to either rename srat_disabled to numa_distance_disabled.
Other than that, this patch looks OK to me.
Quoted 42 lines
xen/arch/arm/numa.c new file +13
-0+return NUMA_REMOTE_DISTANCE ; + +/* +* Check whether the nodes are in the matrix range. +* When any node is out of range, except from and to nodes are the +* same, we treat them as unreachable (return 0xFF) +*/ +if ( from >=MAX_NUMNODES || to >=MAX_NUMNODES ) +return from == to ?NUMA_LOCAL_DISTANCE :NUMA_NO_DISTANCE ; + +return node_distance_map[from][to]; +} +EXPORT_SYMBOL (__node_distance);xen/include/asm-arm/numa.h +13
-0@@ -9,8 +9,21 @@ typedef u8 nodeid_t;#ifdef CONFIG_NUMA +/* +* In ACPI spec, 0-9 are the reserved values for node distance, +* 10 indicates local node distance, 20 indicates remote node +* distance. Set node distance map in device tree will follow +* the ACPI's definition. +*/ +#define NUMA_DISTANCE_UDF_MIN 0 +#define NUMA_DISTANCE_UDF_MAX 9 +#define NUMA_LOCAL_DISTANCE 10 +#define NUMA_REMOTE_DISTANCE 20 +#define NR_NODE_MEMBLKS NR_MEM_BANKS +extern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance); +#else /* Fake one node for now. See also node_online_map. */ Signature · 1 line
2.25.1
RE: [PATCH 23/37] xen/arm: implement node distance helpers for Arm
Hi Stefano,
Quoted 109 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 9:47
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 23/37] xen/arm: implement node distance helpers for ArmQuoted 53 lines · Wei Chen
We will parse NUMA nodes distances from device tree or ACPI table. So we need a matrix to record the distances between any two nodes we parsed. Accordingly, we provide this
node_set_distanceAPI for device tree or ACPI table parsers to set the distance for any two nodes in this patch. When NUMA initialization failed,__node_distancewill returnNUMA_REMOTE_DISTANCE, this will help us avoid doing rollback for distance maxtrix when NUMA initialization failed.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa.c | 69 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 13 +++++++ 3 files changed, 83 insertions(+) create mode 100644 xen/arch/arm/numa.cxen/arch/arm/Makefile +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o +obj-$(CONFIG_NUMA) += numa.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.oxen/arch/arm/numa.c new file +18
-0@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* xen/arch/arm/numa.c line 28
Quoted 10 lines
xen/arch/arm/numa.c new file +10
-0+*/ +#include <xen/init.h> +#include <xen/numa.h> + +static uint8_t __read_mostly +node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = { + {0 } +}; + +void __init numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance)
xen/arch/arm/numa.c
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+{ + if ( from >= MAX_NUMNODES || to >= MAX_NUMNODES ) + { + printk(KERN_WARNING + "NUMA: invalid nodes: from=%"PRIu8" to=%"PRIu8"MAX=%"PRIu8"\n",
xen/arch/arm/numa.c
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+ from, to, MAX_NUMNODES); +return ; + } + +/* NUMA defines 0xff as an unreachable node and 0-9 are undefined */
xen/arch/arm/numa.c
Quoted 7 lines
xen/arch/arm/numa.c new file +7
-0+ if ( distance >= NUMA_NO_DISTANCE || + (distance >= NUMA_DISTANCE_UDF_MIN && + distance <= NUMA_DISTANCE_UDF_MAX) || + (from == to && distance != NUMA_LOCAL_DISTANCE) ) + { + printk(KERN_WARNING + "NUMA: invalid distance: from=%"PRIu8" to=%"PRIu8"distance=%"PRIu32"\n",
xen/arch/arm/numa.c line 56
Quoted 11 lines
xen/arch/arm/numa.c new file +11
-0+ from, to, distance); +return ; + } + + node_distance_map[from][to] = distance; +} + +uint8_t __node_distance (nodeid_t from,nodeid_t to) +{ +/* When NUMA is off, any distance will be treated as remote. */ +if (srat_disabled () )Given that this is ARM specific code and specific to ACPI, I don't think we should have any call to something called "
srat_disabled".
Quoted 4 lines
I suggest to either rename
srat_disabledtonuma_distance_disabled.Other than that, this patch looks OK to me.
srat stands for static resource affinity table, I think dtb also can be treated as a static resource affinity table. So I keep SRAT in this patch and other patches. I have seen your comment in patch#25. Before x86 maintainers give any feedback, can we still keep srat here?
Quoted 44 lines
Quoted 26 lines
xen/arch/arm/numa.c new file +13
-0+return NUMA_REMOTE_DISTANCE ; + +/* +* Check whether the nodes are in the matrix range. +* When any node is out of range, except from and to nodes are the +* same, we treat them as unreachable (return 0xFF) +*/ +if ( from >=MAX_NUMNODES || to >=MAX_NUMNODES ) +return from == to ?NUMA_LOCAL_DISTANCE :NUMA_NO_DISTANCE ; + +return node_distance_map[from][to]; +} +EXPORT_SYMBOL (__node_distance);xen/include/asm-arm/numa.h +4
-0@@ -9,8 +9,21 @@ typedef u8 nodeid_t;#ifdef CONFIG_NUMA +/* +* In ACPI spec, 0-9 are the reserved values for node distance, +* 10 indicates local node distance, 20 indicates remote node +* distance. Set node distance map in device tree will follow xen/include/asm-arm/numa.h typedef u8 nodeid_t; · line 25
Quoted 10 lines
xen/include/asm-arm/numa.h +8
-0+* the ACPI's definition. +*/ +#define NUMA_DISTANCE_UDF_MIN 0 +#define NUMA_DISTANCE_UDF_MAX 9 +#define NUMA_LOCAL_DISTANCE 10 +#define NUMA_REMOTE_DISTANCE 20 +#define NR_NODE_MEMBLKS NR_MEM_BANKS +extern void numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance);
Quoted 7 lines
xen/include/asm-arm/numa.h +1
-1+#else /* Fake one node for now. See also node_online_map. */ --2.25.1
RE: [PATCH 23/37] xen/arm: implement node distance helpers for Arm
Quoted 111 lines · Wei Chen
Quoted 111 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 9:47
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 23/37] xen/arm: implement node distance helpers for ArmQuoted 53 lines · Wei Chen
We will parse NUMA nodes distances from device tree or ACPI table. So we need a matrix to record the distances between any two nodes we parsed. Accordingly, we provide this
node_set_distanceAPI for device tree or ACPI table parsers to set the distance for any two nodes in this patch. When NUMA initialization failed,__node_distancewill returnNUMA_REMOTE_DISTANCE, this will help us avoid doing rollback for distance maxtrix when NUMA initialization failed.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa.c | 69 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 13 +++++++ 3 files changed, 83 insertions(+) create mode 100644 xen/arch/arm/numa.cxen/arch/arm/Makefile +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o +obj-$(CONFIG_NUMA) += numa.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.oxen/arch/arm/numa.c new file +18
-0@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* xen/arch/arm/numa.c line 28
Quoted 10 lines
xen/arch/arm/numa.c new file +10
-0+*/ +#include <xen/init.h> +#include <xen/numa.h> + +static uint8_t __read_mostly +node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = { + {0 } +}; + +void __init numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance)
xen/arch/arm/numa.c
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+{ + if ( from >= MAX_NUMNODES || to >= MAX_NUMNODES ) + { + printk(KERN_WARNING + "NUMA: invalid nodes: from=%"PRIu8" to=%"PRIu8"MAX=%"PRIu8"\n",
xen/arch/arm/numa.c
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+ from, to, MAX_NUMNODES); +return ; + } + +/* NUMA defines 0xff as an unreachable node and 0-9 are undefined */
xen/arch/arm/numa.c
Quoted 7 lines
xen/arch/arm/numa.c new file +7
-0+ if ( distance >= NUMA_NO_DISTANCE || + (distance >= NUMA_DISTANCE_UDF_MIN && + distance <= NUMA_DISTANCE_UDF_MAX) || + (from == to && distance != NUMA_LOCAL_DISTANCE) ) + { + printk(KERN_WARNING + "NUMA: invalid distance: from=%"PRIu8" to=%"PRIu8"distance=%"PRIu32"\n",
xen/arch/arm/numa.c line 56
Quoted 11 lines
xen/arch/arm/numa.c new file +11
-0+ from, to, distance); +return ; + } + + node_distance_map[from][to] = distance; +} + +uint8_t __node_distance (nodeid_t from,nodeid_t to) +{ +/* When NUMA is off, any distance will be treated as remote. */ +if (srat_disabled () )Given that this is ARM specific code and specific to ACPI, I don't think we should have any call to something called "
srat_disabled".I suggest to either rename
srat_disabledtonuma_distance_disabled.
Quoted 7 lines
Quoted 2 lines
Other than that, this patch looks OK to me.
srat stands for static resource affinity table, I think dtb also can be treated as a static resource affinity table. So I keep SRAT in this patch and other patches. I have seen your comment in patch#25. Before x86 maintainers give any feedback, can we still keep srat here?
Jan and I replied in the other thread. I think that in warning messages "SRAT" should not be mentioned when booting from DT. Ideally functions names and variables should be renamed too when shared between ACPI and DT but it is less critical, and it is fine if you don't do that in the next version.
RE: [PATCH 23/37] xen/arm: implement node distance helpers for Arm
Quoted 139 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月25日 3:36
To: Wei Chen <[email protected]>
Cc: Stefano Stabellini <[email protected]>; xen- [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: RE: [PATCH 23/37] xen/arm: implement node distance helpers for ArmQuoted 5 lines · Wei Chen
Quoted 5 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 9:47
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected];Quoted 2 lines
Quoted 2 lines
Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 23/37] xen/arm: implement node distance helpersfor
Quoted 12 lines
Quoted 12 lines
Arm
Quoted 9 lines · Wei Chen
We will parse NUMA nodes distances from device tree or ACPI table. So we need a matrix to record the distances between any two nodes we parsed. Accordingly, we provide this
node_set_distanceAPI for device tree or ACPI table parsers to set the distance for any two nodes in this patch. When NUMA initialization failed,__node_distancewill returnNUMA_REMOTE_DISTANCE, this will help us avoid doing rollback for distance maxtrix when NUMA initialization failed.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa.c | 69++++++++++++++++++++++++++++++++++++++
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
xen/include/asm-arm/numa.h | 13 +++++++ 3 files changed, 83 insertions(+) create mode 100644 xen/arch/arm/numa.cxen/arch/arm/Makefile +1
-0@@ -35,6 +35,7 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o +obj-$(CONFIG_NUMA) += numa.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.oxen/arch/arm/numa.c new file +0
-0Quoted 8 lines
Quoted 8 lines
xen/arch/arm/numa.c line 7
Quoted 8 lines
xen/arch/arm/numa.c new file +7
-0@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify
Quoted 1 line
Quoted 1 line
xen/arch/arm/numa.c line 8
Quoted 1 line
xen/arch/arm/numa.c new file +1
-0+* it under the terms of the GNU General Public License version 2 as
Quoted 8 lines
Quoted 8 lines
xen/arch/arm/numa.c
Quoted 8 lines
xen/arch/arm/numa.c new file +8
-0+* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License
Quoted 1 line
Quoted 1 line
xen/arch/arm/numa.c line 17
Quoted 1 line
xen/arch/arm/numa.c new file +1
-0+* along with this program. If not, see <http://www.gnu.org/licenses/>.
Quoted 17 lines
Quoted 17 lines
xen/arch/arm/numa.c
Quoted 11 lines
xen/arch/arm/numa.c new file +11
-0+* +*/ +#include <xen/init.h> +#include <xen/numa.h> + +static uint8_t __read_mostly +node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = { + {0 } +}; + +void __init numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance)
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+{ + if ( from >= MAX_NUMNODES || to >= MAX_NUMNODES ) + { + printk(KERN_WARNING + "NUMA: invalid nodes: from=%"PRIu8" to=%"PRIu8"Quoted 6 lines
Quoted 6 lines
MAX=%"PRIu8"\n",
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+ from, to, MAX_NUMNODES); +return ; + } + +/* NUMA defines 0xff as an unreachable node and 0-9 are undefined
Quoted 9 lines
Quoted 9 lines
*/
xen/arch/arm/numa.c
Quoted 7 lines
xen/arch/arm/numa.c new file +7
-0+ if ( distance >= NUMA_NO_DISTANCE || + (distance >= NUMA_DISTANCE_UDF_MIN && + distance <= NUMA_DISTANCE_UDF_MAX) || + (from == to && distance != NUMA_LOCAL_DISTANCE) ) + { + printk(KERN_WARNING + "NUMA: invalid distance: from=%"PRIu8" to=%"PRIu8"distance=%"PRIu32"\n",
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
xen/arch/arm/numa.c new file +5
-0+ from, to, distance); +return ; + } + + node_distance_map[from][to] = distance;Quoted 8 lines
xen/arch/arm/numa.c line 56
Quoted 6 lines
xen/arch/arm/numa.c new file +6
-0+} + +uint8_t __node_distance (nodeid_t from,nodeid_t to) +{ +/* When NUMA is off, any distance will be treated as remote. */ +if (srat_disabled () )Given that this is ARM specific code and specific to ACPI, I don't
think
Quoted 9 lines
Quoted 6 lines
we should have any call to something called "
srat_disabled".I suggest to either rename
srat_disabledtonuma_distance_disabled.Other than that, this patch looks OK to me.
srat stands for static resource affinity table, I think dtb also can be treated as a static resource affinity table. So I keep SRAT in this
patch
Quoted 1 line
and other patches. I have seen your comment in patch#25. Before x86
Quoted 8 lines
maintainers
Quoted 1 line
give any feedback, can we still keep srat here?
Jan and I replied in the other thread. I think that in warning messages "SRAT" should not be mentioned when booting from DT. Ideally functions names and variables should be renamed too when shared between ACPI and DT but it is less critical, and it is fine if you don't do that in the next version.
Thanks. I'll leave it as it is, if I do not have a better name.
PATCH 24/37 xen/arm: implement two arch helpers to get memory map info
In reply to Wei ChenThese two helpers are architecture APIs that are required by nodes_cover_memory.
--- xen/arch/arm/numa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
xen/arch/arm/numa.c +14 -0
@@ -67,3 +67,17 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to)return node_distance_map[from][to]; }EXPORT_SYMBOL (__node_distance); + +uint32_t __init arch_meminfo_get_nr_bank (void ) +{ +return bootinfo.mem.nr_banks; +} + +int __init arch_meminfo_get_ram_bank_range (uint32_t bank, +paddr_t *start,paddr_t *end) +{ + *start = bootinfo.mem.bank[bank].start; + *end = bootinfo.mem.bank[bank].start + bootinfo.mem.bank[bank].size; + +return 0 ; +}
Signature · 1 line
2.25.1
Re: [PATCH 24/37] xen/arm: implement two arch helpers to get memory map info
Quoted 20 lines · Wei Chen
These two helpers are architecture APIs that are required by
nodes_cover_memory.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)xen/arch/arm/numa.c +4
-0@@ -67,3 +67,17 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to)return node_distance_map[from][to]; }EXPORT_SYMBOL (__node_distance); + +uint32_t __init arch_meminfo_get_nr_bank (void ) +{ +return bootinfo.mem.nr_banks;
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 83
Quoted 10 lines
xen/arch/arm/numa.c +10
-0+} + +int __init arch_meminfo_get_ram_bank_range (uint32_t bank, +paddr_t *start,paddr_t *end) +{ + *start = bootinfo.mem.bank[bank].start; + *end = bootinfo.mem.bank[bank].start + bootinfo.mem.bank[bank].size; + +return 0 ; +}
The rest of the file is indented using spaces, while this patch is using tabs.
Also, given the implementation, it looks like arch_meminfo_get_ram_bank_range should either return void or bool.
RE: [PATCH 24/37] xen/arm: implement two arch helpers to get memory map info
Quoted 46 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 10:06
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 24/37] xen/arm: implement two arch helpers to get memory map infoQuoted 20 lines · Wei Chen
These two helpers are architecture APIs that are required by
nodes_cover_memory.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)xen/arch/arm/numa.c +4
-0@@ -67,3 +67,17 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to)return node_distance_map[from][to]; }EXPORT_SYMBOL (__node_distance); + +uint32_t __init arch_meminfo_get_nr_bank (void ) +{ +return bootinfo.mem.nr_banks;xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 83
Quoted 10 lines
xen/arch/arm/numa.c +10
-0+} + +int __init arch_meminfo_get_ram_bank_range (uint32_t bank, +paddr_t *start,paddr_t *end) +{ + *start = bootinfo.mem.bank[bank].start; + *end = bootinfo.mem.bank[bank].start + bootinfo.mem.bank[bank].size; + +return 0 ; +}The rest of the file is indented using spaces, while this patch is using tabs.
Quoted 2 lines
Also, given the implementation, it looks like
arch_meminfo_get_ram_bank_rangeshould either return void or bool.
I will fix them in next version.
PATCH 25/37 xen/arm: implement bad_srat for Arm NUMA initialization
In reply to Wei ChenNUMA initialization will parse information from firmware provided static resource affinity table (ACPI SRAT or DTB). bad_srat if a function that will be used when initialization code encounters some unexcepted errors.
In this patch, we introduce Arm version bad_srat for NUMA common initialization code to invoke it.
--- xen/arch/arm/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/arch/arm/numa.c +7 -0
@@ -18,6 +18,7 @@* */ #include <xen/init.h> +#include <xen/nodemask.h> #include <xen/numa.h> static uint8_t __read_mostly
@@ -25,6 +26,12 @@ node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { { 0 } }; +__init void bad_srat (void ) +{ +printk (KERN_ERR "NUMA: Firmware SRAT table not used.\n" ); + fw_numa =-1 ; +} +void __init numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance) {if ( from >=MAX_NUMNODES || to >=MAX_NUMNODES )
Signature · 1 line
2.25.1
Re: [PATCH 25/37] xen/arm: implement bad_srat for Arm NUMA initialization
Quoted 26 lines · Wei Chen
NUMA initialization will parse information from firmware provided static resource affinity table (ACPI SRAT or DTB).
bad_sratif a function that will be used when initialization code encounters some unexcepted errors.In this patch, we introduce Arm version
bad_sratfor NUMA common initialization code to invoke it.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/arm/numa.c +1
-0@@ -18,6 +18,7 @@* */ #include <xen/init.h> +#include <xen/nodemask.h> #include <xen/numa.h> static uint8_t __read_mostly
xen/arch/arm/numa.c node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { · line 33
Quoted 8 lines
xen/arch/arm/numa.c +5
-0@@ -25,6 +26,12 @@ node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { { 0 } }; +__init void bad_srat (void ) +{ +printk (KERN_ERR "NUMA: Firmware SRAT table not used.\n" ); + fw_numa =-1 ; +}
I realize that the series keeps the "srat" terminology everywhere on DT too. I wonder if it is worth replacing srat with something like "numa_distance" everywhere as appropriate. I am adding the x86 maintainers for an opinion.
If you guys prefer to keep srat (if nothing else, it is concise), I am also OK with keeping srat although it is not technically accurate.
RE: [PATCH 25/37] xen/arm: implement bad_srat for Arm NUMA initialization
Hi Stefano,
Quoted 51 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 10:10
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 25/37] xen/arm: implementbad_sratfor Arm NUMA initializationQuoted 26 lines · Wei Chen
NUMA initialization will parse information from firmware provided static resource affinity table (ACPI SRAT or DTB).
bad_sratif a function that will be used when initialization code encounters some unexcepted errors.In this patch, we introduce Arm version
bad_sratfor NUMA common initialization code to invoke it.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/arm/numa.c +1
-0@@ -18,6 +18,7 @@* */ #include <xen/init.h> +#include <xen/nodemask.h> #include <xen/numa.h> static uint8_t __read_mostlyxen/arch/arm/numa.c node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { · line 33
Quoted 8 lines
xen/arch/arm/numa.c +5
-0@@ -25,6 +26,12 @@ node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { { 0 } }; +__init void bad_srat (void ) +{ +printk (KERN_ERR "NUMA: Firmware SRAT table not used.\n" ); + fw_numa =-1 ; +}I realize that the series keeps the "srat" terminology everywhere on DT too. I wonder if it is worth replacing srat with something like "
numa_distance" everywhere as appropriate. I am adding the x86 maintainers for an opinion.
Quoted 2 lines
If you guys prefer to keep srat (if nothing else, it is concise), I am also OK with keeping srat although it is not technically accurate.
I have placed some comments in patch#23 for srat.
I wouldn't like to replace srat by numa_distance. because srat not only contains distance, and it also includes some affinity information for CPU or other devices.
Re: [PATCH 25/37] xen/arm: implement bad_srat for Arm NUMA initialization
In reply to Stefano StabelliniQuoted 41 lines · Stefano Stabellini
Quoted 26 lines · Wei Chen
NUMA initialization will parse information from firmware provided static resource affinity table (ACPI SRAT or DTB).
bad_sratif a function that will be used when initialization code encounters some unexcepted errors.In this patch, we introduce Arm version
bad_sratfor NUMA common initialization code to invoke it.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/arm/numa.c +1
-0@@ -18,6 +18,7 @@* */ #include <xen/init.h> +#include <xen/nodemask.h> #include <xen/numa.h> static uint8_t __read_mostlyxen/arch/arm/numa.c node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { · line 33
Quoted 8 lines
xen/arch/arm/numa.c +5
-0@@ -25,6 +26,12 @@ node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { { 0 } }; +__init void bad_srat (void ) +{ +printk (KERN_ERR "NUMA: Firmware SRAT table not used.\n" ); + fw_numa =-1 ; +}I realize that the series keeps the "srat" terminology everywhere on DT too. I wonder if it is worth replacing srat with something like "
numa_distance" everywhere as appropriate. I am adding the x86 maintainers for an opinion.
Quoted 2 lines
If you guys prefer to keep srat (if nothing else, it is concise), I am also OK with keeping srat although it is not technically accurate.
I think we want to tell apart both things: Where we truly talk about the firmware's SRAT table, keeping that name is fine. But I suppose there no "Firmware SRAT table" (as in the log message above) when using DT? If so, at the very least in log messages SRAT shouldn't be mentioned. Perhaps even functions serving both an ACPI and a DT purpose would better not use "srat" in their names (but I'm not as fussed about it there.)
Jan
Re: [PATCH 25/37] xen/arm: implement bad_srat for Arm NUMA initialization
Quoted 42 lines · Jan Beulich
Quoted 41 lines · Stefano Stabellini
Quoted 26 lines · Wei Chen
NUMA initialization will parse information from firmware provided static resource affinity table (ACPI SRAT or DTB).
bad_sratif a function that will be used when initialization code encounters some unexcepted errors.In this patch, we introduce Arm version
bad_sratfor NUMA common initialization code to invoke it.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/arm/numa.c +1
-0@@ -18,6 +18,7 @@* */ #include <xen/init.h> +#include <xen/nodemask.h> #include <xen/numa.h> static uint8_t __read_mostlyxen/arch/arm/numa.c node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { · line 33
Quoted 8 lines
xen/arch/arm/numa.c +5
-0@@ -25,6 +26,12 @@ node_distance_map[MAX_NUMNODES][MAX_NUMNODES] = { { 0 } }; +__init void bad_srat (void ) +{ +printk (KERN_ERR "NUMA: Firmware SRAT table not used.\n" ); + fw_numa =-1 ; +}I realize that the series keeps the "srat" terminology everywhere on DT too. I wonder if it is worth replacing srat with something like "
numa_distance" everywhere as appropriate. I am adding the x86 maintainers for an opinion.
Quoted 7 lines
Quoted 2 lines
If you guys prefer to keep srat (if nothing else, it is concise), I am also OK with keeping srat although it is not technically accurate.
I think we want to tell apart both things: Where we truly talk about the firmware's SRAT table, keeping that name is fine. But I suppose there no "Firmware SRAT table" (as in the log message above) when using DT?
No. FYI this is the DT binding:
https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/numa.txt
The interesting bit is the "distance-map"
Quoted 4 lines
If so, at the very least in log messages SRAT shouldn't be mentioned. Perhaps even functions serving both an ACPI and a DT purpose would better not use "srat" in their names (but I'm not as fussed about it there.)
I agree 100% with what you wrote.
PATCH 26/37 xen/arm: build NUMA cpu_to_node map in dt_smp_init_cpus
In reply to Wei ChenNUMA implementation has a cpu_to_node array to store CPU to NODE map. Xen is using CPU logical ID in runtime components, so we use CPU logical ID as CPU index in cpu_to_node.
In device tree case, cpu_logical_map is created in dt_smp_init_cpus. So, when NUMA is enabled, dt_smp_init_cpus will fetch CPU NUMA id at the same time for cpu_to_node.
--- xen/arch/arm/smpboot.c | 37 ++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/numa.h | 5 +++++ 2 files changed, 41 insertions(+), 1 deletion(-)
xen/arch/arm/smpboot.c +36 -1
@@ -121,7 +121,12 @@ static void __init dt_smp_init_cpus(void) { [0 ... NR_CPUS - 1] = MPIDR_INVALID }; +static nodeid_t node_map[NR_CPUS ]__initdata = + { + [0 ...NR_CPUS -1 ] =NUMA_NO_NODE + };bool bootcpu_valid = false; +uint32_t nid =0 ;int rc; mpidr = system_cpuinfo.mpidr.bits &MPIDR_HWID_MASK ;
@@ -172,6 +177,28 @@ static void __init dt_smp_init_cpus(void)continue ; } +if (IS_ENABLED (CONFIG_NUMA ) ) + { +/* +* When CONFIG_NUMA is set, try to fetch numa infomation +* from CPU dts node, otherwise the nid is always 0. +*/ +if ( !dt_property_read_u32 (cpu,"numa-node-id" , &nid) ) + { +printk (XENLOG_WARNING +"cpu[%d] dts path: %s: doesn't have numa information!\n" , + cpuidx,dt_node_full_name (cpu)); +/* +* During the early stage of NUMA initialization, when Xen +* found any CPU dts node doesn't have numa-node-id info, the +* NUMA will be treated as off, all CPU will be set to a FAKE +* node 0. So if we get numa-node-id failed here, we should +* set nid to 0. +*/ + nid =0 ; + } + } +/* * 8 MSBs must be set to 0 in the DT since the reg property * defines the MPIDR[23:0]
@@ -231,9 +258,12 @@ static void __init dt_smp_init_cpus(void) {printk ("cpu%d init failed (hwid %" PRIregister"): %d\n" , i, hwid, rc); tmp_map[i] =MPIDR_INVALID ; + node_map[i] =NUMA_NO_NODE ; } - else + else { tmp_map[i] = hwid; + node_map[i] = nid; + } }if ( !bootcpu_valid )
@@ -249,6 +279,11 @@ static void __init dt_smp_init_cpus(void)continue ;cpumask_set_cpu (i, &cpu_possible_map);cpu_logical_map (i) = tmp_map[i]; + + nid = node_map[i]; +if ( nid >=MAX_NUMNODES ) + nid =0 ; +numa_set_node (i, nid); } }
xen/include/asm-arm/numa.h +5 -0
@@ -46,6 +46,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_set_node (int cpu,nodeid_t node) +{ + +} +#endif static inline unsigned int arch_have_default_dmazone (void )
Signature · 1 line
2.25.1
Re: [PATCH 26/37] xen/arm: build NUMA cpu_to_node map in dt_smp_init_cpus
Quoted 35 lines · Wei Chen
NUMA implementation has a
cpu_to_nodearray to store CPU to NODE map. Xen is using CPU logical ID in runtime components, so we use CPU logical ID as CPU index incpu_to_node.In device tree case,
cpu_logical_mapis created indt_smp_init_cpus. So, when NUMA is enabled,dt_smp_init_cpuswill fetch CPU NUMA id at the same time forcpu_to_node.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/smpboot.c | 37 ++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/numa.h | 5 +++++ 2 files changed, 41 insertions(+), 1 deletion(-)xen/arch/arm/smpboot.c +5
-0@@ -121,7 +121,12 @@ static void __init dt_smp_init_cpus(void) { [0 ... NR_CPUS - 1] = MPIDR_INVALID }; +static nodeid_t node_map[NR_CPUS ]__initdata = + { + [0 ...NR_CPUS -1 ] =NUMA_NO_NODE + };bool bootcpu_valid = false; +uint32_t nid =0 ;int rc; mpidr = system_cpuinfo.mpidr.bits &MPIDR_HWID_MASK ;@@ -172,6 +177,28 @@ static void __init dt_smp_init_cpus(void)continue ; }
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 189
Quoted 10 lines
xen/arch/arm/smpboot.c +10
-0+if (IS_ENABLED (CONFIG_NUMA ) ) + { +/* +* When CONFIG_NUMA is set, try to fetch numa infomation +* from CPU dts node, otherwise the nid is always 0. +*/ +if ( !dt_property_read_u32 (cpu,"numa-node-id" , &nid) ) + { + printk(XENLOG_WARNING + "cpu[%d] dts path: %s: doesn't have numa information!\n",
^ %u
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 190
Quoted 1 line
xen/arch/arm/smpboot.c +1
-0+ cpuidx, dt_node_full_name(cpu));
I think that this message shouldn't be a warning: CONFIG_NUMA is a compile time option. Anybody that enables CONFIG_NUMA in the Xen build will get this warning printed out at boot time if Xen is booting on a regular non-NUMA machine, right?
The warning should only be printed if NUMA is actively enabled, e.g. there is a distance-map but the cpus don't have numa-node-id.
Quoted 59 lines
xen/arch/arm/smpboot.c +20
-1+/* +* During the early stage of NUMA initialization, when Xen +* found any CPU dts node doesn't have numa-node-id info, the +* NUMA will be treated as off, all CPU will be set to a FAKE +* node 0. So if we get numa-node-id failed here, we should +* set nid to 0. +*/ + nid =0 ; + } + } +/* * 8 MSBs must be set to 0 in the DT since the reg property * defines the MPIDR[23:0] @@ -231,9 +258,12 @@ static void __init dt_smp_init_cpus(void) {printk ("cpu%d init failed (hwid %" PRIregister"): %d\n" , i, hwid, rc); tmp_map[i] =MPIDR_INVALID ; + node_map[i] =NUMA_NO_NODE ; } - else + else { tmp_map[i] = hwid; + node_map[i] = nid; + } }if ( !bootcpu_valid )@@ -249,6 +279,11 @@ static void __init dt_smp_init_cpus(void)continue ;cpumask_set_cpu (i, &cpu_possible_map);cpu_logical_map (i) = tmp_map[i]; + + nid = node_map[i]; +if ( nid >=MAX_NUMNODES ) + nid =0 ; +numa_set_node (i, nid); } }xen/include/asm-arm/numa.h +5
-0@@ -46,6 +46,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_set_node (int cpu,nodeid_t node) +{ + +} +#endif static inline unsigned int arch_have_default_dmazone (void )Signature · 1 line
2.25.1
RE: [PATCH 26/37] xen/arm: build NUMA cpu_to_node map in dt_smp_init_cpus
Hi Stefano,
Quoted 61 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 10:26
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 26/37] xen/arm: build NUMAcpu_to_nodemap indt_smp_init_cpusQuoted 35 lines · Wei Chen
NUMA implementation has a
cpu_to_nodearray to store CPU to NODE map. Xen is using CPU logical ID in runtime components, so we use CPU logical ID as CPU index incpu_to_node.In device tree case,
cpu_logical_mapis created indt_smp_init_cpus. So, when NUMA is enabled,dt_smp_init_cpuswill fetch CPU NUMA id at the same time forcpu_to_node.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/smpboot.c | 37 ++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/numa.h | 5 +++++ 2 files changed, 41 insertions(+), 1 deletion(-)xen/arch/arm/smpboot.c +5
-0@@ -121,7 +121,12 @@ static void __init dt_smp_init_cpus(void) { [0 ... NR_CPUS - 1] = MPIDR_INVALID }; +static nodeid_t node_map[NR_CPUS ]__initdata = + { + [0 ...NR_CPUS -1 ] =NUMA_NO_NODE + };bool bootcpu_valid = false; +uint32_t nid =0 ;int rc; mpidr = system_cpuinfo.mpidr.bits &MPIDR_HWID_MASK ;@@ -172,6 +177,28 @@ static void __init dt_smp_init_cpus(void)continue ; }xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 189
Quoted 10 lines
xen/arch/arm/smpboot.c +10
-0+ if ( IS_ENABLED(CONFIG_NUMA) ) + { + /* + * When CONFIG_NUMA is set, try to fetch numa infomation + * from CPU dts node, otherwise the nid is always 0. + */ + if ( !dt_property_read_u32(cpu, "numa-node-id", &nid) ) + { + printk(XENLOG_WARNING + "cpu[%d] dts path: %s: doesn't have numainformation!\n",
^ %uxen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 190
Quoted 1 line
xen/arch/arm/smpboot.c +1
-0+ cpuidx, dt_node_full_name(cpu));
Quoted 9 lines
I think that this message shouldn't be a warning:
CONFIG_NUMAis a compile time option. Anybody that enablesCONFIG_NUMAin the Xen build will get this warning printed out at boot time if Xen is booting on a regular non-NUMA machine, right?The warning should only be printed if NUMA is actively enabled, e.g. there is a distance-map but the cpus don't have numa-node-id.
Yes, this message would be unexpected on a regular non-NUMA machine. I will some check condition to print this message.
Quoted 65 lines
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 192
Quoted 3 lines
xen/arch/arm/smpboot.c +2
-0+/* +* During the early stage of NUMA initialization, when Xen
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 193
Quoted 1 line
xen/arch/arm/smpboot.c +1
-0+* found any CPU dts node doesn't have numa-node-id info, the
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 194
Quoted 1 line
xen/arch/arm/smpboot.c +1
-0+* NUMA will be treated as off, all CPU will be set to a FAKE
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 195
Quoted 1 line
xen/arch/arm/smpboot.c +1
-0+* node 0. So if we get numa-node-id failed here, we should
xen/arch/arm/smpboot.c static void __init dt_smp_init_cpus(void) · line 259
Quoted 12 lines
xen/arch/arm/smpboot.c +6
-0+* set nid to 0. +*/ + nid =0 ; + } + } +/* * 8 MSBs must be set to 0 in the DT since the reg property * defines the MPIDR[23:0] @@ -231,9 +258,12 @@ static void __init dt_smp_init_cpus(void) { printk("cpu%d init failed (hwid %"PRIregister"): %d\n", i,hwid, rc);
Quoted 42 lines
xen/arch/arm/smpboot.c +9
-1tmp_map[i] =MPIDR_INVALID ; + node_map[i] =NUMA_NO_NODE ; } -else +else { tmp_map[i] = hwid; + node_map[i] = nid; + } }if ( !bootcpu_valid )@@ -249,6 +279,11 @@ static void __init dt_smp_init_cpus(void)continue ;cpumask_set_cpu (i, &cpu_possible_map);cpu_logical_map (i) = tmp_map[i]; + + nid = node_map[i]; +if ( nid >=MAX_NUMNODES ) + nid =0 ; +numa_set_node (i, nid); } }xen/include/asm-arm/numa.h +5
-1@@ -46,6 +46,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_set_node (int cpu,nodeid_t node) +{ + +} +#endif static inline unsigned int arch_have_default_dmazone (void ) --2.25.1
PATCH 27/37 xen/arm: Add boot and secondary CPU to NUMA system
In reply to Wei ChenIn this patch, we make NUMA node online and add cpu to its NUMA node. This will make NUMA-aware components have NUMA affinity data to support their work.
To keep the mostly the same behavior of x86, we still use srat_detect_node to online node. The difference is that, we have prepared cpu_to_node in dt_smp_init_cpus, so we don't need to setup cpu_to_node in srat_detect_node.
--- xen/arch/arm/numa.c | 10 ++++++++++ xen/arch/arm/setup.c | 5 +++++ xen/include/asm-arm/numa.h | 10 ++++++++++ 3 files changed, 25 insertions(+)
xen/arch/arm/numa.c +10 -0
@@ -32,6 +32,16 @@ __init void bad_srat(void) fw_numa =-1 ; } +void srat_detect_node (int cpu) +{ +nodeid_t node = cpu_to_node[cpu]; + +if ( node ==NUMA_NO_NODE ) + node =0 ; + +node_set_online (node); +} +void __init numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance) {if ( from >=MAX_NUMNODES || to >=MAX_NUMNODES )
xen/arch/arm/setup.c +5 -0
@@ -988,6 +988,11 @@ void __init start_xen(unsigned long boot_phys_offset,for_each_present_cpu ( i ) { +/* Detect and online node based on cpu_to_node[] */ +srat_detect_node (i); +/* Set up node_to_cpumask based on cpu_to_node[]. */ +numa_add_cpu (i); +if ( (num_online_cpus () < cpus) && !cpu_online (i) ) {int ret =cpu_up (i);
xen/include/asm-arm/numa.h +10 -0
@@ -46,11 +46,21 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_add_cpu (int cpu) +{ + +} +static inline void numa_set_node (int cpu,nodeid_t node) { } +static inline void srat_detect_node (int cpu) +{ + +} +#endif static inline unsigned int arch_have_default_dmazone (void )
Signature · 1 line
2.25.1
PATCH 28/37 xen/arm: stub memory hotplug access helpers for Arm
In reply to Wei ChenCommon code in NUMA need these two helpers to access/update memory hotplug end address. Arm has not support memory hotplug yet. So we stub these two helpers in this patch to make NUMA common code happy.
--- xen/include/asm-arm/mm.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
xen/include/asm-arm/mm.h +10 -0
@@ -362,6 +362,16 @@ void clear_and_clean_page(struct page_info *page);unsigned int arch_get_dma_bitsize (void ); +static inline void mem_hotplug_update_boundary (paddr_t end) +{ + +} + +static inline paddr_t mem_hotplug_boundary (void ) +{ +return 0 ; +} +#endif /* __ARCH_ARM_MM__ */ /* * Local variables:
Signature · 1 line
2.25.1
Re: [PATCH 28/37] xen/arm: stub memory hotplug access helpers for Arm
Quoted 17 lines · Wei Chen
Common code in NUMA need these two helpers to access/update memory hotplug end address. Arm has not support memory hotplug yet. So we stub these two helpers in this patch to make NUMA common code happy.
Signed-off-by Wei Chen <[email protected]>--- xen/include/asm-arm/mm.h | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/include/asm-arm/mm.h +0
-0@@ -362,6 +362,16 @@ void clear_and_clean_page(struct page_info *page);unsigned int arch_get_dma_bitsize (void );
xen/include/asm-arm/mm.h void clear_and_clean_page(struct page_info *page); · line 373
Quoted 10 lines
xen/include/asm-arm/mm.h +9
-0+static inline void mem_hotplug_update_boundary (paddr_t end) +{ + +} + +static inline paddr_t mem_hotplug_boundary (void ) +{ +return 0 ; +}
Why zero? Could it be INVALID_PADDR ?
RE: [PATCH 28/37] xen/arm: stub memory hotplug access helpers for Arm
Quoted 30 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 10:34
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 28/37] xen/arm: stub memory hotplug access helpers for ArmQuoted 18 lines · Wei Chen
Common code in NUMA need these two helpers to access/update memory hotplug end address. Arm has not support memory hotplug yet. So we stub these two helpers in this patch to make NUMA common code happy.
Signed-off-by Wei Chen <[email protected]>--- xen/include/asm-arm/mm.h | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/include/asm-arm/mm.h +0
-0@@ -362,6 +362,16 @@ void clear_and_clean_page(struct page_info *page);unsigned int arch_get_dma_bitsize (void );
Quoted 11 lines
xen/include/asm-arm/mm.h void clear_and_clean_page(struct page_info *page); · line 373
Quoted 9 lines
xen/include/asm-arm/mm.h +9
-0+static inline void mem_hotplug_update_boundary (paddr_t end) +{ + +} + +static inline paddr_t mem_hotplug_boundary (void ) +{ +return 0 ; +}Why zero? Could it be
INVALID_PADDR?
Yes, INVALID_PADDR is better.
PATCH 29/37 xen/arm: introduce a helper to parse device tree processor node
In reply to Wei ChenProcessor NUMA ID information is stored in device tree's processor node as "numa-node-id". We need a new helper to parse this ID from processor node. If we get this ID from processor node, this ID's validity still need to be checked. Once we got a invalid NUMA ID from any processor node, the device tree will be marked as NUMA information invalid.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa_device_tree.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/arch/arm/numa_device_tree.c
xen/arch/arm/Makefile +1 -0
@@ -36,6 +36,7 @@ obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_DEVICE_TREE_NUMA) += numa_device_tree.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.o
xen/arch/arm/numa_device_tree.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 29/37] xen/arm: introduce a helper to parse device tree processor node
Quoted 52 lines · Wei Chen
Processor NUMA ID information is stored in device tree's processor node as "numa-node-id". We need a new helper to parse this ID from processor node. If we get this ID from processor node, this ID's validity still need to be checked. Once we got a invalid NUMA ID from any processor node, the device tree will be marked as NUMA information invalid.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa_device_tree.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/arch/arm/numa_device_tree.cxen/arch/arm/Makefile +1
-0@@ -36,6 +36,7 @@ obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_DEVICE_TREE_NUMA) += numa_device_tree.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.oxen/arch/arm/numa_device_tree.c new file +20
-0@@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +*/ +#include <xen/init.h>
xen/arch/arm/numa_device_tree.c line 30
Quoted 10 lines
xen/arch/arm/numa_device_tree.c new file +10
-0+#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/libfdt/libfdt.h> +#include <xen/device_tree.h> + +/* Callback for device tree processor affinity */ +static int __init fdt_numa_processor_affinity_init (nodeid_t node) +{ +if (srat_disabled () ) +return -EINVAL ;
fdt_numa_processor_affinity_init is called by fdt_parse_numa_cpu_node which is already parsing NUMA related info. Should this srat_disabled check be moved to fdt_parse_numa_cpu_node?
Quoted 13 lines
xen/arch/arm/numa_device_tree.c new file +13
-0+else if ( node ==NUMA_NO_NODE || node >=MAX_NUMNODES ) + { +bad_srat (); +return -EINVAL ; + } + +numa_set_processor_nodes_parsed (node); + fw_numa =1 ; + +printk (KERN_INFO "DT: NUMA node %" PRIu7" processor parsed\n" , node); + +return 0 ; +}
xen/arch/arm/numa_device_tree.c line 53
Quoted 10 lines
xen/arch/arm/numa_device_tree.c new file +10
-0+ +/* Parse CPU NUMA node info */ +static int __init fdt_parse_numa_cpu_node (const void *fdt,int node) +{ +uint32_t nid; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); +if ( nid >=MAX_NUMNODES ) + { +printk (XENLOG_ERR "Node id %u exceeds maximum value\n" , nid);
^ PRIu32
Quoted 8 lines
xen/arch/arm/numa_device_tree.c new file +5
-0+return -EINVAL ; + } + +return fdt_numa_processor_affinity_init (nid); +}Signature · 1 line
2.25.1
RE: [PATCH 29/37] xen/arm: introduce a helper to parse device tree processor node
Quoted 70 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 10:45
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 29/37] xen/arm: introduce a helper to parse device tree processor nodeReview
Quoted 27 lines · Wei Chen
Processor NUMA ID information is stored in device tree's processor node as "numa-node-id". We need a new helper to parse this ID from processor node. If we get this ID from processor node, this ID's validity still need to be checked. Once we got a invalid NUMA ID from any processor node, the device tree will be marked as NUMA information invalid.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/numa_device_tree.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 xen/arch/arm/numa_device_tree.cxen/arch/arm/Makefile +1
-0@@ -36,6 +36,7 @@ obj-y += mem_access.o obj-y += mm.o obj-y += monitor.o obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_DEVICE_TREE_NUMA) += numa_device_tree.o obj-y += p2m.o obj-y += percpu.o obj-y += platform.o(quoted diff) +0
-0
b/xen/arch/arm/numa_device_tree.cQuoted 31 lines
new file mode 100644
index 0000000000..2428fbae0bxen/arch/arm/numa_device_tree.c new file +26
-0@@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Arm Architecture support layer for NUMA. +* +* Copyright (C) 2021 Arm Ltd +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +*/ +#include <xen/init.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/libfdt/libfdt.h> +#include <xen/device_tree.h> + +/* Callback for device tree processor affinity */
Quoted 9 lines
xen/arch/arm/numa_device_tree.c line 30
Quoted 4 lines
xen/arch/arm/numa_device_tree.c new file +4
-0+static int __init fdt_numa_processor_affinity_init (nodeid_t node) +{ +if (srat_disabled () ) +return -EINVAL ;
fdt_numa_processor_affinity_initis called byfdt_parse_numa_cpu_nodewhich is already parsing NUMA related info. Should thissrat_disabledcheck be moved tofdt_parse_numa_cpu_node?
Ah, yes, it's a good suggestion, I will address it in next version.
Quoted 35 lines
Quoted 14 lines
xen/arch/arm/numa_device_tree.c new file +13
-0+else if ( node ==NUMA_NO_NODE || node >=MAX_NUMNODES ) + { +bad_srat (); +return -EINVAL ; + } + +numa_set_processor_nodes_parsed (node); + fw_numa =1 ; + +printk (KERN_INFO "DT: NUMA node %" PRIu7" processor parsed\n" , node); + +return 0 ; +}xen/arch/arm/numa_device_tree.c line 53
Quoted 10 lines
xen/arch/arm/numa_device_tree.c new file +10
-0+ +/* Parse CPU NUMA node info */ +static int __init fdt_parse_numa_cpu_node (const void *fdt,int node) +{ +uint32_t nid; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); +if ( nid >=MAX_NUMNODES ) + { +printk (XENLOG_ERR "Node id %u exceeds maximum value\n" , nid);^ PRIu32Quoted 8 lines
xen/arch/arm/numa_device_tree.c new file +5
-1+return -EINVAL ; + } + +return fdt_numa_processor_affinity_init (nid); +} --2.25.1
PATCH 30/37 xen/arm: introduce a helper to parse device tree memory node
In reply to Wei ChenMemory blocks' NUMA ID information is stored in device tree's memory nodes as "numa-node-id". We need a new helper to parse and verify this ID from memory nodes.
--- xen/arch/arm/numa_device_tree.c | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
xen/arch/arm/numa_device_tree.c +80 -0
@@ -42,6 +42,35 @@ static int __init fdt_numa_processor_affinity_init(nodeid_t node)return 0 ; } +/* Callback for parsing of the memory regions affinity */ +static int __init fdt_numa_memory_affinity_init (nodeid_t node, +paddr_t start,paddr_t size) +{ +int ret; + +if (srat_disabled () ) + { +return -EINVAL ; + } + +if ( !numa_memblks_available () ) + { +dprintk (XENLOG_WARNING , +"Too many numa entry, try bigger NR_NODE_MEMBLKS \n" ); +bad_srat (); +return -EINVAL ; + } + + ret =numa_update_node_memblks (node, start, size, false); +if ( ret !=0 ) + { +bad_srat (); +return -EINVAL ; + } + +return 0 ; +} +/* Parse CPU NUMA node info */ static int __init fdt_parse_numa_cpu_node (const void *fdt,int node) {
@@ -56,3 +85,54 @@ static int __init fdt_parse_numa_cpu_node(const void *fdt, int node)return fdt_numa_processor_affinity_init (nid); } + +/* Parse memory node NUMA info */ +static int __init fdt_parse_numa_memory_node (const void *fdt,int node, +const char *name,uint32_t addr_cells,uint32_t size_cells) +{ +uint32_t nid; +int ret =0 , len; +paddr_t addr, size; +const struct fdt_property *prop; +uint32_t idx, ranges; +const __be32 *addresses; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); +if ( nid >=MAX_NUMNODES ) + { +printk (XENLOG_WARNING "Node id %u exceeds maximum value\n" , nid); +return -EINVAL ; + } + + prop =fdt_get_property (fdt, node,"reg" , &len); +if ( !prop ) + { +printk (XENLOG_WARNING +"fdt: node `%s': missing `reg' property\n" , name); +return -EINVAL ; + } + + addresses = (const __be32 *)prop->data; + ranges = len / (sizeof (__be32)* (addr_cells + size_cells)); +for ( idx =0 ; idx < ranges; idx++ ) + { +device_tree_get_reg (&addresses, addr_cells, size_cells, &addr, &size); +/* Skip zero size ranges */ +if ( !size ) +continue ; + + ret =fdt_numa_memory_affinity_init (nid, addr, size); +if ( ret ) { +return -EINVAL ; + } + } + +if ( idx ==0 ) + { +printk (XENLOG_ERR +"bad property in memory node, idx=%d ret=%d\n" , idx, ret); +return -EINVAL ; + } + +return 0 ; +}
Signature · 1 line
2.25.1
Re: [PATCH 30/37] xen/arm: introduce a helper to parse device tree memory node
Quoted 5 lines · Wei Chen
Memory blocks' NUMA ID information is stored in device tree's memory nodes as "numa-node-id". We need a new helper to parse and verify this ID from memory nodes.
Signed-off-by Wei Chen <[email protected]>
There are tabs for indentation in this patch, we use spaces.
Quoted 9 lines
--- xen/arch/arm/numa_device_tree.c | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)xen/arch/arm/numa_device_tree.c +0
-0
xen/arch/arm/numa_device_tree.c static int __init fdt_numa_processor_affinity_init(nodeid_t node) · line 47
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +3
-0@@ -42,6 +42,35 @@ static int __init fdt_numa_processor_affinity_init(nodeid_t node)return 0 ; } +/* Callback for parsing of the memory regions affinity */ +static int __init fdt_numa_memory_affinity_init (nodeid_t node, +paddr_t start,paddr_t size)
Please align the parameters
Quoted 15 lines
xen/arch/arm/numa_device_tree.c +15
-0+{ +int ret; + +if (srat_disabled () ) + { +return -EINVAL ; + } + +if ( !numa_memblks_available () ) + { +dprintk (XENLOG_WARNING , +"Too many numa entry, try bigger NR_NODE_MEMBLKS \n" ); +bad_srat (); +return -EINVAL ; + }
xen/arch/arm/numa_device_tree.c static int __init fdt_numa_processor_affinity_init(nodeid_t node) · line 72
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+ + ret =numa_update_node_memblks (node, start, size, false); +if ( ret !=0 ) + { +bad_srat (); +return -EINVAL ; + } + +return 0 ; +}
Aside from spaces/tabs, this is a lot better!
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node) · line 91
Quoted 11 lines
xen/arch/arm/numa_device_tree.c +4
-0/* Parse CPU NUMA node info */ static int __init fdt_parse_numa_cpu_node (const void *fdt,int node) {@@ -56,3 +85,54 @@ static int __init fdt_parse_numa_cpu_node(const void *fdt, int node)return fdt_numa_processor_affinity_init (nid); } + +/* Parse memory node NUMA info */ +static int __init fdt_parse_numa_memory_node (const void *fdt,int node, +const char *name,uint32_t addr_cells,uint32_t size_cells)
Please align the parameters
Quoted 27 lines
xen/arch/arm/numa_device_tree.c +27
-0+{ +uint32_t nid; +int ret =0 , len; +paddr_t addr, size; +const struct fdt_property *prop; +uint32_t idx, ranges; +const __be32 *addresses; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); +if ( nid >=MAX_NUMNODES ) + { +printk (XENLOG_WARNING "Node id %u exceeds maximum value\n" , nid); +return -EINVAL ; + } + + prop =fdt_get_property (fdt, node,"reg" , &len); +if ( !prop ) + { +printk (XENLOG_WARNING +"fdt: node `%s': missing `reg' property\n" , name); +return -EINVAL ; + } + + addresses = (const __be32 *)prop->data; + ranges = len / (sizeof (__be32)* (addr_cells + size_cells)); +for ( idx =0 ; idx < ranges; idx++ ) + {
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node) · line 128
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+device_tree_get_reg (&addresses, addr_cells, size_cells, &addr, &size); +/* Skip zero size ranges */ +if ( !size ) +continue ; + + ret =fdt_numa_memory_affinity_init (nid, addr, size); +if ( ret ) { +return -EINVAL ; + } + }
I take it would be difficult to parse numa-node-id and call fdt_numa_memory_affinity_init from xen/arch/arm/bootfdt.c:device_tree_get_meminfo. Is it because device_tree_get_meminfo is called too early?
Quoted 12 lines
xen/arch/arm/numa_device_tree.c +9
-0+if ( idx ==0 ) + { +printk (XENLOG_ERR +"bad property in memory node, idx=%d ret=%d\n" , idx, ret); +return -EINVAL ; + } + +return 0 ; +}Signature · 1 line
2.25.1
RE: [PATCH 30/37] xen/arm: introduce a helper to parse device tree memory node
Hi Stefano,
Quoted 9 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:05
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 30/37] xen/arm: introduce a helper to parse device tree memory node
Quoted 9 lines
Quoted 5 lines · Wei Chen
Memory blocks' NUMA ID information is stored in device tree's memory nodes as "numa-node-id". We need a new helper to parse and verify this ID from memory nodes.
Signed-off-by Wei Chen <[email protected]>There are tabs for indentation in this patch, we use spaces.
OK
Quoted 12 lines
Review
Quoted 6 lines
--- xen/arch/arm/numa_device_tree.c | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)(quoted diff) +0
-0
b/xen/arch/arm/numa_device_tree.cxen/arch/arm/numa_device_tree.c static int __init
Quoted 4 lines
index
2428fbae0b..7918a397fa100644xen/arch/arm/numa_device_tree.c +0
-0@@ -42,6 +42,35 @@ static int __init
fdt_numa_processor_affinity_init(nodeid_t node)
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_numa_processor_affinity_init(nodeid_t node) · line 47
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +3
-0return 0 ; } +/* Callback for parsing of the memory regions affinity */ +static int __init fdt_numa_memory_affinity_init (nodeid_t node, +paddr_t start,paddr_t size)Please align the parameters
OK
Quoted 20 lines
Quoted 20 lines
xen/arch/arm/numa_device_tree.c +19
-0+{ +int ret; + +if (srat_disabled () ) + { +return -EINVAL ; + } + +if ( !numa_memblks_available () ) + { +dprintk (XENLOG_WARNING , +"Too many numa entry, try bigger NR_NODE_MEMBLKS \n" ); +bad_srat (); +return -EINVAL ; + } + + ret =numa_update_node_memblks (node, start, size, false); +if ( ret !=0 ) + {
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_numa_processor_affinity_init(nodeid_t node) · line 72
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +6
-0+bad_srat (); +return -EINVAL ; + } + +return 0 ; +}Aside from spaces/tabs, this is a lot better!
ok
Quoted 7 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void
Quoted 5 lines
xen/arch/arm/numa_device_tree.c +0
-0/* Parse CPU NUMA node info */ static int __init fdt_parse_numa_cpu_node (const void *fdt,int node) {@@ -56,3 +85,54 @@ static int __init fdt_parse_numa_cpu_node(const void*fdt, int node)
Quoted 1 line
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node) · line 91
Quoted 6 lines
return fdt_numa_processor_affinity_init(nid);}
xen/arch/arm/numa_device_tree.c +4
-0+ +/* Parse memory node NUMA info */ +static int __init fdt_parse_numa_memory_node (const void *fdt,int node, +const char *name,uint32_t addr_cells,uint32_t size_cells)Please align the parameters
ok
Quoted 41 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node)
Quoted 13 lines
xen/arch/arm/numa_device_tree.c +12
-0+{ +uint32_t nid; +int ret =0 , len; +paddr_t addr, size; +const struct fdt_property *prop; +uint32_t idx, ranges; +const __be32 *addresses; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); +if ( nid >=MAX_NUMNODES ) + { + printk(XENLOG_WARNING "Node id %u exceeds maximum value\n",nid);
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +6
-0+return -EINVAL ; + } + + prop =fdt_get_property (fdt, node,"reg" , &len); +if ( !prop ) + {xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node)
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+printk (XENLOG_WARNING +"fdt: node `%s': missing `reg' property\n" , name); +return -EINVAL ; + } + + addresses = (const __be32 *)prop->data; + ranges = len / (sizeof (__be32)* (addr_cells + size_cells)); +for ( idx =0 ; idx < ranges; idx++ ) + { + device_tree_get_reg(&addresses, addr_cells, size_cells, &addr,&size);
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node) · line 128
Quoted 9 lines
xen/arch/arm/numa_device_tree.c +9
-0+/* Skip zero size ranges */ +if ( !size ) +continue ; + + ret =fdt_numa_memory_affinity_init (nid, addr, size); +if ( ret ) { +return -EINVAL ; + } + }
Quoted 5 lines
I take it would be difficult to parse numa-node-id and call
fdt_numa_memory_affinity_initfrom xen/arch/arm/bootfdt.c:device_tree_get_meminfo. Is it becausedevice_tree_get_meminfois called too early?
When I was composing this patch, penny's patch hadn't been merged. I will look into it.
Quoted 14 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_cpu_node(const void *fdt, int node)
Quoted 5 lines
xen/arch/arm/numa_device_tree.c +4
-0+if ( idx ==0 ) + { + printk(XENLOG_ERR + "bad property in memory node, idx=%d ret=%d\n", idx,ret);
Quoted 8 lines
xen/arch/arm/numa_device_tree.c +5
-1+return -EINVAL ; + } + +return 0 ; +} --2.25.1
PATCH 31/37 xen/arm: introduce a helper to parse device tree NUMA distance map
In reply to Wei ChenA NUMA aware device tree will provide a "distance-map" node to describe distance between any two nodes. This patch introduce a new helper to parse this distance map.
--- xen/arch/arm/numa_device_tree.c | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
xen/arch/arm/numa_device_tree.c +106 -0
@@ -136,3 +136,109 @@ static int __init fdt_parse_numa_memory_node(const void *fdt, int node,return 0 ; } + + +/* Parse NUMA distance map v1 */ +static int __init fdt_parse_numa_distance_map_v1 (const void *fdt,int node) +{ +const struct fdt_property *prop; +const __be32 *matrix; +uint32_t entry_count; +int len, i; + +printk (XENLOG_INFO "NUMA: parsing numa-distance-map\n" ); + + prop =fdt_get_property (fdt, node,"distance-matrix" , &len); +if ( !prop ) + { +printk (XENLOG_WARNING +"NUMA: No distance-matrix property in distance-map\n" ); + +return -EINVAL ; + } + +if ( len %sizeof (uint32_t ) !=0 ) + { +printk (XENLOG_WARNING +"distance-matrix in node is not a multiple of u32\n" ); +return -EINVAL ; + } + + entry_count = len /sizeof (uint32_t ); +if ( entry_count ==0 ) + { +printk (XENLOG_WARNING "NUMA: Invalid distance-matrix\n" ); + +return -EINVAL ; + } + + matrix = (const __be32 *)prop->data; +for ( i =0 ; i +2 < entry_count; i +=3 ) + { +uint32_t from, to, distance, opposite; + + from =dt_next_cell (1 , &matrix); + to =dt_next_cell (1 , &matrix); + distance =dt_next_cell (1 , &matrix); +if ( (from == to && distance !=NUMA_LOCAL_DISTANCE ) || + (from != to && distance <=NUMA_LOCAL_DISTANCE ) ) + { +printk (XENLOG_WARNING +"NUMA: Invalid distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); +return -EINVAL ; + } + +printk (XENLOG_INFO "NUMA: distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); + +/* Get opposite way distance */ + opposite =__node_distance (from, to); +if ( opposite ==0 ) + { +/* Bi-directions are not set, set both */ +numa_set_distance (from, to, distance); +numa_set_distance (to, from, distance); + } +else + { +/* +* Opposite way distance has been set to a different value. +* It may be a firmware device tree bug? +*/ +if ( opposite != distance ) + { +/* +* In device tree NUMA distance-matrix binding: +* https://www.kernel.org/doc/Documentation/devicetree/bindings/numa.txt +* There is a notes mentions: +* "Each entry represents distance from first node to +* second node. The distances are equal in either +* direction." +* +* That means device tree doesn't permit this case. +* But in ACPI spec, it cares to specifically permit this +* case: +* "Except for the relative distance from a System Locality +* to itself, each relative distance is stored twice in the +* matrix. This provides the capability to describe the +* scenario where the relative distances for the two +* directions between System Localities is different." +* +* That means a real machine allows such NUMA configuration. +* So, place a WARNING here to notice system administrators, +* is it the specail case that they hijack the device tree +* to support their rare machines? +*/ +printk (XENLOG_WARNING +"Un-matched bi-direction! NODE#%u->NODE#%u:%u, NODE#%u->NODE#%u:%u\n" , + from, to, distance, to, from, opposite); + } + +/* Opposite way distance has been set, just set this way */ +numa_set_distance (from, to, distance); + } + } + +return 0 ; +}
Signature · 1 line
2.25.1
Re: [PATCH 31/37] xen/arm: introduce a helper to parse device tree NUMA distance map
Quoted 24 lines · Wei Chen
A NUMA aware device tree will provide a "distance-map" node to describe distance between any two nodes. This patch introduce a new helper to parse this distance map.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa_device_tree.c | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)xen/arch/arm/numa_device_tree.c +7
-0@@ -136,3 +136,109 @@ static int __init fdt_parse_numa_memory_node(const void *fdt, int node,return 0 ; } + + +/* Parse NUMA distance map v1 */ +static int __init fdt_parse_numa_distance_map_v1 (const void *fdt,int node) +{ +const struct fdt_property *prop; +const __be32 *matrix;
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 155
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+uint32_t entry_count; +int len, i; + +printk (XENLOG_INFO "NUMA: parsing numa-distance-map\n" ); + + prop =fdt_get_property (fdt, node,"distance-matrix" , &len); +if ( !prop ) + { +printk (XENLOG_WARNING +"NUMA: No distance-matrix property in distance-map\n" );
I haven't seen where this is called from yet but make sure to print an error here only if NUMA info is actually expected and required, not on regular non-NUMA boots on non-NUMA machines.
Quoted 30 lines
xen/arch/arm/numa_device_tree.c +30
-0+return -EINVAL ; + } + +if ( len %sizeof (uint32_t ) !=0 ) + { +printk (XENLOG_WARNING +"distance-matrix in node is not a multiple of u32\n" ); +return -EINVAL ; + } + + entry_count = len /sizeof (uint32_t ); +if ( entry_count ==0 ) + { +printk (XENLOG_WARNING "NUMA: Invalid distance-matrix\n" ); + +return -EINVAL ; + } + + matrix = (const __be32 *)prop->data; +for ( i =0 ; i +2 < entry_count; i +=3 ) + { +uint32_t from, to, distance, opposite; + + from =dt_next_cell (1 , &matrix); + to =dt_next_cell (1 , &matrix); + distance =dt_next_cell (1 , &matrix); +if ( (from == to && distance !=NUMA_LOCAL_DISTANCE ) || + (from != to && distance <=NUMA_LOCAL_DISTANCE ) ) + { + printk(XENLOG_WARNING
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 196
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+"NUMA: Invalid distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); +return -EINVAL ; + } + +printk (XENLOG_INFO "NUMA: distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); + +/* Get opposite way distance */ + opposite =__node_distance (from, to);
This is not checking for the opposite node distance but...
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 201
Quoted 5 lines
xen/arch/arm/numa_device_tree.c +5
-0+if ( opposite ==0 ) + { +/* Bi-directions are not set, set both */ +numa_set_distance (from, to, distance); +numa_set_distance (to, from, distance);
...since you set both directions here at once then it is OK. You are checking if this direction has already been set which is correct I think. But the comment "Get opposite way distance" and the variable name "opposite" are wrong.
Quoted 24 lines
xen/arch/arm/numa_device_tree.c +24
-0+ } +else + { +/* +* Opposite way distance has been set to a different value. +* It may be a firmware device tree bug? +*/ +if ( opposite != distance ) + { +/* +* In device tree NUMA distance-matrix binding: +* https://www.kernel.org/doc/Documentation/devicetree/bindings/numa.txt +* There is a notes mentions: +* "Each entry represents distance from first node to +* second node. The distances are equal in either +* direction." +* +* That means device tree doesn't permit this case. +* But in ACPI spec, it cares to specifically permit this +* case: +* "Except for the relative distance from a System Locality +* to itself, each relative distance is stored twice in the +* matrix. This provides the capability to describe the +* scenario where the relative distances for the two
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 235
Quoted 10 lines
xen/arch/arm/numa_device_tree.c +10
-0+* directions between System Localities is different." +* +* That means a real machine allows such NUMA configuration. +* So, place a WARNING here to notice system administrators, +* is it the specail case that they hijack the device tree +* to support their rare machines? +*/ +printk (XENLOG_WARNING +"Un-matched bi-direction! NODE#%u->NODE#%u:%u, NODE#%u->NODE#%u:%u\n" , + from, to, distance, to, from, opposite);
PRIu32
Quoted 12 lines
xen/arch/arm/numa_device_tree.c +9
-0+ } + +/* Opposite way distance has been set, just set this way */ +numa_set_distance (from, to, distance); + } + } + +return 0 ; +}Signature · 1 line
2.25.1
RE: [PATCH 31/37] xen/arm: introduce a helper to parse device tree NUMA distance map
Hi Stefano,
Quoted 43 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:05
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 31/37] xen/arm: introduce a helper to parse device tree NUMA distance mapReview
Quoted 10 lines · Wei Chen
A NUMA aware device tree will provide a "distance-map" node to describe distance between any two nodes. This patch introduce a new helper to parse this distance map.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa_device_tree.c | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)(quoted diff) +0
-0
b/xen/arch/arm/numa_device_tree.cxen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const
Quoted 4 lines
index
7918a397fa..e7fa84df4c100644xen/arch/arm/numa_device_tree.c +0
-0@@ -136,3 +136,109 @@ static int __init fdt_parse_numa_memory_node(constvoid *fdt, int node,
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node,
Quoted 7 lines
xen/arch/arm/numa_device_tree.c +4
-0return 0 ; } + + +/* Parse NUMA distance map v1 */ +static int __init fdt_parse_numa_distance_map_v1(const void *fdt, intnode)
Quoted 9 lines
xen/arch/arm/numa_device_tree.c +9
-0+{ +const struct fdt_property *prop; +const __be32 *matrix; +uint32_t entry_count; +int len, i; + +printk (XENLOG_INFO "NUMA: parsing numa-distance-map\n" ); + + prop =fdt_get_property (fdt, node,"distance-matrix" , &len);
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 155
Quoted 4 lines
xen/arch/arm/numa_device_tree.c +4
-0+if ( !prop ) + { +printk (XENLOG_WARNING +"NUMA: No distance-matrix property in distance-map\n" );I haven't seen where this is called from yet but make sure to print an error here only if NUMA info is actually expected and required, not on regular non-NUMA boots on non-NUMA machines.
Only users enable NUMA option and numa_off is false, then Xen can run into this function (this check is in numa_init). So non-NUMA machines will not reach here.
Quoted 35 lines
Quoted 35 lines
xen/arch/arm/numa_device_tree.c +34
-0+return -EINVAL ; + } + +if ( len %sizeof (uint32_t ) !=0 ) + { +printk (XENLOG_WARNING +"distance-matrix in node is not a multiple of u32\n" ); +return -EINVAL ; + } + + entry_count = len /sizeof (uint32_t ); +if ( entry_count ==0 ) + { +printk (XENLOG_WARNING "NUMA: Invalid distance-matrix\n" ); + +return -EINVAL ; + } + + matrix = (const __be32 *)prop->data; +for ( i =0 ; i +2 < entry_count; i +=3 ) + { +uint32_t from, to, distance, opposite; + + from =dt_next_cell (1 , &matrix); + to =dt_next_cell (1 , &matrix); + distance =dt_next_cell (1 , &matrix); +if ( (from == to && distance !=NUMA_LOCAL_DISTANCE ) || + (from != to && distance <=NUMA_LOCAL_DISTANCE ) ) + { +printk (XENLOG_WARNING +"NUMA: Invalid distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); +return -EINVAL ; + }
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 196
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +6
-0+ +printk (XENLOG_INFO "NUMA: distance: NODE#%u->NODE#%u:%u\n" , + from, to, distance); + +/* Get opposite way distance */ + opposite =__node_distance (from, to);This is not checking for the opposite node distance but...
Ah, yes, it's a mistake. It should be __node_distance(to, from);
Quoted 7 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 201
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +5
-0+if ( opposite ==0 ) + { +/* Bi-directions are not set, set both */ +numa_set_distance (from, to, distance); +numa_set_distance (to, from, distance);
Quoted 5 lines
...since you set both directions here at once then it is OK. You are checking if this direction has already been set which is correct I think. But the comment "Get opposite way distance" and the variable name "opposite" are wrong.
My above mistake make this mis-understanding:
I want to check the opposite way distance is set or not. If opposite way distance is not set, I will set both way here.
So I will change " opposite = __node_distance(from, to);" to " opposite = __node_distance(to, from);". And keep the comment. How do you think about it?
Quoted 38 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 218
Quoted 13 lines
xen/arch/arm/numa_device_tree.c +12
-0+ } +else + { +/* +* Opposite way distance has been set to a different value. +* It may be a firmware device tree bug? +*/ +if ( opposite != distance ) + { +/* +* In device tree NUMA distance-matrix binding: +* https://www.kernel.org/doc/Documentation/devicetree/bindings/numa.txt
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node,
Quoted 7 lines
xen/arch/arm/numa_device_tree.c +7
-0+* There is a notes mentions: +* "Each entry represents distance from first node to +* second node. The distances are equal in either +* direction." +* +* That means device tree doesn't permit this case. +* But in ACPI spec, it cares to specifically permit this
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const · line 220
Quoted 2 lines
xen/arch/arm/numa_device_tree.c +2
-0+* case: +* "Except for the relative distance from a System Locality
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const · line 221
Quoted 1 line
xen/arch/arm/numa_device_tree.c +1
-0+* to itself, each relative distance is stored twice in the
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const · line 222
Quoted 1 line
xen/arch/arm/numa_device_tree.c +1
-0+* matrix. This provides the capability to describe the
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node,
Quoted 4 lines
xen/arch/arm/numa_device_tree.c +4
-0+* scenario where the relative distances for the two +* directions between System Localities is different." +* +* That means a real machine allows such NUMA configuration.
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const · line 227
Quoted 1 line
xen/arch/arm/numa_device_tree.c +1
-0+* So, place a WARNING here to notice system administrators,
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const · line 228
Quoted 1 line
xen/arch/arm/numa_device_tree.c +1
-0+* is it the specail case that they hijack the device tree
Quoted 8 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node,
Quoted 4 lines
xen/arch/arm/numa_device_tree.c +4
-0+* to support their rare machines? +*/ + printk(XENLOG_WARNING + "Un-matched bi-direction! NODE#%u->NODE#%u:%u,NODE#%u->NODE#%u:%u\n",
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_memory_node(const void *fdt, int node, · line 235
Quoted 1 line
xen/arch/arm/numa_device_tree.c +1
-0+ from, to, distance, to, from, opposite);PRIu32
Yes.
Quoted 14 lines
Quoted 14 lines
xen/arch/arm/numa_device_tree.c +9
-1+ } + +/* Opposite way distance has been set, just set this way */ +numa_set_distance (from, to, distance); + } + } + +return 0 ; +} --2.25.1
PATCH 32/37 xen/arm: unified entry to parse all NUMA data from device tree
In reply to Wei ChenIn this API, we scan whole device tree to parse CPU node id, memory node id and distance-map. Though early_scan_node will invoke has a handler to process memory nodes. If we want to parse memory node id in this handler, we have to embeded NUMA parse code in this handler. But we still need to scan whole device tree to find CPU NUMA id and distance-map. In this case, we include memory NUMA id parse in this API too. Another benefit is that we have a unique entry for device tree NUMA data parse.
--- xen/arch/arm/numa_device_tree.c | 30 ++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 1 + 2 files changed, 31 insertions(+)
xen/arch/arm/numa_device_tree.c +30 -0
@@ -242,3 +242,33 @@ static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node)return 0 ; } + +static int __init fdt_scan_numa_nodes (const void *fdt, +int node,const char *uname,int depth, +u32 address_cells,u32 size_cells,void *data) +{ +int len, ret =0 ; +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" , &len); +if (prop) + { + len +=1 ; +if (memcmp (prop,"cpu" , len) ==0 ) + ret =fdt_parse_numa_cpu_node (fdt, node); +else if (memcmp (prop,"memory" , len) ==0 ) + ret =fdt_parse_numa_memory_node (fdt, node, uname, + address_cells, size_cells); + } +else if (fdt_node_check_compatible (fdt, node, +"numa-distance-map-v1" ) ==0 ) + ret =fdt_parse_numa_distance_map_v1 (fdt, node); + +return ret; +} + +/* Initialize NUMA from device tree */ +int __init numa_device_tree_init (const void *fdt) +{ +return device_tree_for_each_node (fdt,0 , fdt_scan_numa_nodes,NULL ); +}
xen/include/asm-arm/numa.h +1 -0
@@ -23,6 +23,7 @@ typedef u8 nodeid_t;#define NR_NODE_MEMBLKS NR_MEM_BANKSextern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance); +extern int numa_device_tree_init (const void *fdt);#else
Signature · 1 line
2.25.1
Re: [PATCH 32/37] xen/arm: unified entry to parse all NUMA data from device tree
Quoted 1 line · Wei Chen
In this API, we scan whole device tree to parse CPU node id, memory
^ function ^ the whole
Quoted 3 lines
node id and distance-map. Though
early_scan_nodewill invoke has a handler to process memory nodes. If we want to parse memory node id in this handler, we have to embeded NUMA parse code in this handler.
^ embed
Quoted 3 lines
But we still need to scan whole device tree to find CPU NUMA id and distance-map. In this case, we include memory NUMA id parse in this API too. Another benefit is that we have a unique entry for device
^ function
Quoted 1 line
tree NUMA data parse.
Ah, that's the explanation I was asking for earlier!
Quoted 11 lines
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa_device_tree.c | 30 ++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 1 + 2 files changed, 31 insertions(+)xen/arch/arm/numa_device_tree.c +0
-0
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 248
Quoted 7 lines
xen/arch/arm/numa_device_tree.c +4
-0@@ -242,3 +242,33 @@ static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node)return 0 ; } + +static int __init fdt_scan_numa_nodes (const void *fdt, +int node,const char *uname,int depth, +u32 address_cells,u32 size_cells,void *data)
Please align parameters
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 254
Quoted 6 lines
xen/arch/arm/numa_device_tree.c +6
-0+{ +int len, ret =0 ; +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" , &len); +if (prop)
code style
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 261
Quoted 7 lines
xen/arch/arm/numa_device_tree.c +7
-0+ { + len +=1 ; +if (memcmp (prop,"cpu" , len) ==0 ) + ret =fdt_parse_numa_cpu_node (fdt, node); +else if (memcmp (prop,"memory" , len) ==0 ) + ret =fdt_parse_numa_memory_node (fdt, node, uname, + address_cells, size_cells);
I realize that with the inclusion of '\0' in the check, the usage of memcmp should be safe, but I would prefer if we used strncmp instead.
Quoted 28 lines
xen/arch/arm/numa_device_tree.c +13
-0+ } +else if (fdt_node_check_compatible (fdt, node, +"numa-distance-map-v1" ) ==0 ) + ret =fdt_parse_numa_distance_map_v1 (fdt, node); + +return ret; +} + +/* Initialize NUMA from device tree */ +int __init numa_device_tree_init (const void *fdt) +{ +return device_tree_for_each_node (fdt,0 , fdt_scan_numa_nodes,NULL ); +}xen/include/asm-arm/numa.h +1
-0@@ -23,6 +23,7 @@ typedef u8 nodeid_t;#define NR_NODE_MEMBLKS NR_MEM_BANKSextern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance); +extern int numa_device_tree_init (const void *fdt);#else Signature · 1 line
2.25.1
RE: [PATCH 32/37] xen/arm: unified entry to parse all NUMA data from device tree
Hi Stefano,
Quoted 18 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:17
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 32/37] xen/arm: unified entry to parse all NUMA data from device treeQuoted 1 line · Wei Chen
In this API, we scan whole device tree to parse CPU node id, memory
^ function ^ the whole
Quoted 3 lines
node id and distance-map. Though
early_scan_nodewill invoke has a handler to process memory nodes. If we want to parse memory node id in this handler, we have to embeded NUMA parse code in this handler.^ embed
Quoted 9 lines
Quoted 3 lines
But we still need to scan whole device tree to find CPU NUMA id and distance-map. In this case, we include memory NUMA id parse in this API too. Another benefit is that we have a unique entry for device
^ function
Quoted 1 line
tree NUMA data parse.
Ah, that's the explanation I was asking for earlier!
The question about device_tree_get_meminfo?
Quoted 15 lines
Review
Quoted 8 lines
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa_device_tree.c | 30 ++++++++++++++++++++++++++++++ xen/include/asm-arm/numa.h | 1 + 2 files changed, 31 insertions(+)(quoted diff) +0
-0
b/xen/arch/arm/numa_device_tree.cxen/arch/arm/numa_device_tree.c static int __init
Quoted 4 lines
index
e7fa84df4c..6a3fed0002100644xen/arch/arm/numa_device_tree.c +0
-0@@ -242,3 +242,33 @@ static int __init
fdt_parse_numa_distance_map_v1(const void *fdt, int node)Quoted 1 line
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 248
Quoted 6 lines
return 0;}
xen/arch/arm/numa_device_tree.c +4
-0+ +static int __init fdt_scan_numa_nodes (const void *fdt, +int node,const char *uname,int depth, +u32 address_cells,u32 size_cells,void *data)Please align parameters
OK
Quoted 10 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 254
Quoted 7 lines
xen/arch/arm/numa_device_tree.c +6
-0+{ +int len, ret =0 ; +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" , &len); +if (prop)code style
OK
Quoted 9 lines
xen/arch/arm/numa_device_tree.c static int __init fdt_parse_numa_distance_map_v1(const void *fdt, int node) · line 261
Quoted 8 lines
xen/arch/arm/numa_device_tree.c +7
-0+ { + len +=1 ; +if (memcmp (prop,"cpu" , len) ==0 ) + ret =fdt_parse_numa_cpu_node (fdt, node); +else if (memcmp (prop,"memory" , len) ==0 ) + ret =fdt_parse_numa_memory_node (fdt, node, uname, + address_cells, size_cells);
Quoted 3 lines
I realize that with the inclusion of '\0' in the check, the usage of memcmp should be safe, but I would prefer if we used strncmp instead.
Ok, I will use strncmp in next version.
Quoted 30 lines
Quoted 19 lines
xen/arch/arm/numa_device_tree.c +13
-0+ } +else if (fdt_node_check_compatible (fdt, node, +"numa-distance-map-v1" ) ==0 ) + ret =fdt_parse_numa_distance_map_v1 (fdt, node); + +return ret; +} + +/* Initialize NUMA from device tree */ +int __init numa_device_tree_init (const void *fdt) +{ +return device_tree_for_each_node (fdt,0 , fdt_scan_numa_nodes,NULL ); +}xen/include/asm-arm/numa.h +0
-0xen/include/asm-arm/numa.h typedef u8 nodeid_t; · line 25
Quoted 3 lines
xen/include/asm-arm/numa.h +0
-0@@ -23,6 +23,7 @@ typedef u8 nodeid_t;#define NR_NODE_MEMBLKS NR_MEM_BANKS extern void numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance);
Quoted 7 lines
xen/include/asm-arm/numa.h +1
-1+extern int numa_device_tree_init (const void *fdt);#else --2.25.1
RE: [PATCH 32/37] xen/arm: unified entry to parse all NUMA data from device tree
Quoted 21 lines · Wei Chen
Quoted 21 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:17
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 32/37] xen/arm: unified entry to parse all NUMA data from device treeQuoted 1 line · Wei Chen
In this API, we scan whole device tree to parse CPU node id, memory
^ function ^ the whole
Quoted 3 lines
node id and distance-map. Though
early_scan_nodewill invoke has a handler to process memory nodes. If we want to parse memory node id in this handler, we have to embeded NUMA parse code in this handler.^ embed
Quoted 3 lines
But we still need to scan whole device tree to find CPU NUMA id and distance-map. In this case, we include memory NUMA id parse in this API too. Another benefit is that we have a unique entry for device
Quoted 8 lines
Quoted 6 lines
^ function
Quoted 1 line
tree NUMA data parse.
Ah, that's the explanation I was asking for earlier!
The question about
device_tree_get_meminfo?
Yes, it would be nice to reuse process_memory_node if we can, but I understand if we cannot.
PATCH 33/37 xen/arm: keep guest still be NUMA unware
In reply to Wei ChenThe NUMA information provided in the host Device-Tree are only for Xen. For dom0, we want to hide them as they may be different (for now, dom0 is still not aware of NUMA) The CPU and memory nodes are recreated from scratch for the domain. So we already skip the "numa-node-id" property for these two types of nodes.
However, some devices like PCIe may have "numa-node-id" property too. We have to skip them as well.
--- xen/arch/arm/domain_build.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/arm/domain_build.c +6 -0
@@ -737,6 +737,10 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,continue ; } +/* Guest is numa unaware in current stage */ +if (dt_property_name_is_equal (prop,"numa-node-id" ) ) +continue ; + res =fdt_property (kinfo->fdt, prop->name, prop_data, prop_len);if ( res )
@@ -1607,6 +1611,8 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,DT_MATCH_TYPE ("memory" ),/* The memory mapped timer is not supported by Xen. */ DT_MATCH_COMPATIBLE ("arm,armv7-timer-mem" ), +/* Numa info doesn't need to be exposed to Domain-0 */ + DT_MATCH_COMPATIBLE("numa-distance-map-v1"), { /* sentinel */ }, }; static const struct dt_device_match timer_matches[] __initconst =
Signature · 1 line
2.25.1
Re: [PATCH 33/37] xen/arm: keep guest still be NUMA unware
Quoted 20 lines · Wei Chen
The NUMA information provided in the host Device-Tree are only for Xen. For dom0, we want to hide them as they may be different (for now, dom0 is still not aware of NUMA) The CPU and memory nodes are recreated from scratch for the domain. So we already skip the "numa-node-id" property for these two types of nodes.
However, some devices like PCIe may have "numa-node-id" property too. We have to skip them as well.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/domain_build.c | 6 ++++++ 1 file changed, 6 insertions(+)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c static int __init write_properties(struct domain *d, struct kernel_info *kinfo, · line 740
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -737,6 +737,10 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,continue ; } +/* Guest is numa unaware in current stage */
I would say: "Dom0 is currently NUMA unaware"
Quoted 18 lines
xen/arch/arm/domain_build.c +5
-0+if (dt_property_name_is_equal (prop,"numa-node-id" ) ) +continue ; + res =fdt_property (kinfo->fdt, prop->name, prop_data, prop_len);if ( res )@@ -1607,6 +1611,8 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,DT_MATCH_TYPE ("memory" ),/* The memory mapped timer is not supported by Xen. */ DT_MATCH_COMPATIBLE ("arm,armv7-timer-mem" ), +/* Numa info doesn't need to be exposed to Domain-0 */ + DT_MATCH_COMPATIBLE("numa-distance-map-v1"), { /* sentinel */ }, }; static const struct dt_device_match timer_matches[] __initconst =Signature · 1 line
2.25.1
RE: [PATCH 33/37] xen/arm: keep guest still be NUMA unware
Quoted 31 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:19
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 33/37] xen/arm: keep guest still be NUMA unwarexen/arch/arm/domain_build.c static int __init write_properties(struct domain *d,
Quoted 20 lines · Wei Chen
The NUMA information provided in the host Device-Tree are only for Xen. For dom0, we want to hide them as they may be different (for now, dom0 is still not aware of NUMA) The CPU and memory nodes are recreated from scratch for the domain. So we already skip the "numa-node-id" property for these two types of nodes.
However, some devices like PCIe may have "numa-node-id" property too. We have to skip them as well.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/domain_build.c | 6 ++++++ 1 file changed, 6 insertions(+)xen/arch/arm/domain_build.c +0
-0@@ -737,6 +737,10 @@ static int __init write_properties(struct domain *d,struct
kernel_info*kinfo,
Quoted 9 lines
xen/arch/arm/domain_build.c static int __init write_properties(struct domain *d, struct kernel_info *kinfo, · line 740
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0continue ; } +/* Guest is numa unaware in current stage */ I would say: "Dom0 is currently NUMA unaware"
Reviewed-by Stefano Stabellini <[email protected]>
I will update the code comment in next version.
Thanks!
Quoted 20 lines
xen/arch/arm/domain_build.c static int __init handle_node(struct domain *d,
Quoted 8 lines
xen/arch/arm/domain_build.c +3
-0+if (dt_property_name_is_equal (prop,"numa-node-id" ) ) +continue ; + res =fdt_property (kinfo->fdt, prop->name, prop_data, prop_len);if ( res )@@ -1607,6 +1611,8 @@ static int __init handle_node(struct domain *d,struct
kernel_info*kinfo,Quoted 11 lines
xen/arch/arm/domain_build.c +2
-1DT_MATCH_TYPE ("memory" ),/* The memory mapped timer is not supported by Xen. */ DT_MATCH_COMPATIBLE ("arm,armv7-timer-mem" ), +/* Numa info doesn't need to be exposed to Domain-0 */ + DT_MATCH_COMPATIBLE("numa-distance-map-v1"), { /* sentinel */ }, }; static const struct dt_device_match timer_matches[] __initconst = --2.25.1
PATCH 34/37 xen/arm: enable device tree based NUMA in system init
In reply to Wei ChenIn this patch, we can start to create NUMA system that is based on device tree.
--- xen/arch/arm/numa.c | 55 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 7 +++++ xen/include/asm-arm/numa.h | 6 +++++ 3 files changed, 68 insertions(+)
xen/arch/arm/numa.c +55 -0
@@ -18,8 +18,10 @@* */ #include <xen/init.h> +#include <xen/device_tree.h> #include <xen/nodemask.h> #include <xen/numa.h> +#include <xen/pfn.h> static uint8_t __read_mostly node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = {
@@ -85,6 +87,59 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to) }EXPORT_SYMBOL (__node_distance); +void __init numa_init (bool acpi_off) +{ +uint32_t idx; +paddr_t ram_start = ~0 ; +paddr_t ram_size =0 ; +paddr_t ram_end =0 ; + +/* NUMA has been turned off through Xen parameters */ +if ( numa_off ) + goto mem_init; + +/* Initialize NUMA from device tree when system is not ACPI booted */ +if ( acpi_off ) + { +int ret =numa_device_tree_init (device_tree_flattened); +if ( ret ) + { +printk (XENLOG_WARNING +"Init NUMA from device tree failed, ret=%d\n" , ret); + numa_off = true; + } + } +else + { +/* We don't support NUMA for ACPI boot currently */ +printk (XENLOG_WARNING +"ACPI NUMA has not been supported yet, NUMA off!\n" ); + numa_off = true; + } + +mem_init: +/* +* Find the minimal and maximum address of RAM, NUMA will +* build a memory to node mapping table for the whole range. +*/ + ram_start = bootinfo.mem.bank[0 ].start; + ram_size = bootinfo.mem.bank[0 ].size; + ram_end = ram_start + ram_size; +for ( idx =1 ; idx < bootinfo.mem.nr_banks; idx++ ) + { +paddr_t bank_start = bootinfo.mem.bank[idx].start; +paddr_t bank_size = bootinfo.mem.bank[idx].size; +paddr_t bank_end = bank_start + bank_size; + + ram_size = ram_size + bank_size; + ram_start =min (ram_start, bank_start); + ram_end =max (ram_end, bank_end); + } + +numa_initmem_init (PFN_UP (ram_start),PFN_DOWN (ram_end)); +return ; +} +uint32_t __init arch_meminfo_get_nr_bank (void ) {return bootinfo.mem.nr_banks;
xen/arch/arm/setup.c +7 -0
@@ -905,6 +905,13 @@ void __init start_xen(unsigned long boot_phys_offset,/* Parse the ACPI tables for possible boot-time configuration */ acpi_boot_table_init (); +/* +* Try to initialize NUMA system, if failed, the system will +* fallback to uniform system which means system has only 1 +* NUMA node. +*/ +numa_init (acpi_disabled); +end_boot_allocator ();/*
xen/include/asm-arm/numa.h +6 -0
@@ -24,6 +24,7 @@ typedef u8 nodeid_t;extern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance);extern int numa_device_tree_init (const void *fdt); +extern void numa_init (bool acpi_off);#else
@@ -47,6 +48,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_init (bool acpi_off) +{ + +} +static inline void numa_add_cpu (int cpu) {
Signature · 1 line
2.25.1
Re: [PATCH 34/37] xen/arm: enable device tree based NUMA in system init
Quoted 26 lines · Wei Chen
In this patch, we can start to create NUMA system that is based on device tree.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 55 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 7 +++++ xen/include/asm-arm/numa.h | 6 +++++ 3 files changed, 68 insertions(+)xen/arch/arm/numa.c +2
-0@@ -18,8 +18,10 @@* */ #include <xen/init.h> +#include <xen/device_tree.h> #include <xen/nodemask.h> #include <xen/numa.h> +#include <xen/pfn.h> static uint8_t __read_mostly node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = {
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 93
Quoted 7 lines
xen/arch/arm/numa.c +4
-0@@ -85,6 +87,59 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to) }EXPORT_SYMBOL (__node_distance); +void __init numa_init (bool acpi_off) +{ +uint32_t idx; +paddr_t ram_start = ~0 ;
INVALID_PADDR
Quoted 5 lines
xen/arch/arm/numa.c +5
-0+paddr_t ram_size =0 ; +paddr_t ram_end =0 ; + +/* NUMA has been turned off through Xen parameters */ +if ( numa_off )
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 108
Quoted 10 lines
xen/arch/arm/numa.c +10
-0+ goto mem_init; + +/* Initialize NUMA from device tree when system is not ACPI booted */ +if ( acpi_off ) + { +int ret =numa_device_tree_init (device_tree_flattened); +if ( ret ) + { +printk (XENLOG_WARNING +"Init NUMA from device tree failed, ret=%d\n" , ret);
As I mentioned in other patches we need to distinguish between two cases:
1) NUMA initialization failed because no NUMA information has been found
2) NUMA initialization failed because wrong/inconsistent NUMA info has been found
In case of 1), we print nothing. Maybe a single XENLOG_DEBUG message. In case of 2), all the warnings are good to print.
In this case, if ret != 0 because of 2), then it is fine to print this warning. But it looks like could be that ret is -EINVAL simply because a CPU node doesn't have numa-node-id, which is a normal condition for non-NUMA machines.
Quoted 22 lines
xen/arch/arm/numa.c +22
-0+ numa_off = true; + } + } +else + { +/* We don't support NUMA for ACPI boot currently */ +printk (XENLOG_WARNING +"ACPI NUMA has not been supported yet, NUMA off!\n" ); + numa_off = true; + } + +mem_init: +/* +* Find the minimal and maximum address of RAM, NUMA will +* build a memory to node mapping table for the whole range. +*/ + ram_start = bootinfo.mem.bank[0 ].start; + ram_size = bootinfo.mem.bank[0 ].size; + ram_end = ram_start + ram_size; +for ( idx =1 ; idx < bootinfo.mem.nr_banks; idx++ ) + { +paddr_t bank_start = bootinfo.mem.bank[idx].start;
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 140
Quoted 10 lines
xen/arch/arm/numa.c +10
-0+paddr_t bank_size = bootinfo.mem.bank[idx].size; +paddr_t bank_end = bank_start + bank_size; + + ram_size = ram_size + bank_size; + ram_start =min (ram_start, bank_start); + ram_end =max (ram_end, bank_end); + } + +numa_initmem_init (PFN_UP (ram_start),PFN_DOWN (ram_end)); +return ;
No need for return
Quoted 50 lines
xen/arch/arm/numa.c +2
-0+} +uint32_t __init arch_meminfo_get_nr_bank (void ) {return bootinfo.mem.nr_banks;xen/arch/arm/setup.c +7
-0@@ -905,6 +905,13 @@ void __init start_xen(unsigned long boot_phys_offset,/* Parse the ACPI tables for possible boot-time configuration */ acpi_boot_table_init (); +/* +* Try to initialize NUMA system, if failed, the system will +* fallback to uniform system which means system has only 1 +* NUMA node. +*/ +numa_init (acpi_disabled); +end_boot_allocator ();/* xen/include/asm-arm/numa.h +6
-0@@ -24,6 +24,7 @@ typedef u8 nodeid_t;extern void numa_set_distance (nodeid_t from,nodeid_t to,uint32_t distance);extern int numa_device_tree_init (const void *fdt); +extern void numa_init (bool acpi_off);#else @@ -47,6 +48,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_init (bool acpi_off) +{ + +} +static inline void numa_add_cpu (int cpu) {Signature · 1 line
2.25.1
RE: [PATCH 34/37] xen/arm: enable device tree based NUMA in system init
Hi Stefano,
Quoted 39 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月24日 11:28
To: Wei Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 34/37] xen/arm: enable device tree based NUMA in system initQuoted 29 lines · Wei Chen
In this patch, we can start to create NUMA system that is based on device tree.
Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/numa.c | 55 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 7 +++++ xen/include/asm-arm/numa.h | 6 +++++ 3 files changed, 68 insertions(+)xen/arch/arm/numa.c +2
-0@@ -18,8 +18,10 @@* */ #include <xen/init.h> +#include <xen/device_tree.h> #include <xen/nodemask.h> #include <xen/numa.h> +#include <xen/pfn.h> static uint8_t __read_mostly node_distance_map[MAX_NUMNODES ][MAX_NUMNODES ] = {@@ -85,6 +87,59 @@ uint8_t __node_distance(nodeid_t from, nodeid_t to) }EXPORT_SYMBOL (__node_distance);
Quoted 7 lines
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 93
Quoted 4 lines
xen/arch/arm/numa.c +4
-0+void __init numa_init (bool acpi_off) +{ +uint32_t idx; +paddr_t ram_start = ~0 ;
INVALID_PADDR
Oh, yes
Quoted 25 lines
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to)
Quoted 9 lines
xen/arch/arm/numa.c +8
-0+paddr_t ram_size =0 ; +paddr_t ram_end =0 ; + +/* NUMA has been turned off through Xen parameters */ +if ( numa_off ) + goto mem_init; + +/* Initialize NUMA from device tree when system is not ACPI booted */
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 108
Quoted 7 lines
xen/arch/arm/numa.c +7
-0+if ( acpi_off ) + { +int ret =numa_device_tree_init (device_tree_flattened); +if ( ret ) + { +printk (XENLOG_WARNING +"Init NUMA from device tree failed, ret=%d\n" , ret);As I mentioned in other patches we need to distinguish between two cases:
1) NUMA initialization failed because no NUMA information has been found
2) NUMA initialization failed because wrong/inconsistent NUMA info has been found
Quoted 9 lines
In case of 1), we print nothing. Maybe a single
XENLOG_DEBUGmessage. In case of 2), all the warnings are good to print.In this case, if ret != 0 because of 2), then it is fine to print this warning. But it looks like could be that ret is
-EINVALsimply because a CPU node doesn't have numa-node-id, which is a normal condition for non-NUMA machines.
Yes, we should have to distinguish these two cases. I will try to address it in next version.
Quoted 27 lines
Quoted 27 lines
xen/arch/arm/numa.c +26
-0+ numa_off = true; + } + } +else + { +/* We don't support NUMA for ACPI boot currently */ +printk (XENLOG_WARNING +"ACPI NUMA has not been supported yet, NUMA off!\n" ); + numa_off = true; + } + +mem_init: +/* +* Find the minimal and maximum address of RAM, NUMA will +* build a memory to node mapping table for the whole range. +*/ + ram_start = bootinfo.mem.bank[0 ].start; + ram_size = bootinfo.mem.bank[0 ].size; + ram_end = ram_start + ram_size; +for ( idx =1 ; idx < bootinfo.mem.nr_banks; idx++ ) + { +paddr_t bank_start = bootinfo.mem.bank[idx].start; +paddr_t bank_size = bootinfo.mem.bank[idx].size; +paddr_t bank_end = bank_start + bank_size; + + ram_size = ram_size + bank_size;
Quoted 9 lines
xen/arch/arm/numa.c uint8_t __node_distance(nodeid_t from, nodeid_t to) · line 140
Quoted 6 lines
xen/arch/arm/numa.c +6
-0+ ram_start =min (ram_start, bank_start); + ram_end =max (ram_end, bank_end); + } + +numa_initmem_init (PFN_UP (ram_start),PFN_DOWN (ram_end)); +return ;No need for return
Ok, I will remove it.
Quoted 53 lines
xen/arch/arm/setup.c void __init start_xen(unsigned long
Quoted 11 lines
xen/arch/arm/numa.c +2
-0+} +uint32_t __init arch_meminfo_get_nr_bank (void ) {return bootinfo.mem.nr_banks;xen/arch/arm/setup.c +0
-0@@ -905,6 +905,13 @@ void __init start_xen(unsigned long
boot_phys_offset,Quoted 18 lines
xen/arch/arm/setup.c +7
-0/* Parse the ACPI tables for possible boot-time configuration */ acpi_boot_table_init (); +/* +* Try to initialize NUMA system, if failed, the system will +* fallback to uniform system which means system has only 1 +* NUMA node. +*/ +numa_init (acpi_disabled); +end_boot_allocator ();/* xen/include/asm-arm/numa.h +0
-0xen/include/asm-arm/numa.h typedef u8 nodeid_t; · line 25
Quoted 2 lines
xen/include/asm-arm/numa.h +0
-0@@ -24,6 +24,7 @@ typedef u8 nodeid_t; extern void numa_set_distance(nodeid_t from, nodeid_t to, uint32_tdistance);
Quoted 20 lines
xen/include/asm-arm/numa.h +6
-1extern int numa_device_tree_init (const void *fdt); +extern void numa_init (bool acpi_off);#else @@ -47,6 +48,11 @@ extern mfn_t first_valid_mfn;#define node_start_pfn (nid) (mfn_x(first_valid_mfn))#define __node_distance (a, b) (20) +static inline void numa_init (bool acpi_off) +{ + +} +static inline void numa_add_cpu (int cpu) { --2.25.1
PATCH 35/37 xen/arm: use CONFIG_NUMA to gate node_online_map in smpboot
In reply to Wei Chennode_online_map in smpboot still need for Arm when NUMA is turn off by Kconfig.
--- xen/arch/arm/smpboot.c | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/arm/smpboot.c +2 -0
@@ -46,8 +46,10 @@ struct cpuinfo_arm cpu_data[NR_CPUS];/* CPU logical map: map xen cpuid to an MPIDR */ register_t __cpu_logical_map[NR_CPUS ] = { [0 ...NR_CPUS -1 ] =MPIDR_INVALID }; +#ifndef CONFIG_NUMA /* Fake one node for now. See also include/asm-arm/numa.h */ nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; +#endif /* Xen stack for bringing up the first CPU. */ static unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]
Signature · 1 line
2.25.1
PATCH 36/37 xen/arm: Provide Kconfig options for Arm to enable NUMA
In reply to Wei ChenArm platforms support both ACPI and device tree. We don't want users to select device tree NUMA or ACPI NUMA manually. We hope usrs can just enable NUMA for Arm, and device tree NUMA and ACPI NUMA can be selected depends on device tree feature and ACPI feature status automatically. In this case, these two kinds of NUMA support code can be co-exist in one Xen binary. Xen can check feature flags to decide using device tree or ACPI as NUMA based firmware.
So in this patch, we introduce a generic option:CONFIG_ARM_NUMA for user to enable NUMA for Arm. And one CONFIG_DEVICE_TREE_NUMA option for ARM_NUMA to select when HAS_DEVICE_TREE option is enabled. Once when ACPI NUMA for Arm is supported, ACPI_NUMA can be selected here too.
--- xen/arch/arm/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
xen/arch/arm/Kconfig +11 -0
@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" if UNSUPPORTED + select DEVICE_TREE_NUMA if HAS_DEVICE_TREE + ---help--- + + Enable Non-Uniform Memory Access (NUMA) for Arm architecutres + config GICV3 bool "GICv3 driver" depends on ARM_64 && !NEW_VGIC
Signature · 1 line
2.25.1
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 3 lines · Wei Chen
Arm platforms support both ACPI and device tree. We don't want users to select device tree NUMA or ACPI NUMA manually. We hope usrs can just enable NUMA for Arm, and device tree
^ users
Quoted 8 lines
NUMA and ACPI NUMA can be selected depends on device tree feature and ACPI feature status automatically. In this case, these two kinds of NUMA support code can be co-exist in one Xen binary. Xen can check feature flags to decide using device tree or ACPI as NUMA based firmware.
So in this patch, we introduce a generic option:
CONFIG_ARM_NUMAfor user to enable NUMA for Arm.
^ users
Quoted 15 lines
And one
CONFIG_DEVICE_TREE_NUMAoption forARM_NUMAto select whenHAS_DEVICE_TREEoption is enabled. Once when ACPI NUMA for Arm is supported,ACPI_NUMAcan be selected here too.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)xen/arch/arm/Kconfig +0
-0
xen/arch/arm/Kconfig config ACPI · line 43
Quoted 10 lines
xen/arch/arm/Kconfig +7
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" if UNSUPPORTED + select DEVICE_TREE_NUMA if HAS_DEVICE_TREE
Should it be: depends on HAS_DEVICE_TREE ? (And eventually depends on HAS_DEVICE_TREE || ACPI)
xen/arch/arm/Kconfig config ACPI · line 46
Quoted 3 lines
xen/arch/arm/Kconfig +3
-0+ ---help--- + + Enable Non-Uniform Memory Access (NUMA) for Arm architecutres
^ architectures
Quoted 7 lines
xen/arch/arm/Kconfig +1
-0+ config GICV3 bool "GICv3 driver" depends on ARM_64 && !NEW_VGICSignature · 1 line
2.25.1
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Hi Stefano,
Quoted 12 lines · Stefano Stabellini
Quoted 3 lines · Wei Chen
Arm platforms support both ACPI and device tree. We don't want users to select device tree NUMA or ACPI NUMA manually. We hope usrs can just enable NUMA for Arm, and device tree
^ users
Quoted 6 lines
NUMA and ACPI NUMA can be selected depends on device tree feature and ACPI feature status automatically. In this case, these two kinds of NUMA support code can be co-exist in one Xen binary. Xen can check feature flags to decide using device tree or ACPI as NUMA based firmware.
Quoted 4 lines
Quoted 2 lines
So in this patch, we introduce a generic option:
CONFIG_ARM_NUMAfor user to enable NUMA for Arm.^ users
OK
Quoted 18 lines
Quoted 18 lines
And one
CONFIG_DEVICE_TREE_NUMAoption forARM_NUMAto select whenHAS_DEVICE_TREEoption is enabled. Once when ACPI NUMA for Arm is supported,ACPI_NUMAcan be selected here too.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64.
Quoted 11 lines
xen/arch/arm/Kconfig config ACPI · line 43
Quoted 7 lines
xen/arch/arm/Kconfig +7
-0+ config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" if UNSUPPORTED + select DEVICE_TREE_NUMA if HAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)
As the discussion in RFC [1]. We want to make ARM_NUMA as a generic option can be selected by users. And depends on has_device_tree or ACPI to select DEVICE_TREE_NUMA or ACPI_NUMA.
If we add HAS_DEVICE_TREE || ACPI as dependencies for ARM_NUMA, does it become a loop dependency?
https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
Quoted 14 lines
xen/arch/arm/Kconfig config ACPI · line 46
Quoted 4 lines
xen/arch/arm/Kconfig +3
-0+ ---help--- + + Enable Non-Uniform Memory Access (NUMA) for Arm architecutres^ architectures
Quoted 7 lines
xen/arch/arm/Kconfig +1
-0+ config GICV3 bool "GICv3 driver" depends on ARM_64 && !NEW_VGICSignature · 1 line
2.25.1
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 52 lines · Wei Chen
Hi Stefano,
Quoted 12 lines · Stefano Stabellini
Quoted 3 lines · Wei Chen
Arm platforms support both ACPI and device tree. We don't want users to select device tree NUMA or ACPI NUMA manually. We hope usrs can just enable NUMA for Arm, and device tree
^ users
Quoted 6 lines
NUMA and ACPI NUMA can be selected depends on device tree feature and ACPI feature status automatically. In this case, these two kinds of NUMA support code can be co-exist in one Xen binary. Xen can check feature flags to decide using device tree or ACPI as NUMA based firmware.
Quoted 4 lines
Quoted 2 lines
So in this patch, we introduce a generic option:
CONFIG_ARM_NUMAfor user to enable NUMA for Arm.^ users
OK
Quoted 20 lines
Quoted 20 lines
And one
CONFIG_DEVICE_TREE_NUMAoption forARM_NUMAto select whenHAS_DEVICE_TREEoption is enabled. Once when ACPI NUMA for Arm is supported,ACPI_NUMAcan be selected here too.Signed-off-by Wei Chen <[email protected]>--- xen/arch/arm/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)xen/arch/arm/Kconfig +2
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMAQuoted 9 lines
xen/arch/arm/Kconfig config ACPI · line 43
Quoted 5 lines
xen/arch/arm/Kconfig +3
-0+ +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" ifUNSUPPORTED
xen/arch/arm/Kconfig +1
-0+ select DEVICE_TREE_NUMA if HAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)
Quoted 8 lines
As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
OK, I am fine with that. I was just trying to catch the case where a user selects "ARM_NUMA" but actually neither ACPI nor HAS_DEVICE_TREE are selected so nothing happens. I was trying to make it clear that ARM_NUMA depends on having at least one between HAS_DEVICE_TREE or ACPI because otherwise it is not going to work.
That said, I don't think this is important because HAS_DEVICE_TREE cannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 36 lines · Stefano Stabellini
Quoted 20 lines · Wei Chen
Quoted 18 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 43
Quoted 13 lines · Wei Chen
xen/arch/arm/Kconfig +5
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" ifUNSUPPORTED
xen/arch/arm/Kconfig +1
-0+ select DEVICE_TREE_NUMA if HAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)Quoted 8 lines
As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI norHAS_DEVICE_TREEare selected so nothing happens. I was trying to make it clear thatARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEor ACPI because otherwise it is not going to work.
Quoted 3 lines
That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.
So how about doing things the other way around: ARM_NUMA has no prompt and defaults to ACPI_NUMA || DT_NUMA, and DT_NUMA gains a prompt instead (and, for Arm at least, ACPI_NUMA as well; this might even be worthwhile to have on x86 down the road).
Jan
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 40 lines · On Mon, 27 Sep 2021, 10:33 Jan Beulich, <[email protected]> wrote:
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Wei Chen
Quoted 5 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support forXen is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/arm/Kconfig config ACPI
Quoted 7 lines
xen/arch/arm/Kconfig +5
-0an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)"if
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
UNSUPPORTED
+ selectDEVICE_TREE_NUMAifHAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)Quoted 8 lines
Quoted 8 lines
As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
Quoted 7 lines
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI norHAS_DEVICE_TREEare selected so nothing happens. I was trying to make it clear thatARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEor ACPI because otherwise it is not going to work.
Quoted 9 lines
Quoted 3 lines
That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.So how about doing things the other way around:
ARM_NUMAhas no prompt and defaults toACPI_NUMA||DT_NUMA, andDT_NUMAgains a prompt instead (and, for Arm at least,ACPI_NUMAas well; this might even be worthwhile to have on x86 down the road).
As I wrote before, I don't think the user should say "I want to enable NUMA with Device-Tree or ACPI". Instead, they say whether they want to use NUMA and let Xen decide to enable the DT/ACPI support.
In other word, the prompt should stay on ARM_NUMA.
Cheers,
Quoted 3 lines
Jan
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 52 lines · Julien Grall
Quoted 40 lines · On Mon, 27 Sep 2021, 10:33 Jan Beulich, <[email protected]> wrote:
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Wei Chen
Quoted 5 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support forXen is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/arm/Kconfig config ACPI
Quoted 7 lines
xen/arch/arm/Kconfig +5
-0an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)"if
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
UNSUPPORTED
+ selectDEVICE_TREE_NUMAifHAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)Quoted 8 lines
Quoted 8 lines
As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
Quoted 7 lines
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI norHAS_DEVICE_TREEare selected so nothing happens. I was trying to make it clear thatARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEor ACPI because otherwise it is not going to work.Quoted 9 lines
Quoted 3 lines
That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.So how about doing things the other way around:
ARM_NUMAhas no prompt and defaults toACPI_NUMA||DT_NUMA, andDT_NUMAgains a prompt instead (and, for Arm at least,ACPI_NUMAas well; this might even be worthwhile to have on x86 down the road).
Quoted 5 lines
As I wrote before, I don't think the user should say "I want to enable NUMA with Device-Tree or ACPI". Instead, they say whether they want to use NUMA and let Xen decide to enable the DT/ACPI support.
In other word, the prompt should stay on
ARM_NUMA.
Okay. In which case I'm confused by Stefano's question.
Jan
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 53 lines · Jan Beulich
Quoted 52 lines · Julien Grall
Quoted 49 lines · On Mon, 27 Sep 2021, 10:33 Jan Beulich, <[email protected]> wrote:
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Wei Chen
Quoted 5 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support forXen is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/arm/Kconfig config ACPI · line 41
Quoted 7 lines
xen/arch/arm/Kconfig +5
-0an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)"if
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
UNSUPPORTED
+ selectDEVICE_TREE_NUMAifHAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)Quoted 8 lines
Quoted 8 lines
As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?https://lists.xenproject.org/archives/html/xen-devel/2021-08/msg00888.html
Quoted 10 lines
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI norHAS_DEVICE_TREEare selected so nothing happens. I was trying to make it clear thatARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEor ACPI because otherwise it is not going to work.That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.So how about doing things the other way around:
ARM_NUMAhas no prompt and defaults toACPI_NUMA||DT_NUMA, andDT_NUMAgains a prompt instead (and, for Arm at least,ACPI_NUMAas well; this might even be worthwhile to have on x86 down the road).
Quoted 7 lines
Quoted 5 lines
As I wrote before, I don't think the user should say "I want to enable NUMA with Device-Tree or ACPI". Instead, they say whether they want to use NUMA and let Xen decide to enable the DT/ACPI support.
In other word, the prompt should stay on
ARM_NUMA.Okay. In which case I'm confused by Stefano's question.
Let me clarify: I think it is fine to have a single prompt for NUMA in Kconfig. However, I am just pointing out that it is theoretically possible with the current code to present an ARM_NUMA prompt to the user but actually have no NUMA enabled at the end because both DEVICE TREE and ACPI are disabled. This is only a theoretical problem because DEVICE TREE support (HAS_DEVICE_TREE) cannot be disabled today. Also I cannot imagine how a configuration with neither DEVICE TREE nor ACPI can be correct. So I don't think it is a critical concern.
That said, you can see that, at least theoretically, ARM_NUMA depends on either HAS_DEVICE_TREE or ACPI, so I suggested to add:
depends on HAS_DEVICE_TREE || ACPI
Wei answered that it might introduce a circular dependency, but I did try the addition of "depends on HAS_DEVICE_TREE || ACPI" under ARM_NUMA in Kconfig and everything built fine here.
RE: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Hi Stefano,
Quoted 91 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月28日 1:17
To: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Wei Chen <[email protected]>; xen-devel <xen- [email protected]>; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 36/37] xen/arm: ProvideKconfigoptions for Arm to enable NUMAQuoted 11 lines · Jan Beulich
Quoted 10 lines · Julien Grall
Quoted 8 lines · On Mon, 27 Sep 2021, 10:33 Jan Beulich, <[email protected]> wrote:
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Wei Chen
Quoted 5 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) supportfor
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Xen is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/arm/Kconfig config ACPI · line 41
Quoted 7 lines
xen/arch/arm/Kconfig +5
-0an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support(UNSUPPORTED)"
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
if
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
UNSUPPORTED
+ selectDEVICE_TREE_NUMAifHAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?08/msg00888.html
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI nor
HAS_DEVICE_TREEQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
are selected so nothing happens. I was trying to make it clear that
ARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEorACPI
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
because otherwise it is not going to work.
That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.So how about doing things the other way around:
ARM_NUMAhas noprompt
Quoted 1 line
Quoted 1 line
Quoted 1 line
and defaults to
ACPI_NUMA||DT_NUMA, andDT_NUMAgains a promptinstead
Quoted 1 line
Quoted 1 line
Quoted 1 line
(and, for Arm at least,
ACPI_NUMAas well; this might even beworthwhile
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
to have on x86 down the road).
As I wrote before, I don't think the user should say "I want to enable
NUMA
Quoted 1 line
Quoted 1 line
with Device-Tree or ACPI". Instead, they say whether they want to use
NUMA
Quoted 5 lines
Quoted 3 lines
and let Xen decide to enable the DT/ACPI support.
In other word, the prompt should stay on
ARM_NUMA.Okay. In which case I'm confused by Stefano's question.
Let me clarify: I think it is fine to have a single prompt for NUMA in
Kconfig. However, I am just pointing out that it is theoretically possible with the current code to present anARM_NUMAprompt to the user but actually have no NUMA enabled at the end because both DEVICE TREE and ACPI are disabled. This is only a theoretical problem because DEVICE TREE support (HAS_DEVICE_TREE) cannot be disabled today. Also I cannot imagine how a configuration with neither DEVICE TREE nor ACPI can be correct. So I don't think it is a critical concern.
Quoted 8 lines
That said, you can see that, at least theoretically,
ARM_NUMAdepends on eitherHAS_DEVICE_TREEor ACPI, so I suggested to add:depends on
HAS_DEVICE_TREE|| ACPIWei answered that it might introduce a circular dependency, but I did try the addition of "depends on
HAS_DEVICE_TREE|| ACPI" underARM_NUMAinKconfigand everything built fine here.
Ok, I will add "depends on HAS_DEVICE_TREE" in next version, but "|| ACPI" will be later when we have ACPI NUMA for Arm : )
RE: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 94 lines · Wei Chen
Quoted 94 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Sent: 2021年9月28日 1:17
To: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Wei Chen <[email protected]>; xen-devel <xen- [email protected]>; Bertrand Marquis <[email protected]>
Subject: Re: [PATCH 36/37] xen/arm: ProvideKconfigoptions for Arm to enable NUMAQuoted 11 lines · Jan Beulich
Quoted 10 lines · Julien Grall
Quoted 8 lines · On Mon, 27 Sep 2021, 10:33 Jan Beulich, <[email protected]> wrote:
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Wei Chen
Quoted 5 lines · Stefano Stabellini
xen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) supportfor
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Xen is
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/arch/arm/Kconfig config ACPI · line 41
Quoted 7 lines
xen/arch/arm/Kconfig +5
-0an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA + +config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support(UNSUPPORTED)"
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
if
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
UNSUPPORTED
+ selectDEVICE_TREE_NUMAifHAS_DEVICE_TREEShould it be: depends on
HAS_DEVICE_TREE? (And eventually depends onHAS_DEVICE_TREE|| ACPI)As the discussion in RFC [1]. We want to make
ARM_NUMAas a generic option can be selected by users. And depends onhas_device_treeor ACPI to selectDEVICE_TREE_NUMAorACPI_NUMA.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
If we add
HAS_DEVICE_TREE|| ACPI as dependencies forARM_NUMA, does it become a loop dependency?08/msg00888.html
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
OK, I am fine with that. I was just trying to catch the case where a user selects "
ARM_NUMA" but actually neither ACPI nor
HAS_DEVICE_TREEQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
are selected so nothing happens. I was trying to make it clear that
ARM_NUMAdepends on having at least one betweenHAS_DEVICE_TREEorACPI
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
because otherwise it is not going to work.
That said, I don't think this is important because
HAS_DEVICE_TREEcannot be unselected. So if we cannot find a way to express the dependency, I think it is fine to keep the patch as is.So how about doing things the other way around:
ARM_NUMAhas noprompt
Quoted 1 line
Quoted 1 line
Quoted 1 line
and defaults to
ACPI_NUMA||DT_NUMA, andDT_NUMAgains a promptinstead
Quoted 1 line
Quoted 1 line
Quoted 1 line
(and, for Arm at least,
ACPI_NUMAas well; this might even beworthwhile
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
to have on x86 down the road).
As I wrote before, I don't think the user should say "I want to enable
NUMA
Quoted 1 line
Quoted 1 line
with Device-Tree or ACPI". Instead, they say whether they want to use
NUMA
Quoted 5 lines
Quoted 3 lines
and let Xen decide to enable the DT/ACPI support.
In other word, the prompt should stay on
ARM_NUMA.Okay. In which case I'm confused by Stefano's question.
Let me clarify: I think it is fine to have a single prompt for NUMA in
Kconfig. However, I am just pointing out that it is theoretically possible with the current code to present anARM_NUMAprompt to the user but actually have no NUMA enabled at the end because both DEVICE TREE and ACPI are disabled. This is only a theoretical problem because DEVICE TREE support (HAS_DEVICE_TREE) cannot be disabled today. Also I cannot imagine how a configuration with neither DEVICE TREE nor ACPI can be correct. So I don't think it is a critical concern.That said, you can see that, at least theoretically,
ARM_NUMAdepends on eitherHAS_DEVICE_TREEor ACPI, so I suggested to add:
Quoted 8 lines
Quoted 5 lines
depends on
HAS_DEVICE_TREE|| ACPIWei answered that it might introduce a circular dependency, but I did try the addition of "depends on
HAS_DEVICE_TREE|| ACPI" underARM_NUMAinKconfigand everything built fine here.Ok, I will add "depends on
HAS_DEVICE_TREE" in next version, but "|| ACPI" will be later when we have ACPI NUMA for Arm : )
Good point :)
Re: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
In reply to Wei Chenxen/arch/arm/Kconfig config ACPI · line 39
Quoted 9 lines · Wei Chen
xen/arch/arm/Kconfig +3
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xen is an alternative to device tree on ARM64. + config DEVICE_TREE_NUMA + def_bool n + select NUMA
Two nits here: There's a stray blank on the first line, and you appear to mean just "bool", not "def_bool n" (there's no point in having defaults for select-only options).
xen/arch/arm/Kconfig config ACPI · line 44
Quoted 4 lines
xen/arch/arm/Kconfig +4
-0+config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" if UNSUPPORTED + select DEVICE_TREE_NUMA if HAS_DEVICE_TREE + ---help---
And another nit here: We try to move away from "---help---", which is no longer supported by Linux'es newer kconfig. Please use just "help" in new code.
Jan
RE: [PATCH 36/37] xen/arm: Provide Kconfig options for Arm to enable NUMA
Quoted 18 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 2021年9月24日 18:26
To: Wei Chen <[email protected]>
Cc: Bertrand Marquis <[email protected]>; xen- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 36/37] xen/arm: ProvideKconfigoptions for Arm to enable NUMAxen/arch/arm/Kconfig config ACPI · line 34
Quoted 4 lines · Wei Chen
xen/arch/arm/Kconfig +0
-0@@ -34,6 +34,17 @@ config ACPI Advanced Configuration and Power Interface (ACPI) support for Xenis
Quoted 2 lines
xen/arch/arm/Kconfig +0
-0an alternative to device tree on ARM64.
Quoted 8 lines
xen/arch/arm/Kconfig config ACPI · line 39
Quoted 3 lines
xen/arch/arm/Kconfig +3
-0+ config DEVICE_TREE_NUMA + def_bool n + select NUMATwo nits here: There's a stray blank on the first line, and you appear to mean just "bool", not "
def_booln" (there's no point in having defaults for select-only options).
Ok
Quoted 10 lines
xen/arch/arm/Kconfig config ACPI · line 41
Quoted 2 lines
xen/arch/arm/Kconfig +2
-0+config ARM_NUMA + bool "Arm NUMA (Non-Uniform Memory Access) Support (UNSUPPORTED)" ifUNSUPPORTED
xen/arch/arm/Kconfig config ACPI · line 44
Quoted 2 lines
xen/arch/arm/Kconfig +2
-0+ select DEVICE_TREE_NUMA if HAS_DEVICE_TREE + ---help---And another nit here: We try to move away from "---help---", which is no longer supported by Linux'es newer kconfig. Please use just "help" in new code.
Thanks, I will do it.
Quoted 1 line
Jan
PATCH 37/37 docs: update numa command line to support Arm
In reply to Wei ChenCurrent numa command in documentation is x86 only. Remove x86 from numa command's arch limitation in this patch.
--- docs/misc/xen-command-line.pandoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
docs/misc/xen-command-line.pandoc +1 -1
@@ -1785,7 +1785,7 @@ i.e. a limit on the number of guests it is possible to start each having assigned a device sharing a common interrupt line. Accepts values between 1 and 255. -### numa (x86) +### numa > `= on | off | fake=<integer> | noacpi` > Default: `on`
Signature · 1 line
2.25.1