public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c
@ 2023-12-06 10:43 Yuntao Wang
  2023-12-06 10:43 ` [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity() Yuntao Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yuntao Wang @ 2023-12-06 10:43 UTC (permalink / raw)
  To: linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Len Brown, Dan Williams, Alison Schofield,
	Dave Hansen, 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

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

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity()
  2023-12-06 10:43 [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Yuntao Wang
@ 2023-12-06 10:43 ` Yuntao Wang
  2023-12-06 10:43 ` [PATCH 2/3] ACPI/NUMA: Optimize the check for the availability of node values Yuntao Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yuntao Wang @ 2023-12-06 10:43 UTC (permalink / raw)
  To: linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Len Brown, Dan Williams, Alison Schofield,
	Dave Hansen, Yuntao Wang

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 <ytcoode@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ACPI/NUMA: Optimize the check for the availability of node values
  2023-12-06 10:43 [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Yuntao Wang
  2023-12-06 10:43 ` [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity() Yuntao Wang
@ 2023-12-06 10:43 ` Yuntao Wang
  2023-12-06 10:43 ` [PATCH 3/3] ACPI/NUMA: Fix the logic of getting the fake_pxm value Yuntao Wang
  2023-12-12 19:37 ` [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Yuntao Wang @ 2023-12-06 10:43 UTC (permalink / raw)
  To: linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Len Brown, Dan Williams, Alison Schofield,
	Dave Hansen, 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.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ACPI/NUMA: Fix the logic of getting the fake_pxm value
  2023-12-06 10:43 [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Yuntao Wang
  2023-12-06 10:43 ` [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity() Yuntao Wang
  2023-12-06 10:43 ` [PATCH 2/3] ACPI/NUMA: Optimize the check for the availability of node values Yuntao Wang
@ 2023-12-06 10:43 ` Yuntao Wang
  2023-12-12 19:37 ` [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Yuntao Wang @ 2023-12-06 10:43 UTC (permalink / raw)
  To: linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Len Brown, Dan Williams, Alison Schofield,
	Dave Hansen, 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.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c
  2023-12-06 10:43 [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Yuntao Wang
                   ` (2 preceding siblings ...)
  2023-12-06 10:43 ` [PATCH 3/3] ACPI/NUMA: Fix the logic of getting the fake_pxm value Yuntao Wang
@ 2023-12-12 19:37 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2023-12-12 19:37 UTC (permalink / raw)
  To: Yuntao Wang
  Cc: linux-kernel, linux-acpi, Rafael J. Wysocki, Len Brown,
	Dan Williams, Alison Schofield, Dave Hansen

On Wed, Dec 6, 2023 at 11:44 AM Yuntao Wang <ytcoode@gmail.com> 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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-12 19:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-06 10:43 [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Yuntao Wang
2023-12-06 10:43 ` [PATCH 1/3] ACPI/NUMA: Remove unnecessary check in acpi_parse_gi_affinity() Yuntao Wang
2023-12-06 10:43 ` [PATCH 2/3] ACPI/NUMA: Optimize the check for the availability of node values Yuntao Wang
2023-12-06 10:43 ` [PATCH 3/3] ACPI/NUMA: Fix the logic of getting the fake_pxm value Yuntao Wang
2023-12-12 19:37 ` [PATCH 0/3] ACPI/NUMA: A few fixes and cleanups in drivers/acpi/numa/srat.c Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox