device-dax: use fallback nid when numa node is invalid
PATCH v2 1/1 device-dax: use fallback nid when numa node is invalid
Previously, numa_off was set unconditionally in dummy_numa_init() even with a fake numa node. Then ACPI sets node id as NUMA_NO_NODE(-1) after acpi_map_pxm_to_node() because it regards numa_off as turning off the numa node. Hence dev_dax->target_node is NUMA_NO_NODE on arm64 with fake numa case.
Without this patch, pmem can't be probed as RAM devices on arm64 if
SRAT table isn't present:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 64K kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1
kmem: probe of dax0.0 failed with error -22
This fixes it by using fallback memory_add_physaddr_to_nid() as nid.
---
v2: - rebase it based on David's "memory group" patch.
- drop the changes in dev_dax_kmem_remove() since nid had been removed in remove_memory().
drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/dax/kmem.c +17 -14
@@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)unsigned long total_len =0 ;struct dax_kmem_data *data;int i, rc, mapped =0 ; -int numa_node; - -/* -* Ensure good NUMA information for the persistent memory. -* Without this check, there is a risk that slow memory -* could be mixed in a node with faster memory, causing -* unavoidable performance issues. -*/ - numa_node = dev_dax->target_node; -if (numa_node <0 ) { -dev_warn (dev,"rejecting DAX region with invalid node: %d\n" , - numa_node); -return -EINVAL ; - } +int numa_node = dev_dax->target_node;for (i =0 ; i < dev_dax->nr_range; i++) {struct range range;
@@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) i, range.start, range.end);continue ; } + +/* +* Ensure good NUMA information for the persistent memory. +* Without this check, there is a risk but not fatal that slow +* memory could be mixed in a node with faster memory, causing +* unavoidable performance issues. Warn this and use fallback +* node id. +*/ +if (numa_node <0 ) { +int new_node =memory_add_physaddr_to_nid (range.start); + +dev_info (dev,"changing nid from %d to %d for DAX region [%#llx-%#llx]\n" , + numa_node, new_node, range.start, range.end); + numa_node = new_node; + } + total_len +=range_len (&range); }
Signature · 1 line
2.17.1
Quoted 61 lines · Jia He
Previously,
numa_offwas set unconditionally indummy_numa_init()even with a fake numa node. Then ACPI sets node id asNUMA_NO_NODE(-1)afteracpi_map_pxm_to_node()because it regardsnuma_offas turning off the numa node. Hencedev_dax->target_nodeisNUMA_NO_NODEon arm64 with fake numa case.Without this patch, pmem can't be probed as RAM devices on arm64 if
SRAT table isn't present:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 64K kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with invalid node: -1
kmem: probe of dax0.0 failed with error -22This fixes it by using fallback
memory_add_physaddr_to_nid()as nid.Suggested-by David Hildenbrand <[email protected]>Signed-off-by Jia He <[email protected]>---
v2: - rebase it based on David's "memory group" patch.
- drop the changes indev_dax_kmem_remove()since nid had been removed inremove_memory().drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)drivers/dax/kmem.c +8
-14@@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)unsigned long total_len =0 ;struct dax_kmem_data *data;int i, rc, mapped =0 ; -int numa_node; - -/* -* Ensure good NUMA information for the persistent memory. -* Without this check, there is a risk that slow memory -* could be mixed in a node with faster memory, causing -* unavoidable performance issues. -*/ - numa_node = dev_dax->target_node; -if (numa_node <0 ) { -dev_warn (dev,"rejecting DAX region with invalid node: %d\n" , - numa_node); -return -EINVAL ; - } +int numa_node = dev_dax->target_node;for (i =0 ; i < dev_dax->nr_range; i++) {struct range range;@@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) i, range.start, range.end);continue ; } + +/* +* Ensure good NUMA information for the persistent memory. +* Without this check, there is a risk but not fatal that slow +* memory could be mixed in a node with faster memory, causing +* unavoidable performance issues. Warn this and use fallback +* node id.
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 77
Quoted 10 lines
drivers/dax/kmem.c +9
-0+*/ +if (numa_node <0 ) { +int new_node =memory_add_physaddr_to_nid (range.start); + +dev_info (dev,"changing nid from %d to %d for DAX region [%#llx-%#llx]\n" , + numa_node, new_node, range.start, range.end); + numa_node = new_node; + } + total_len +=range_len (&range);
This fallback change belongs where the parent region for the namespace adopts its target_node, because it's not clear memory_add_physaddr_to_nid() is the right fallback in all situations. Here is where this setting is happening currently:
drivers/acpi/nfit/core.c:3004: ndr_desc->target_node =pxm_to_node(spa->proximity_domain);drivers/acpi/nfit/core.c:3007: ndr_desc->target_node = NUMA_NO_NODE;drivers/nvdimm/e820.c:29: ndr_desc.target_node = nid;drivers/nvdimm/of_pmem.c:58: ndr_desc.target_node =
ndr_desc.numa_node;drivers/nvdimm/region_devs.c:1127: nd_region->target_node =ndr_desc->target_node;
...where is this pmem region originating on this arm64 platform?
Hi Dan,
Quoted 94 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Friday, September 10, 2021 11:42 PM
To: Justin He <[email protected]>
Cc: Vishal Verma <[email protected]>; Dave Jiang <[email protected]>; David Hildenbrand <[email protected]>; Linux NVDIMM <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v2] device-dax: use fallback nid when numa node is invalidQuoted 10 lines · Jia He
Previously,
numa_offwas set unconditionally indummy_numa_init()even with a fake numa node. Then ACPI sets node id asNUMA_NO_NODE(-1)afteracpi_map_pxm_to_node()because it regardsnuma_offas turning off the numa node. Hencedev_dax->target_nodeisNUMA_NO_NODEon arm64 with fake numa case.Without this patch, pmem can't be probed as RAM devices on arm64 if SRAT table isn't present:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g-a 64K
Quoted 1 line
kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with
invalid node: -1
Quoted 22 lines
kmem: probe of dax0.0 failed with error -22
This fixes it by using fallback
memory_add_physaddr_to_nid()as nid.Suggested-by David Hildenbrand <[email protected]>Signed-off-by Jia He <[email protected]>---
v2: - rebase it based on David's "memory group" patch.
- drop the changes indev_dax_kmem_remove()since nid had been removed inremove_memory().drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)drivers/dax/kmem.c +0
-1@@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)unsigned long total_len =0 ;struct dax_kmem_data *data;int i, rc, mapped =0 ; -int numa_node;drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 60
Quoted 10 lines
drivers/dax/kmem.c +0
-10- -/* -* Ensure good NUMA information for the persistent memory. -* Without this check, there is a risk that slow memory -* could be mixed in a node with faster memory, causing -* unavoidable performance issues. -*/ - numa_node = dev_dax->target_node; -if (numa_node <0 ) { - dev_warn(dev, "rejecting DAX region with invalidnode: %d\n",
Quoted 8 lines
drivers/dax/kmem.c +1
-3- numa_node); -return -EINVAL ; - } +int numa_node = dev_dax->target_node;for (i =0 ; i < dev_dax->nr_range; i++) {struct range range;drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 63
Quoted 6 lines
drivers/dax/kmem.c +3
-0@@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) i, range.start, range.end);continue ; } + +/* +* Ensure good NUMA information for the persistent memory.
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 64
Quoted 1 line
drivers/dax/kmem.c +1
-0+* Without this check, there is a risk but not fatal that slow
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 65
Quoted 1 line
drivers/dax/kmem.c +1
-0+* memory could be mixed in a node with faster memory, causing
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 66
Quoted 1 line
drivers/dax/kmem.c +1
-0+* unavoidable performance issues. Warn this and use fallback
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 70
Quoted 4 lines
drivers/dax/kmem.c +4
-0+* node id. +*/ +if (numa_node <0 ) { + int new_node =
memory_add_physaddr_to_nid(range.start);drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 72
Quoted 2 lines
drivers/dax/kmem.c +2
-0+ + dev_info(dev, "changing nid from %d to %d forDAX region [%#llx-%#llx]\n",
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 73
Quoted 1 line
drivers/dax/kmem.c +1
-0+ numa_node, new_node, range.start,range.end);
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 77
Quoted 4 lines
drivers/dax/kmem.c +3
-0+ numa_node = new_node; + } + total_len +=range_len (&range);
Quoted 7 lines
This fallback change belongs where the parent region for the namespace adopts its
target_node, because it's not clearmemory_add_physaddr_to_nid()is the right fallback in all situations. Here is where this setting is happening currently:
drivers/acpi/nfit/core.c:3004:ndr_desc->target_node=pxm_to_node(spa->proximity_domain);
On my local arm64 guest('virt' machine type), the target_node is set to -1 at this line.
That is:
The condition "spa->flags & ACPI_NFIT_PROXIMITY_VALID" is hit.
Quoted 7 lines
drivers/acpi/nfit/core.c:3007:ndr_desc->target_node=NUMA_NO_NODE;drivers/nvdimm/e820.c:29: ndr_desc.target_node = nid;drivers/nvdimm/of_pmem.c:58: ndr_desc.target_node =
ndr_desc.numa_node;drivers/nvdimm/region_devs.c:1127:nd_region->target_node=ndr_desc->target_node;
Sorry,Dan. I thought I missed your previous mail:
=========================================
Looks like it is the NFIT driver, thanks.
If you're getting NUMA_NO_NODE in dax_kmem from the NFIT driver in means your ACPI NFIT table is failing to populate correct numa information. You could try the following to fix it up, but I think the real problem is that your platform BIOS needs to add the proper numa data.
drivers/acpi/nfit/core.c +0 -0
@@ -3005,15 +3005,8 @@ static int acpi_nfit_register_region(struct
acpi_nfit_desc *acpi_desc,
ndr_desc->res = &res;
ndr_desc->provider_data = nfit_spa;
ndr_desc->attr_groups = acpi_nfit_region_attribute_groups;- if (spa->flags & ACPI_NFIT_PROXIMITY_VALID) {
- ndr_desc->numa_node = acpi_map_pxm_to_online_node(
- spa->proximity_domain);
- ndr_desc->target_node = acpi_map_pxm_to_node(
- spa->proximity_domain);
- } else {
- ndr_desc->numa_node = NUMA_NO_NODE;
- ndr_desc->target_node = NUMA_NO_NODE;
- } + ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address); + ndr_desc->target_node = phys_to_target_node(spa->address);
/*
* Persistence domain bits are hierarchical, if
===================================================
Do you still suggest fixing like this?
--
Cheers,
Justin (Jia He)
Quoted 154 lines · Justin He
Hi Dan,
Quoted 94 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Friday, September 10, 2021 11:42 PM
To: Justin He <[email protected]>
Cc: Vishal Verma <[email protected]>; Dave Jiang <[email protected]>; David Hildenbrand <[email protected]>; Linux NVDIMM <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v2] device-dax: use fallback nid when numa node is invalidQuoted 10 lines · Jia He
Previously,
numa_offwas set unconditionally indummy_numa_init()even with a fake numa node. Then ACPI sets node id asNUMA_NO_NODE(-1)afteracpi_map_pxm_to_node()because it regardsnuma_offas turning off the numa node. Hencedev_dax->target_nodeisNUMA_NO_NODEon arm64 with fake numa case.Without this patch, pmem can't be probed as RAM devices on arm64 if SRAT table isn't present:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g-a 64K
Quoted 1 line
kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff] with
invalid node: -1
Quoted 22 lines
kmem: probe of dax0.0 failed with error -22
This fixes it by using fallback
memory_add_physaddr_to_nid()as nid.Suggested-by David Hildenbrand <[email protected]>Signed-off-by Jia He <[email protected]>---
v2: - rebase it based on David's "memory group" patch.
- drop the changes indev_dax_kmem_remove()since nid had been removed inremove_memory().drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)drivers/dax/kmem.c +0
-1@@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)unsigned long total_len =0 ;struct dax_kmem_data *data;int i, rc, mapped =0 ; -int numa_node;drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 60
Quoted 10 lines
drivers/dax/kmem.c +0
-10- -/* -* Ensure good NUMA information for the persistent memory. -* Without this check, there is a risk that slow memory -* could be mixed in a node with faster memory, causing -* unavoidable performance issues. -*/ - numa_node = dev_dax->target_node; -if (numa_node <0 ) { - dev_warn(dev, "rejecting DAX region with invalidnode: %d\n",
Quoted 8 lines
drivers/dax/kmem.c +1
-3- numa_node); -return -EINVAL ; - } +int numa_node = dev_dax->target_node;for (i =0 ; i < dev_dax->nr_range; i++) {struct range range;drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 63
Quoted 6 lines
drivers/dax/kmem.c +3
-0@@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) i, range.start, range.end);continue ; } + +/* +* Ensure good NUMA information for the persistent memory.
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 64
Quoted 1 line
drivers/dax/kmem.c +1
-0+* Without this check, there is a risk but not fatal that slow
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 65
Quoted 1 line
drivers/dax/kmem.c +1
-0+* memory could be mixed in a node with faster memory, causing
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 66
Quoted 1 line
drivers/dax/kmem.c +1
-0+* unavoidable performance issues. Warn this and use fallback
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 70
Quoted 4 lines
drivers/dax/kmem.c +4
-0+* node id. +*/ +if (numa_node <0 ) { + int new_node =
memory_add_physaddr_to_nid(range.start);drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 72
Quoted 2 lines
drivers/dax/kmem.c +2
-0+ + dev_info(dev, "changing nid from %d to %d forDAX region [%#llx-%#llx]\n",
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 73
Quoted 1 line
drivers/dax/kmem.c +1
-0+ numa_node, new_node, range.start,range.end);
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax *dev_dax) · line 77
Quoted 4 lines
drivers/dax/kmem.c +3
-0+ numa_node = new_node; + } + total_len +=range_len (&range);Quoted 7 lines
This fallback change belongs where the parent region for the namespace adopts its
target_node, because it's not clearmemory_add_physaddr_to_nid()is the right fallback in all situations. Here is where this setting is happening currently:
drivers/acpi/nfit/core.c:3004:ndr_desc->target_node=pxm_to_node(spa->proximity_domain);On my local arm64 guest('virt' machine type), the
target_nodeis set to -1 at this line.
That is:
The condition "spa->flags&ACPI_NFIT_PROXIMITY_VALID" is hit.Quoted 7 lines
drivers/acpi/nfit/core.c:3007:ndr_desc->target_node=NUMA_NO_NODE;drivers/nvdimm/e820.c:29: ndr_desc.target_node = nid;drivers/nvdimm/of_pmem.c:58: ndr_desc.target_node =
ndr_desc.numa_node;drivers/nvdimm/region_devs.c:1127:nd_region->target_node=ndr_desc->target_node;Sorry,Dan. I thought I missed your previous mail:
=========================================
Looks like it is the NFIT driver, thanks.If you're getting
NUMA_NO_NODEindax_kmemfrom the NFIT driver in means your ACPI NFIT table is failing to populate correct numa information. You could try the following to fix it up, but I think the real problem is that your platform BIOS needs to add the proper numa data.drivers/acpi/nfit/core.c +2
-9@@ -3005,15 +3005,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc->res = &res; ndr_desc->provider_data = nfit_spa; ndr_desc->attr_groups = acpi_nfit_region_attribute_groups; -if (spa->flags &ACPI_NFIT_PROXIMITY_VALID ) { - ndr_desc->numa_node =acpi_map_pxm_to_online_node ( - spa->proximity_domain); - ndr_desc->target_node =acpi_map_pxm_to_node ( - spa->proximity_domain); - }else { - ndr_desc->numa_node =NUMA_NO_NODE ; - ndr_desc->target_node =NUMA_NO_NODE ; - } + ndr_desc->numa_node =memory_add_physaddr_to_nid (spa->address); + ndr_desc->target_node =phys_to_target_node (spa->address);/* * Persistence domain bits are hierarchical, if
===================================================
Quoted 1 line
Do you still suggest fixing like this?
Are you saying that ACPI_NFIT_PROXIMITY_VALID is not set on your platform, or that pxm_to_node() returns NUMA_NO_NODE?
I would expect something like this:
drivers/acpi/nfit/core.c +0 -0
@@ -3007,6 +3007,15 @@ static int acpi_nfit_register_region(struct
acpi_nfit_desc *acpi_desc,
ndr_desc->target_node = NUMA_NO_NODE;
}+ /*
+ * Fallback to address based numa information if node lookup + * failed + */
+ if (ndr_desc->numa_node == NUMA_NO_NODE)
+ ndr_desc->numa_node = memory_add_physaddr_to_nid(spa->address);
+ if (ndr_desc->target_node == NUMA_NO_NODE)
+ phys_to_target_node(spa->address);
+
/*
* Persistence domain bits are hierarchical, if
* ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
Quoted 169 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Wednesday, September 15, 2021 1:16 PM
To: Justin He <[email protected]>
Cc: Vishal Verma <[email protected]>; Dave Jiang <[email protected]>; David Hildenbrand <[email protected]>; Linux NVDIMM <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2] device-dax: use fallback nid when numa node is invalidQuoted 9 lines · Justin He
Hi Dan,
Quoted 6 lines
-----Original Message-----
From: Dan Williams <[email protected]>
Sent: Friday, September 10, 2021 11:42 PM
To: Justin He <[email protected]>
Cc: Vishal Verma <[email protected]>; Dave Jiang <[email protected]>; David Hildenbrand <[email protected]>; LinuxNVDIMM
Quoted 13 lines
Quoted 13 lines
<[email protected]>; Linux Kernel Mailing List <linux- [email protected]>
Subject: Re: [PATCH v2] device-dax: use fallback nid when numa node is invalidQuoted 7 lines · Jia He
Previously,
numa_offwas set unconditionally indummy_numa_init()even with a fake numa node. Then ACPI sets node id asNUMA_NO_NODE(-1)afteracpi_map_pxm_to_node()because it regardsnuma_offas turning off the numa node. Hencedev_dax->target_nodeisNUMA_NO_NODEon arm64 with fake numa case.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Without this patch, pmem can't be probed as RAM devices on arm64 if SRAT table isn't present:
$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s1g
Quoted 2 lines
Quoted 2 lines
-a 64K
Quoted 1 line
kmem dax0.0: rejecting DAX region [mem 0x240400000-0x2bfffffff]
with
Quoted 14 lines
Quoted 14 lines
invalid node: -1
Quoted 13 lines
kmem: probe of dax0.0 failed with error -22
This fixes it by using fallback
memory_add_physaddr_to_nid()as nid.Suggested-by David Hildenbrand <[email protected]>Signed-off-by Jia He <[email protected]>---
v2: - rebase it based on David's "memory group" patch.
- drop the changes indev_dax_kmem_remove()since nid had been removed inremove_memory().drivers/dax/kmem.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)Quoted 5 lines
Quoted 5 lines
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax
Quoted 5 lines
drivers/dax/kmem.c +0
-0@@ -47,20 +47,7 @@ static int dev_dax_kmem_probe(struct dev_dax
*dev_dax)Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
drivers/dax/kmem.c +0
-1unsigned long total_len =0 ;struct dax_kmem_data *data;int i, rc, mapped =0 ; -int numa_node;drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 60
Quoted 10 lines
drivers/dax/kmem.c +0
-10- -/* -* Ensure good NUMA information for the persistent memory. -* Without this check, there is a risk that slow memory -* could be mixed in a node with faster memory, causing -* unavoidable performance issues. -*/ - numa_node = dev_dax->target_node; -if (numa_node <0 ) { - dev_warn(dev, "rejecting DAX region with invalidnode: %d\n",
Quoted 8 lines
Quoted 8 lines
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax
Quoted 8 lines
drivers/dax/kmem.c +1
-3- numa_node); -return -EINVAL ; - } +int numa_node = dev_dax->target_node;for (i =0 ; i < dev_dax->nr_range; i++) {struct range range;@@ -71,6 +58,22 @@ static int dev_dax_kmem_probe(struct dev_dax
*dev_dax)Quoted 81 lines
Quoted 28 lines
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 63
Quoted 6 lines
drivers/dax/kmem.c +3
-0i, range.start, range.end);continue ; } + +/* +* Ensure good NUMA information for the persistent memory.
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 64
Quoted 1 line
drivers/dax/kmem.c +1
-0+* Without this check, there is a risk but not fatal that slow
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 65
Quoted 1 line
drivers/dax/kmem.c +1
-0+* memory could be mixed in a node with faster memory, causing
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 66
Quoted 1 line
drivers/dax/kmem.c +1
-0+* unavoidable performance issues. Warn this and use fallback
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 70
Quoted 4 lines
drivers/dax/kmem.c +4
-0+* node id. +*/ +if (numa_node <0 ) { + int new_node =
memory_add_physaddr_to_nid(range.start);drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 72
Quoted 2 lines
drivers/dax/kmem.c +2
-0+ + dev_info(dev, "changing nid from %d to %d forDAX region [%#llx-%#llx]\n",
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 73
Quoted 1 line
drivers/dax/kmem.c +1
-0+ numa_node, new_node, range.start,range.end);
drivers/dax/kmem.c static int dev_dax_kmem_probe(struct dev_dax · line 77
Quoted 4 lines
drivers/dax/kmem.c +3
-0+ numa_node = new_node; + } + total_len +=range_len (&range);Quoted 7 lines
This fallback change belongs where the parent region for the namespace adopts its
target_node, because it's not clearmemory_add_physaddr_to_nid()is the right fallback in all situations. Here is where this setting is happening currently:
drivers/acpi/nfit/core.c:3004:ndr_desc->target_node=pxm_to_node(spa->proximity_domain);On my local arm64 guest('virt' machine type), the
target_nodeis set to -1 at this line.
That is:
The condition "spa->flags&ACPI_NFIT_PROXIMITY_VALID" is hit.Quoted 7 lines
drivers/acpi/nfit/core.c:3007:ndr_desc->target_node=NUMA_NO_NODE;drivers/nvdimm/e820.c:29: ndr_desc.target_node = nid;drivers/nvdimm/of_pmem.c:58: ndr_desc.target_node =
ndr_desc.numa_node;drivers/nvdimm/region_devs.c:1127:nd_region->target_node=ndr_desc->target_node;Sorry,Dan. I thought I missed your previous mail:
=========================================
Looks like it is the NFIT driver, thanks.If you're getting
NUMA_NO_NODEindax_kmemfrom the NFIT driver in means your ACPI NFIT table is failing to populate correct numa information. You could try the following to fix it up, but I think the real problem is that your platform BIOS needs to add the proper numa data.drivers/acpi/nfit/core.c +2
-9@@ -3005,15 +3005,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc->res = &res; ndr_desc->provider_data = nfit_spa; ndr_desc->attr_groups = acpi_nfit_region_attribute_groups; -if (spa->flags &ACPI_NFIT_PROXIMITY_VALID ) { - ndr_desc->numa_node =acpi_map_pxm_to_online_node ( - spa->proximity_domain); - ndr_desc->target_node =acpi_map_pxm_to_node ( - spa->proximity_domain); - }else { - ndr_desc->numa_node =NUMA_NO_NODE ; - ndr_desc->target_node =NUMA_NO_NODE ; - } + ndr_desc->numa_node =memory_add_physaddr_to_nid (spa->address); + ndr_desc->target_node =phys_to_target_node (spa->address);
Quoted 9 lines
Quoted 5 lines
drivers/acpi/nfit/core.c +0
-0/* * Persistence domain bits are hierarchical, if
===================================================Do you still suggest fixing like this?
Are you saying that
ACPI_NFIT_PROXIMITY_VALIDis not set on your platform, or thatpxm_to_node()returnsNUMA_NO_NODE?
Latter, ACPI_NFIT_PROXIMITY_VALID is *set* in my case.
Quoted 11 lines
I would expect something like this:
drivers/acpi/nfit/core.c +0
-0@@ -3007,6 +3007,15 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc->target_node =NUMA_NO_NODE ; }
drivers/acpi/nfit/core.c static int acpi_nfit_register_region(struct · line 3020
Quoted 10 lines
drivers/acpi/nfit/core.c +9
-0+/* +* Fallback to address based numa information if node lookup +* failed +*/ +if (ndr_desc->numa_node ==NUMA_NO_NODE ) + ndr_desc->numa_node =memory_add_physaddr_to_nid (spa- >address); +if (ndr_desc->target_node ==NUMA_NO_NODE ) +phys_to_target_node (spa->address); +
Would it better to add a dev_info() here to report this node id changing?
--
Cheers,
Justin (Jia He)
On Tue, Sep 14, 2021 at 11:51 PM Justin He <[email protected]> wrote:
[..]
Quoted 49 lines
Quoted 21 lines
Quoted 21 lines
drivers/acpi/nfit/core.c +2
-9@@ -3005,15 +3005,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc->res = &res; ndr_desc->provider_data = nfit_spa; ndr_desc->attr_groups = acpi_nfit_region_attribute_groups; -if (spa->flags &ACPI_NFIT_PROXIMITY_VALID ) { - ndr_desc->numa_node =acpi_map_pxm_to_online_node ( - spa->proximity_domain); - ndr_desc->target_node =acpi_map_pxm_to_node ( - spa->proximity_domain); - }else { - ndr_desc->numa_node =NUMA_NO_NODE ; - ndr_desc->target_node =NUMA_NO_NODE ; - } + ndr_desc->numa_node =memory_add_physaddr_to_nid (spa->address); + ndr_desc->target_node =phys_to_target_node (spa->address);Quoted 9 lines
Quoted 5 lines
drivers/acpi/nfit/core.c +0
-0/* * Persistence domain bits are hierarchical, if
===================================================Do you still suggest fixing like this?
Are you saying that
ACPI_NFIT_PROXIMITY_VALIDis not set on your platform, or thatpxm_to_node()returnsNUMA_NO_NODE?Latter,
ACPI_NFIT_PROXIMITY_VALIDis *set* in my case.Quoted 17 lines
I would expect something like this:
drivers/acpi/nfit/core.c +6
-0@@ -3007,6 +3007,15 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc->target_node =NUMA_NO_NODE ; } +/* +* Fallback to address based numa information if node lookup +* failed +*/ +if (ndr_desc->numa_node ==NUMA_NO_NODE ) + ndr_desc->numa_node = memory_add_physaddr_to_nid(spa-
Quoted 6 lines
drivers/acpi/nfit/core.c static int acpi_nfit_register_region(struct · line 3020
Quoted 4 lines
drivers/acpi/nfit/core.c +3
-0>address); +if (ndr_desc->target_node ==NUMA_NO_NODE ) +phys_to_target_node (spa->address); +Would it better to add a
dev_info()here to report this node id changing?
Yes, given all the possibilities here, a dev_info() reporting the final result of the node mapping is justifiable.