Skip to contentSkip to conversation

slub: use N_NORMAL_MEMORY in can_free_to_pcs to handle remote frees

PATCH In review Hao Li 4 participants 6 messages Apr 3 – Apr 6

Subsystems (2)
lore
Share & tools
lore

Hao Li

author reviewer
#0 lore raw

PATCH 1/1 slub: use N_NORMAL_MEMORY in can_free_to_pcs to handle remote frees

Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it.

As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path.

---

Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled. I wonder if Andrew might put them in the same tree.

[1] https://lore.kernel.org/linux-mm/[email protected]/

---
 mm/slub.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/slub.c +3 -2
index fb2c5c57bc4e..4927407c9699 100644
@@ -6022,14 +6022,15 @@ static __always_inline bool can_free_to_pcs(struct slab *slab)
 		goto check_pfmemalloc;
 
 	/*
-	 * Freed object isn't from this cpu's node, but that node is memoryless.
+	 * Freed object isn't from this cpu's node, but that node is memoryless
+	 * or only has ZONE_MOVABLE memory, which slab cannot allocate from.
 	 * Proceed as it's better to cache remote objects than falling back to
 	 * the slowpath for everything. The allocation side can never obtain
 	 * a local object anyway, if none exist. We don't have numa_mem_id() to
 	 * point to the closest node as we would on a proper memoryless node
 	 * setup.
 	 */
-	if (unlikely(!node_state(numa_node, N_MEMORY)))
+	if (unlikely(!node_state(numa_node, N_NORMAL_MEMORY)))
 		goto check_pfmemalloc;
 #endif
 
Signature · 1 line
2.50.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Hao Li

Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it.

As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path.

---

Quoted 4 lines

Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled.

I wonder if Andrew might put them in the same tree.

But it also depends on the patch series
"[PATCH 0/3] slab: support memoryless nodes with sheaves".

So perhaps better send it to Linus after 7.1-rc1?

Thanks!

Quoted 1 line

[1] https://lore.kernel.org/linux-mm/[email protected]/

Signature · 2 lines
Cheers,
Harry / Hyeonggon
#2 lore raw
In reply to Harry Yoo (Oracle)
Quoted 16 lines · Harry Yoo (Oracle)
Quoted 9 lines · Hao Li

Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it.

As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path.

---

Quoted 2 lines

Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled.

Quoted 6 lines
Quoted 1 line

I wonder if Andrew might put them in the same tree.

But it also depends on the patch series
"[PATCH 0/3] slab: support memoryless nodes with sheaves".

So perhaps better send it to Linus after 7.1-rc1?

[1] is in mm-hotfixes so it should get to mainline before 7.0 final, so then it's fine to add this to slab updates PR for 7.1-rc1

Quoted 4 lines

Thanks!

Quoted 1 line

[1] https://lore.kernel.org/linux-mm/[email protected]/

author reviewer
#3 lore raw
Quoted 5 lines · Vlastimil Babka (SUSE)
Quoted 4 lines · Harry Yoo (Oracle)
Quoted 3 lines · Hao Li

Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path.

---

Thanks for Ack!

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled.

I wonder if Andrew might put them in the same tree.

Quoted 7 lines
Quoted 4 lines

But it also depends on the patch series
"[PATCH 0/3] slab: support memoryless nodes with sheaves".

So perhaps better send it to Linus after 7.1-rc1?

[1] is in mm-hotfixes so it should get to mainline before 7.0 final, so then it's fine to add this to slab updates PR for 7.1-rc1

Sounds good, thanks!

Quoted 6 lines
Quoted 5 lines

Thanks!

Quoted 1 line

[1] https://lore.kernel.org/linux-mm/[email protected]/

Signature · 2 lines
Thanks,
Hao
#4 lore raw
In reply to Vlastimil Babka (SUSE)
Quoted 17 lines · Vlastimil Babka (SUSE)
Quoted 16 lines · Harry Yoo (Oracle)
Quoted 9 lines · Hao Li

Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it.

As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path.

---

Quoted 2 lines

Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I wonder if Andrew might put them in the same tree.

But it also depends on the patch series
"[PATCH 0/3] slab: support memoryless nodes with sheaves".

So perhaps better send it to Linus after 7.1-rc1?

[1] is in mm-hotfixes so it should get to mainline before 7.0 final,

Right.

Quoted 1 line

so then it's fine to add this to slab updates PR for 7.1-rc1

Sounds great!

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

[1] https://lore.kernel.org/linux-mm/[email protected]/

Signature · 2 lines
Cheers,
Harry / Hyeonggon