* [PATCH] acpi, numa: fix pxm to online numa node associations
@ 2018-03-16 3:08 Dan Williams
2018-03-17 1:16 ` Dan Williams
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Williams @ 2018-03-16 3:08 UTC (permalink / raw)
To: linux-nvdimm
Cc: linux-acpi, Rafael J. Wysocki, Toshi Kani, linux-kernel, stable
Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added
support for mapping a given proximity to its nearest, by SLIT distance,
online node. However, it sometimes returns unexpected results due to the
fact that it switches from comparing the PXM node to the last node that
was closer than the current max.
for_each_online_node(n) {
dist = node_distance(node, n);
if (dist < min_dist) {
min_dist = dist;
node = n; <---- from this point we're using the
wrong node for node_distance()
Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()")
Cc: <stable@vger.kernel.org>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Rafael, I can take this through the nvdimm tree with your ack. I have a
few other nvdimm fixes pending for 4.16.
drivers/acpi/numa.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 8ccaae3550d2..85167603b9c9 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm)
*/
int acpi_map_pxm_to_online_node(int pxm)
{
- int node, n, dist, min_dist;
+ int node, min_node;
node = acpi_map_pxm_to_node(pxm);
if (node == NUMA_NO_NODE)
node = 0;
+ min_node = node;
if (!node_online(node)) {
- min_dist = INT_MAX;
+ int min_dist = INT_MAX, dist, n;
+
for_each_online_node(n) {
dist = node_distance(node, n);
if (dist < min_dist) {
min_dist = dist;
- node = n;
+ min_node = n;
}
}
}
- return node;
+ return min_node;
}
EXPORT_SYMBOL(acpi_map_pxm_to_online_node);
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] acpi, numa: fix pxm to online numa node associations
2018-03-16 3:08 [PATCH] acpi, numa: fix pxm to online numa node associations Dan Williams
@ 2018-03-17 1:16 ` Dan Williams
2018-03-18 21:55 ` Rafael J. Wysocki
2018-03-19 15:21 ` Kani, Toshi
2 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2018-03-17 1:16 UTC (permalink / raw)
To: linux-nvdimm
Cc: Linux ACPI, Rafael J. Wysocki, Linux Kernel Mailing List, stable
[ adding Toshi's correct address ]
On Thu, Mar 15, 2018 at 8:08 PM, Dan Williams <dan.j.williams@intel.com> wrote:
> Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added
> support for mapping a given proximity to its nearest, by SLIT distance,
> online node. However, it sometimes returns unexpected results due to the
> fact that it switches from comparing the PXM node to the last node that
> was closer than the current max.
>
> for_each_online_node(n) {
> dist = node_distance(node, n);
> if (dist < min_dist) {
> min_dist = dist;
> node = n; <---- from this point we're using the
> wrong node for node_distance()
>
>
> Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()")
> Cc: <stable@vger.kernel.org>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Rafael, I can take this through the nvdimm tree with your ack. I have a
> few other nvdimm fixes pending for 4.16.
>
> drivers/acpi/numa.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
> index 8ccaae3550d2..85167603b9c9 100644
> --- a/drivers/acpi/numa.c
> +++ b/drivers/acpi/numa.c
> @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm)
> */
> int acpi_map_pxm_to_online_node(int pxm)
> {
> - int node, n, dist, min_dist;
> + int node, min_node;
>
> node = acpi_map_pxm_to_node(pxm);
>
> if (node == NUMA_NO_NODE)
> node = 0;
>
> + min_node = node;
> if (!node_online(node)) {
> - min_dist = INT_MAX;
> + int min_dist = INT_MAX, dist, n;
> +
> for_each_online_node(n) {
> dist = node_distance(node, n);
> if (dist < min_dist) {
> min_dist = dist;
> - node = n;
> + min_node = n;
> }
> }
> }
>
> - return node;
> + return min_node;
> }
> EXPORT_SYMBOL(acpi_map_pxm_to_online_node);
>
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] acpi, numa: fix pxm to online numa node associations
2018-03-16 3:08 [PATCH] acpi, numa: fix pxm to online numa node associations Dan Williams
2018-03-17 1:16 ` Dan Williams
@ 2018-03-18 21:55 ` Rafael J. Wysocki
2018-03-19 15:21 ` Kani, Toshi
2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2018-03-18 21:55 UTC (permalink / raw)
To: Dan Williams
Cc: Toshi Kani, linux-nvdimm, Rafael J. Wysocki,
Linux Kernel Mailing List, Stable, ACPI Devel Maling List
On Fri, Mar 16, 2018 at 4:08 AM, Dan Williams <dan.j.williams@intel.com> wrote:
> Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added
> support for mapping a given proximity to its nearest, by SLIT distance,
> online node. However, it sometimes returns unexpected results due to the
> fact that it switches from comparing the PXM node to the last node that
> was closer than the current max.
>
> for_each_online_node(n) {
> dist = node_distance(node, n);
> if (dist < min_dist) {
> min_dist = dist;
> node = n; <---- from this point we're using the
> wrong node for node_distance()
>
>
> Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()")
> Cc: <stable@vger.kernel.org>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Rafael, I can take this through the nvdimm tree with your ack. I have a
> few other nvdimm fixes pending for 4.16.
OK
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> drivers/acpi/numa.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
> index 8ccaae3550d2..85167603b9c9 100644
> --- a/drivers/acpi/numa.c
> +++ b/drivers/acpi/numa.c
> @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm)
> */
> int acpi_map_pxm_to_online_node(int pxm)
> {
> - int node, n, dist, min_dist;
> + int node, min_node;
>
> node = acpi_map_pxm_to_node(pxm);
>
> if (node == NUMA_NO_NODE)
> node = 0;
>
> + min_node = node;
> if (!node_online(node)) {
> - min_dist = INT_MAX;
> + int min_dist = INT_MAX, dist, n;
> +
> for_each_online_node(n) {
> dist = node_distance(node, n);
> if (dist < min_dist) {
> min_dist = dist;
> - node = n;
> + min_node = n;
> }
> }
> }
>
> - return node;
> + return min_node;
> }
> EXPORT_SYMBOL(acpi_map_pxm_to_online_node);
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] acpi, numa: fix pxm to online numa node associations
2018-03-16 3:08 [PATCH] acpi, numa: fix pxm to online numa node associations Dan Williams
2018-03-17 1:16 ` Dan Williams
2018-03-18 21:55 ` Rafael J. Wysocki
@ 2018-03-19 15:21 ` Kani, Toshi
2 siblings, 0 replies; 4+ messages in thread
From: Kani, Toshi @ 2018-03-19 15:21 UTC (permalink / raw)
To: dan.j.williams, linux-nvdimm
Cc: linux-acpi, rafael.j.wysocki, toshi.kani, linux-kernel, stable
On Thu, 2018-03-15 at 20:08 -0700, Dan Williams wrote:
> Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added
> support for mapping a given proximity to its nearest, by SLIT distance,
> online node. However, it sometimes returns unexpected results due to the
> fact that it switches from comparing the PXM node to the last node that
> was closer than the current max.
>
> for_each_online_node(n) {
> dist = node_distance(node, n);
> if (dist < min_dist) {
> min_dist = dist;
> node = n; <---- from this point we're using the
> wrong node for node_distance()
ouch...
>
>
> Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()")
> Cc: <stable@vger.kernel.org>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Thanks Dan for the fix!
Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
-Toshi
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-19 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-16 3:08 [PATCH] acpi, numa: fix pxm to online numa node associations Dan Williams
2018-03-17 1:16 ` Dan Williams
2018-03-18 21:55 ` Rafael J. Wysocki
2018-03-19 15:21 ` Kani, Toshi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).