Skip to contentSkip to conversation

arm64: init: override deferred_page_init_max_threads

PATCH In review Eric Chanudet 4 participants 6 messages May 20, 2024 – May 22, 2024 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: init: override deferred_page_init_max_threads

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |
---
 arch/arm64/mm/init.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/mm/init.c +7 -0
index 9b5ab6818f7f..71f5188fe63d 100644
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif
+
 int pfn_is_map_memory(unsigned long pfn)
 {
 	phys_addr_t addr = PFN_PHYS(pfn);
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Eric Chanudet

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |
---
 arch/arm64/mm/init.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/mm/init.c +0 -0
index 9b5ab6818f7f..71f5188fe63d 100644

arch/arm64/mm/init.c static void __init zone_sizes_init(void) · line 166

Quoted 9 lines
arch/arm64/mm/init.c +6 -0
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif

LGTM,

Quoted 7 lines
arch/arm64/mm/init.c +1 -0
+
 int pfn_is_map_memory(unsigned long pfn)
 {
 	phys_addr_t addr = PFN_PHYS(pfn);
Signature · 1 line
2.44.0
#2 lore raw
In reply to Eric Chanudet

(added powerpc folks)

Quoted 27 lines · Eric Chanudet

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |
---
 arch/arm64/mm/init.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/mm/init.c +0 -0
index 9b5ab6818f7f..71f5188fe63d 100644

arch/arm64/mm/init.c static void __init zone_sizes_init(void) · line 167

Quoted 10 lines
arch/arm64/mm/init.c +7 -0
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif
+

Maybe we should make this default and let architectures that want a single thread override deferred_page_init_max_threads() to return 1?

Quoted 6 lines
arch/arm64/mm/init.c +0 -0
 int pfn_is_map_memory(unsigned long pfn)
 {
 	phys_addr_t addr = PFN_PHYS(pfn);
Signature · 1 line
2.44.0
Signature · 2 lines
Sincerely yours,
Mike.
#3 lore raw
Quoted 33 lines · Mike Rapoport

(added powerpc folks)

Quoted 30 lines · Eric Chanudet

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |
---
 arch/arm64/mm/init.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/mm/init.c +0 -0
index 9b5ab6818f7f..71f5188fe63d 100644
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
Quoted 10 lines

arch/arm64/mm/init.c static void __init zone_sizes_init(void) · line 167

Quoted 7 lines
arch/arm64/mm/init.c +7 -0
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif
+

Maybe we should make this default and let architectures that want a single thread override deferred_page_init_max_threads() to return 1?

It would affect more archs than I can try this on. Currently, only x86 (with this change, arm64) return more than one thread.

I'm happy to send a v2 inverting the logic if you find it preferable.

Best,

Quoted 11 lines
Quoted 6 lines
arch/arm64/mm/init.c +0 -0
 int pfn_is_map_memory(unsigned long pfn)
 {
 	phys_addr_t addr = PFN_PHYS(pfn);
Signature · 1 line
2.44.0
Signature · 2 lines
Sincerely yours,
Mike.
Signature · 1 line
Eric Chanudet
#4 lore raw
Quoted 2 lines · Eric Chanudet
Quoted 1 line · Mike Rapoport

(added powerpc folks)

Thanks Mike.

Quoted 9 lines
Quoted 9 lines · Eric Chanudet
Quoted 8 lines

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |

How did you measure this, just some printks in page_alloc_init_late() or something more sophisticated? Just so I can do some comparable measurements.

Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
arch/arm64/mm/init.c +0 -0
index 9b5ab6818f7f..71f5188fe63d 100644
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
Quoted 10 lines

arch/arm64/mm/init.c static void __init zone_sizes_init(void) · line 167

Quoted 7 lines
arch/arm64/mm/init.c +7 -0
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif
+

Maybe we should make this default and let architectures that want a single thread override deferred_page_init_max_threads() to return 1?

Quoted 2 lines

It would affect more archs than I can try this on. Currently, only x86 (with this change, arm64) return more than one thread.

I can test powerpc and we can find someone to test s390. No other arches have it enabled in their defconfig.

Quoted 1 line

I'm happy to send a v2 inverting the logic if you find it preferable.

That seems preferable. It's a scalability feature, it makes no sense for the default to be a single thread AFAICS.

cheers

#5 lore raw
Quoted 24 lines · Michael Ellerman
Quoted 2 lines · Eric Chanudet
Quoted 1 line · Mike Rapoport

(added powerpc folks)

Thanks Mike.

Quoted 9 lines
Quoted 9 lines · Eric Chanudet
Quoted 8 lines

This was the behavior prior to making the function arch-specific with commit ecd096506922 ("mm: make deferred init's max threads arch-specific")

Architectures can override the generic implementation that uses only one CPU. Setting DEFERRED_STRUCT_PAGE_INIT and testing on a few arm64 platforms shows faster deferred_init_memmap completions:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
|         | x13s        | SA8775p-ride | Ampere R137-P31 | Ampere HR330 |
|         | Metal, 32GB | VM, 36GB     | VM, 58GB        | Metal, 128GB |
|         | 8cpus       | 8cpus        | 8cpus           | 32cpus       |
|---------|-------------|--------------|-----------------|--------------|
| threads |  ms     (%) | ms       (%) |  ms         (%) |  ms      (%) |
|---------|-------------|--------------|-----------------|--------------|
| 1       | 108    (0%) | 72      (0%) | 224        (0%) | 324     (0%) |
| cpus    |  24  (-77%) | 36    (-50%) |  40      (-82%) |  56   (-82%) |
Quoted 2 lines

How did you measure this, just some printks in page_alloc_init_late() or something more sophisticated? Just so I can do some comparable measurements.

I used the existing pr_info in deferred_init_memmap().

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 5 lines
arch/arm64/mm/init.c +0 -0
index 9b5ab6818f7f..71f5188fe63d 100644

arch/arm64/mm/init.c static void __init zone_sizes_init(void) · line 167

Quoted 10 lines
arch/arm64/mm/init.c +7 -0
@@ -158,6 +158,13 @@ static void __init zone_sizes_init(void)
 	free_area_init(max_zone_pfns);
 }
 
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask)
+{
+	return max_t(int, cpumask_weight(node_cpumask), 1);
+}
+#endif
+

Maybe we should make this default and let architectures that want a single thread override deferred_page_init_max_threads() to return 1?

Quoted 5 lines
Quoted 2 lines

It would affect more archs than I can try this on. Currently, only x86 (with this change, arm64) return more than one thread.

I can test powerpc and we can find someone to test s390. No other arches have it enabled in their defconfig.

Many thanks!

Quoted 4 lines
Quoted 1 line

I'm happy to send a v2 inverting the logic if you find it preferable.

That seems preferable. It's a scalability feature, it makes no sense for the default to be a single thread AFAICS.

Understood, I'll respin.

Signature · 1 line
Eric Chanudet