Skip to contentSkip to conversation

ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c

PATCH In review Yuntao Wang 2 participants 5 messages Dec 6, 2023 – Dec 12, 2023 ACPI

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.43.0
#1 lore raw

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.

---
 drivers/acpi/numa/srat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/numa/srat.c +1 -1
index 12f330b0eac0..9d2d0deb256e 100644
@@ -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;
 	}
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 ACPI/NUMA: Optimize the check for the availability of node values

In reply to Yuntao Wang

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.

---
 drivers/acpi/numa/srat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/numa/srat.c +2 -2
index 9d2d0deb256e..d58e5ef424f2 100644
@@ -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);
 	}
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 ACPI/NUMA: Fix the logic of getting the fake_pxm value

In reply to Yuntao Wang

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.

---
 drivers/acpi/numa/srat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/numa/srat.c +2 -2
index d58e5ef424f2..0214518fc582 100644
@@ -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];
 	}
Signature · 1 line
2.43.0
#4 lore raw
In reply to Yuntao Wang
Quoted 7 lines · Yuntao Wang

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!