Skip to contentSkip to conversation

mm/fake-numa: fix under-allocation detection logic in uniform split

RFC PATCH Superseded Sang-Heon Jeon 2 participants 7 messages Apr 13 – Apr 16

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mm/fake-numa: fix under-allocation detection logic in uniform split

Hello,

This series fixes under-allocation detection logic and an outdated comment in uniform NUMA node splitting.

I found this while going through NUMA enulation codes. If I misunderstood, feel free to tell me about it.

Thank you for taking your valuable time to review this work.

Best Regards,
Sang-Heon Jeon

Sang-Heon Jeon (2):
mm/fake-numa: fix under-allocation detection in uniform split mm/fake-numa: fix outdated return value comment

 mm/numa_emulation.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

RFC PATCH 1/2 mm/fake-numa: fix under-allocation detection logic in uniform split

When split NUMA node uniformly, split_nodes_size_interleave_uniform() returns the next absolute node ID, not the number of nodes created.

The previous under-allocation detection logic compares next absolute node ID (ret) and request count (n), which only works when nid starts at 0.

Fix under-allocation detection logic to compare the number of actually created nodes (ret - nid) against the request count (n).

Fixes cc9aec03e58f ("x86/numa_emulation: Introduce uniform split capability") # 4.19
---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index 703c8fa05048..e7f856c8f2a1 100644
@@ -416,7 +416,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 					n, &pi.blk[0], nid);
 			if (ret < 0)
 				break;
-			if (ret < n) {
+			if (ret - nid < n) {
 				pr_info("%s: phys: %d only got %d of %ld nodes, failing\n",
 						__func__, i, ret, n);
 				ret = -1;
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Hi,

Quoted 4 lines · Sang-Heon Jeon

When split NUMA node uniformly, split_nodes_size_interleave_uniform() returns the next absolute node ID, not the number of nodes created.

The previous under-allocation detection logic compares next absolute node

I'd replace "previous" with "existing"

Quoted 4 lines

ID (ret) and request count (n), which only works when nid starts at 0.

Fix under-allocation detection logic to compare the number of actually created nodes (ret - nid) against the request count (n).

It would be nice to have an example of memory configuration and numa=fake=nU that demonstrates the issue.

Quoted 24 lines
Fixes cc9aec03e58f ("x86/numa_emulation: Introduce uniform split capability") # 4.19
---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index 703c8fa05048..e7f856c8f2a1 100644
@@ -416,7 +416,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 					n, &pi.blk[0], nid);
 			if (ret < 0)
 				break;
-			if (ret < n) {
+			if (ret - nid < n) {
 				pr_info("%s: phys: %d only got %d of %ld nodes, failing\n",
 						__func__, i, ret, n);
 				ret = -1;
Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours,
Mike.
#3 lore raw

Hello, Mike

Quoted 10 lines · Mike Rapoport

Hi,

Quoted 4 lines · Sang-Heon Jeon

When split NUMA node uniformly, split_nodes_size_interleave_uniform() returns the next absolute node ID, not the number of nodes created.

The previous under-allocation detection logic compares next absolute node

I'd replace "previous" with "existing"

That's good :) I'll replace it.

Quoted 7 lines
Quoted 4 lines

ID (ret) and request count (n), which only works when nid starts at 0.

Fix under-allocation detection logic to compare the number of actually created nodes (ret - nid) against the request count (n).

It would be nice to have an example of memory configuration and numa=fake=nU that demonstrates the issue.

Sure, I'll add it.

Quoted 20 lines
Quoted 20 lines
Fixes cc9aec03e58f ("x86/numa_emulation: Introduce uniform split capability") # 4.19
---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index 703c8fa05048..e7f856c8f2a1 100644
@@ -416,7 +416,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
                                      n, &pi.blk[0], nid);
                      if (ret < 0)
                              break;
-                     if (ret < n) {
+                     if (ret - nid < n) {
                              pr_info("%s: phys: %d only got %d of %ld nodes, failing\n",
                                              __func__, i, ret, n);
Quoted 8 lines
Quoted 4 lines
mm/numa_emulation.c +0 -1
                              ret = -1;
--

2.43.0

--
Sincerely yours,
Mike.

Thanks for your kind review.

Best Regards,
Sang-Heon Jeon

#4 lore raw

RFC PATCH 2/2 mm/fake-numa: fix outdated return value comment

In reply to Sang-Heon Jeon

split_nodes_size_interleave_uniform() returns absolute node ID when succeed, not zero.

Fix the outdated comment to match the actual return value.

---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index e7f856c8f2a1..c1d0a76aef64 100644
@@ -214,7 +214,7 @@ static u64 uniform_size(u64 max_addr, u64 base, u64 hole, int nr_nodes)
  * Sets up fake nodes of `size' interleaved over physical nodes ranging from
  * `addr' to `max_addr'.
  *
- * Returns zero on success or negative on error.
+ * Returns absolute node ID on success or negative on error.
  */
 static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei,
 					      struct numa_meminfo *pi,
Signature · 1 line
2.43.0
maintainer
#5 lore raw

Re: [RFC PATCH 2/2] mm/fake-numa: fix outdated return value comment

Hi,

Quoted 4 lines · Sang-Heon Jeon

split_nodes_size_interleave_uniform() returns absolute node ID when succeed, not zero.

Fix the outdated comment to match the actual return value.

This should be merged in the previous patch.

Quoted 21 lines
---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index e7f856c8f2a1..c1d0a76aef64 100644
@@ -214,7 +214,7 @@ static u64 uniform_size(u64 max_addr, u64 base, u64 hole, int nr_nodes)
  * Sets up fake nodes of `size' interleaved over physical nodes ranging from
  * `addr' to `max_addr'.
  *
- * Returns zero on success or negative on error.
+ * Returns absolute node ID on success or negative on error.
  */
 static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei,
 					      struct numa_meminfo *pi,
Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours,
Mike.
#6 lore raw

Re: [RFC PATCH 2/2] mm/fake-numa: fix outdated return value comment

Hello,

Quoted 10 lines · Mike Rapoport

Hi,

Quoted 4 lines · Sang-Heon Jeon

split_nodes_size_interleave_uniform() returns absolute node ID when succeed, not zero.

Fix the outdated comment to match the actual return value.

This should be merged in the previous patch.

I got it. I'll include it in the v2 patch.

Quoted 17 lines
Quoted 17 lines
---
 mm/numa_emulation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/numa_emulation.c +1 -1
index e7f856c8f2a1..c1d0a76aef64 100644
@@ -214,7 +214,7 @@ static u64 uniform_size(u64 max_addr, u64 base, u64 hole, int nr_nodes)
  * Sets up fake nodes of `size' interleaved over physical nodes ranging from
  * `addr' to `max_addr'.
  *
- * Returns zero on success or negative on error.
+ * Returns absolute node ID on success or negative on error.
  */
 static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei,
Quoted 8 lines
Quoted 4 lines
mm/numa_emulation.c +0 -1
                                            struct numa_meminfo *pi,
--

2.43.0

--
Sincerely yours,
Mike.

Best Regards,
Sang-Heon Jeon