2023-12-06 10:44:20

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c

This series fixes an issue and does some cleanups in drivers/acpi/numa/srat.c.

Yuntao Wang (3):
ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity()
ACPI/NUMA: Optimize the check for the availability of node values
ACPI/NUMA: Fix the logic of getting the fake_pxm value

drivers/acpi/numa/srat.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

--
2.43.0


2023-12-06 10:44:49

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity()

The acpi_map_pxm_to_node() function will never return a node value
that is greater than or equal to MAX_NUMNODES. Remove the unnecessary
`node >= MAX_NUMNODES` check to keep the code consistent with other users
of the acpi_map_pxm_to_node() function.

Signed-off-by: Yuntao Wang <[email protected]>
---
drivers/acpi/numa/srat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 12f330b0eac0..9d2d0deb256e 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -430,7 +430,7 @@ acpi_parse_gi_affinity(union acpi_subtable_headers *header,
return -EINVAL;

node = acpi_map_pxm_to_node(gi_affinity->proximity_domain);
- if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
+ if (node == NUMA_NO_NODE) {
pr_err("SRAT: Too many proximity domains.\n");
return -EINVAL;
}
--
2.43.0

2023-12-06 10:44:59

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH 2/3] ACPI/NUMA: Optimize the check for the availability of node values

The first_unset_node() function returns the first unused node in
nodes_found_map. If all nodes are in use, the function returns
MAX_NUMNODES. We can use this return value to determine whether there are
any available node values in nodes_found_map, eliminating the need to use
the nodes_weight() function to perform this check.

Signed-off-by: Yuntao Wang <[email protected]>
---
drivers/acpi/numa/srat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 9d2d0deb256e..d58e5ef424f2 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -67,9 +67,9 @@ int acpi_map_pxm_to_node(int pxm)
node = pxm_to_node_map[pxm];

if (node == NUMA_NO_NODE) {
- if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
- return NUMA_NO_NODE;
node = first_unset_node(nodes_found_map);
+ if (node >= MAX_NUMNODES)
+ return NUMA_NO_NODE;
__acpi_map_pxm_to_node(pxm, node);
node_set(node, nodes_found_map);
}
--
2.43.0

2023-12-06 10:45:54

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH 3/3] ACPI/NUMA: Fix the logic of getting the fake_pxm value

The for loop does not iterate over the last element of the node_to_pxm_map
array. This could lead to a conflict between the final fake_pxm value and
the existing pxm values. That is, the final fake_pxm value can not be
guaranteed to be an unused pxm value.

Signed-off-by: Yuntao Wang <[email protected]>
---
drivers/acpi/numa/srat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index d58e5ef424f2..0214518fc582 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -183,7 +183,7 @@ static int __init slit_valid(struct acpi_table_slit *slit)
int i, j;
int d = slit->locality_count;
for (i = 0; i < d; i++) {
- for (j = 0; j < d; j++) {
+ for (j = 0; j < d; j++) {
u8 val = slit->entry[d*i + j];
if (i == j) {
if (val != LOCAL_DISTANCE)
@@ -532,7 +532,7 @@ int __init acpi_numa_init(void)
*/

/* fake_pxm is the next unused PXM value after SRAT parsing */
- for (i = 0, fake_pxm = -1; i < MAX_NUMNODES - 1; i++) {
+ for (i = 0, fake_pxm = -1; i < MAX_NUMNODES; i++) {
if (node_to_pxm_map[i] > fake_pxm)
fake_pxm = node_to_pxm_map[i];
}
--
2.43.0

2023-12-12 19:38:16

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c

On Wed, Dec 6, 2023 at 11:44 AM Yuntao Wang <[email protected]> wrote:
>
> This series fixes an issue and does some cleanups in drivers/acpi/numa/srat.c.
>
> Yuntao Wang (3):
> ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity()
> ACPI/NUMA: Optimize the check for the availability of node values
> ACPI/NUMA: Fix the logic of getting the fake_pxm value

All patches applied as 6.8 material with some edits in the changelogs.

Thanks!