2023-10-19 07:38:41

by Qi Zheng

[permalink] [raw]
Subject: [PATCH v2 0/2] handle memoryless nodes more appropriately

Hi all,

Currently, in the process of initialization or offline memory, memoryless
nodes will still be built into the fallback list of itself or other nodes.

This is not what we expected, so this patch series removes memoryless
nodes from the fallback list entirely.

This series is based on the next-20231018.

Comments and suggestions are welcome.

Thanks,
Qi

Changlog in v1 -> v2:
- modify the commit message in [PATCH 1/2], mention that it can also fix the
specific crash. (suggested by Ingo Molnar)

Qi Zheng (2):
mm: page_alloc: skip memoryless nodes entirely
mm: memory_hotplug: drop memoryless node from fallback lists

mm/memory_hotplug.c | 2 +-
mm/page_alloc.c | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)

--
2.30.2


2023-10-19 07:38:53

by Qi Zheng

[permalink] [raw]
Subject: [PATCH v2 2/2] mm: memory_hotplug: drop memoryless node from fallback lists

In offline_pages(), if a node becomes memoryless, we
will clear its N_MEMORY state by calling node_states_clear_node().
But we do this after rebuilding the zonelists by calling
build_all_zonelists(), which will cause this memoryless node to
still be in the fallback list of other nodes. This will incur
some runtime overhead.

To drop memoryless node from fallback lists in this case, just
call node_states_clear_node() before calling build_all_zonelists().

Signed-off-by: Qi Zheng <[email protected]>
---
mm/memory_hotplug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index d4a364fdaf8f..18af399627f0 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -2036,12 +2036,12 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
/* reinitialise watermarks and update pcp limits */
init_per_zone_wmark_min();

+ node_states_clear_node(node, &arg);
if (!populated_zone(zone)) {
zone_pcp_reset(zone);
build_all_zonelists(NULL);
}

- node_states_clear_node(node, &arg);
if (arg.status_change_nid >= 0) {
kcompactd_stop(node);
kswapd_stop(node);
--
2.30.2

2023-10-19 07:58:24

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] handle memoryless nodes more appropriately

On 19.10.23 09:36, Qi Zheng wrote:
> Hi all,
>
> Currently, in the process of initialization or offline memory, memoryless
> nodes will still be built into the fallback list of itself or other nodes.
>
> This is not what we expected, so this patch series removes memoryless
> nodes from the fallback list entirely.

What's the end result of this change -- IOW why do we care? Patch #1
mentions "which will reduce runtime overhead." and patch #2 mentions
"This will incur some runtime overhead.". IIUC the comment in patch #1
correctly, these changes don't fix anything, correct?

Did you look into showing a performance gain?

--
Cheers,

David / dhildenb

2023-10-19 08:12:24

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] mm: memory_hotplug: drop memoryless node from fallback lists

On 19.10.23 09:36, Qi Zheng wrote:
> In offline_pages(), if a node becomes memoryless, we
> will clear its N_MEMORY state by calling node_states_clear_node().
> But we do this after rebuilding the zonelists by calling
> build_all_zonelists(), which will cause this memoryless node to
> still be in the fallback list of other nodes. This will incur
> some runtime overhead.
>
> To drop memoryless node from fallback lists in this case, just
> call node_states_clear_node() before calling build_all_zonelists().
>
> Signed-off-by: Qi Zheng <[email protected]>
> ---
> mm/memory_hotplug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index d4a364fdaf8f..18af399627f0 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -2036,12 +2036,12 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
> /* reinitialise watermarks and update pcp limits */
> init_per_zone_wmark_min();
>
> + node_states_clear_node(node, &arg);
> if (!populated_zone(zone)) {
> zone_pcp_reset(zone);
> build_all_zonelists(NULL);
> }
>
> - node_states_clear_node(node, &arg);
> if (arg.status_change_nid >= 0) {
> kcompactd_stop(node);
> kswapd_stop(node);

Probably worth a comment.

/*
* Make sure to mark the node as memory-less before rebuilding the zone
* list. Otherwise this node would still appear in the fallback lists.
*/

Acked-by: David Hildenbrand <[email protected]>

--
Cheers,

David / dhildenb

2023-10-19 08:18:13

by Qi Zheng

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] handle memoryless nodes more appropriately

Hi David,

On 2023/10/19 15:56, David Hildenbrand wrote:
> On 19.10.23 09:36, Qi Zheng wrote:
>> Hi all,
>>
>> Currently, in the process of initialization or offline memory, memoryless
>> nodes will still be built into the fallback list of itself or other
>> nodes.
>>
>> This is not what we expected, so this patch series removes memoryless
>> nodes from the fallback list entirely.
>
> What's the end result of this change -- IOW why do we care? Patch #1
> mentions "which will reduce runtime overhead." and patch #2 mentions
> "This will incur some runtime overhead.". IIUC the comment in patch #1
> correctly, these changes don't fix anything, correct?

Yes, after dropping the NODE_MIN_SIZE constrain in x86, the panic
problem fixed by this patch no longer exists (Unless there are other
architectures that have this constrain).

The reason I am re-sending this patch is that I agree with Ingo's point
of view:

```
While I agree with dropping the limitation, and I agree that
9391a3f9c7f1 should have provided more of a justification, I believe a
core MM fix is in order as well, for it to not crash.
```

I also think that core MM should be safe (not crash) even in some weird
topology.

>
> Did you look into showing a performance gain?
>

No, and I think the performance gain should be small, after all it just
traverses one less node. ;)

Thanks,
Qi


2023-10-19 08:23:41

by Qi Zheng

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] mm: memory_hotplug: drop memoryless node from fallback lists

Hi David,

On 2023/10/19 16:11, David Hildenbrand wrote:
> On 19.10.23 09:36, Qi Zheng wrote:
>> In offline_pages(), if a node becomes memoryless, we
>> will clear its N_MEMORY state by calling node_states_clear_node().
>> But we do this after rebuilding the zonelists by calling
>> build_all_zonelists(), which will cause this memoryless node to
>> still be in the fallback list of other nodes. This will incur
>> some runtime overhead.
>>
>> To drop memoryless node from fallback lists in this case, just
>> call node_states_clear_node() before calling build_all_zonelists().
>>
>> Signed-off-by: Qi Zheng <[email protected]>
>> ---
>>   mm/memory_hotplug.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>> index d4a364fdaf8f..18af399627f0 100644
>> --- a/mm/memory_hotplug.c
>> +++ b/mm/memory_hotplug.c
>> @@ -2036,12 +2036,12 @@ int __ref offline_pages(unsigned long
>> start_pfn, unsigned long nr_pages,
>>       /* reinitialise watermarks and update pcp limits */
>>       init_per_zone_wmark_min();
>> +    node_states_clear_node(node, &arg);
>>       if (!populated_zone(zone)) {
>>           zone_pcp_reset(zone);
>>           build_all_zonelists(NULL);
>>       }
>> -    node_states_clear_node(node, &arg);
>>       if (arg.status_change_nid >= 0) {
>>           kcompactd_stop(node);
>>           kswapd_stop(node);
>
> Probably worth a comment.
>
> /*
>  * Make sure to mark the node as memory-less before rebuilding the zone
>  * list. Otherwise this node would still appear in the fallback lists.
>  */

OK, will add it in the v3.

>
> Acked-by: David Hildenbrand <[email protected]>

Thanks.

>