linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] handle memoryless nodes more appropriately
@ 2023-10-20 11:04 Qi Zheng
  2023-10-20 11:04 ` [PATCH v4 1/2] mm: page_alloc: skip memoryless nodes entirely Qi Zheng
  2023-10-20 11:04 ` [PATCH v4 2/2] mm: memory_hotplug: drop memoryless node from fallback lists Qi Zheng
  0 siblings, 2 replies; 3+ messages in thread
From: Qi Zheng @ 2023-10-20 11:04 UTC (permalink / raw)
  To: akpm, rppt, david, vbabka, mhocko
  Cc: willy, mgorman, mingo, aneesh.kumar, ying.huang, hannes,
	osalvador, linux-kernel, linux-mm, Qi Zheng

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 v3 -> v4:
 - fix typo in the commit messages and comment (pointed by Ingo Molnar)
 - collect Acked-bys

Changlog in v2 -> v3:
 - add a comment in [PATCH v2 2/2] (suggested by David Hildenbrand)
 - collect Acked-bys

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)
 - rebase onto the next-20231018

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

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

-- 
2.30.2



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

* [PATCH v4 1/2] mm: page_alloc: skip memoryless nodes entirely
  2023-10-20 11:04 [PATCH v4 0/2] handle memoryless nodes more appropriately Qi Zheng
@ 2023-10-20 11:04 ` Qi Zheng
  2023-10-20 11:04 ` [PATCH v4 2/2] mm: memory_hotplug: drop memoryless node from fallback lists Qi Zheng
  1 sibling, 0 replies; 3+ messages in thread
From: Qi Zheng @ 2023-10-20 11:04 UTC (permalink / raw)
  To: akpm, rppt, david, vbabka, mhocko
  Cc: willy, mgorman, mingo, aneesh.kumar, ying.huang, hannes,
	osalvador, linux-kernel, linux-mm, Qi Zheng

In find_next_best_node(), we skipped memoryless nodes
when building the zonelists of other normal nodes (N_NORMAL),
but did not skip the memoryless node itself when building
the zonelist. This will cause it to be traversed at runtime.

For example, say we have node0 and node1, node0 is memoryless
node, then the fall back order of node0 and node1 as follows:

[    0.153005] Fallback order for Node 0: 0 1
[    0.153564] Fallback order for Node 1: 1

After this patch, we skip memoryless node0 entirely, then
the fall back order of node0 and node1 as follows:

[    0.155236] Fallback order for Node 0: 1
[    0.155806] Fallback order for Node 1: 1

So it becomes completely invisible, which will reduce runtime
overhead.

And in this way, we will not try to allocate pages from memoryless
node0, then the panic mentioned in [1] will also be fixed. Even though
this problem has been solved by dropping the NODE_MIN_SIZE constrain
in x86 [2], it would be better to fix it in the core MM as well.

[1]. https://lore.kernel.org/all/20230212110305.93670-1-zhengqi.arch@bytedance.com/
[2]. https://lore.kernel.org/all/20231017062215.171670-1-rppt@kernel.org/

Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
---
 mm/page_alloc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ee392a324802..1f852929709f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5052,8 +5052,11 @@ int find_next_best_node(int node, nodemask_t *used_node_mask)
 	int min_val = INT_MAX;
 	int best_node = NUMA_NO_NODE;
 
-	/* Use the local node if we haven't already */
-	if (!node_isset(node, *used_node_mask)) {
+	/*
+	 * Use the local node if we haven't already, but for memoryless local
+	 * node, we should skip it and fall back to other nodes.
+	 */
+	if (!node_isset(node, *used_node_mask) && node_state(node, N_MEMORY)) {
 		node_set(node, *used_node_mask);
 		return node;
 	}
-- 
2.30.2



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

* [PATCH v4 2/2] mm: memory_hotplug: drop memoryless node from fallback lists
  2023-10-20 11:04 [PATCH v4 0/2] handle memoryless nodes more appropriately Qi Zheng
  2023-10-20 11:04 ` [PATCH v4 1/2] mm: page_alloc: skip memoryless nodes entirely Qi Zheng
@ 2023-10-20 11:04 ` Qi Zheng
  1 sibling, 0 replies; 3+ messages in thread
From: Qi Zheng @ 2023-10-20 11:04 UTC (permalink / raw)
  To: akpm, rppt, david, vbabka, mhocko
  Cc: willy, mgorman, mingo, aneesh.kumar, ying.huang, hannes,
	osalvador, linux-kernel, linux-mm, Qi Zheng

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 nodes from fallback lists in this case, just
call node_states_clear_node() before calling build_all_zonelists().

Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
---
 mm/memory_hotplug.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index d4a364fdaf8f..f019f7d6272c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -2036,12 +2036,16 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages,
 	/* reinitialise watermarks and update pcp limits */
 	init_per_zone_wmark_min();
 
+	/*
+	 * Make sure to mark the node as memory-less before rebuilding the zone
+	 * list. Otherwise this node would still appear in the fallback lists.
+	 */
+	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



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

end of thread, other threads:[~2023-10-20 11:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 11:04 [PATCH v4 0/2] handle memoryless nodes more appropriately Qi Zheng
2023-10-20 11:04 ` [PATCH v4 1/2] mm: page_alloc: skip memoryless nodes entirely Qi Zheng
2023-10-20 11:04 ` [PATCH v4 2/2] mm: memory_hotplug: drop memoryless node from fallback lists Qi Zheng

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