[PATCH v5 05/10] mm,memory-tiers: Use node-notifier instead of memory-notifier

Oscar Salvador posted 10 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH v5 05/10] mm,memory-tiers: Use node-notifier instead of memory-notifier
Posted by Oscar Salvador 6 months, 2 weeks ago
memory-tier is only concerned when a numa node changes its memory state,
because it then needs to re-create the demotion list.
So stop using the memory notifier and use the new numa node notifer
instead.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
---
 mm/memory-tiers.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
index fc14fe53e9b7..67f06e6264a1 100644
--- a/mm/memory-tiers.c
+++ b/mm/memory-tiers.c
@@ -872,25 +872,25 @@ static int __meminit memtier_hotplug_callback(struct notifier_block *self,
 					      unsigned long action, void *_arg)
 {
 	struct memory_tier *memtier;
-	struct memory_notify *arg = _arg;
+	struct node_notify *narg = _arg;
 
 	/*
 	 * Only update the node migration order when a node is
 	 * changing status, like online->offline.
 	 */
-	if (arg->status_change_nid < 0)
+	if (narg->nid < 0)
 		return notifier_from_errno(0);
 
 	switch (action) {
-	case MEM_OFFLINE:
+	case NODE_REMOVED_LAST_MEMORY:
 		mutex_lock(&memory_tier_lock);
-		if (clear_node_memory_tier(arg->status_change_nid))
+		if (clear_node_memory_tier(narg->nid))
 			establish_demotion_targets();
 		mutex_unlock(&memory_tier_lock);
 		break;
-	case MEM_ONLINE:
+	case NODE_ADDED_FIRST_MEMORY:
 		mutex_lock(&memory_tier_lock);
-		memtier = set_node_memory_tier(arg->status_change_nid);
+		memtier = set_node_memory_tier(narg->nid);
 		if (!IS_ERR(memtier))
 			establish_demotion_targets();
 		mutex_unlock(&memory_tier_lock);
@@ -929,7 +929,7 @@ static int __init memory_tier_init(void)
 	nodes_and(default_dram_nodes, node_states[N_MEMORY],
 		  node_states[N_CPU]);
 
-	hotplug_memory_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI);
+	hotplug_node_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI);
 	return 0;
 }
 subsys_initcall(memory_tier_init);
-- 
2.49.0
Re: [PATCH v5 05/10] mm,memory-tiers: Use node-notifier instead of memory-notifier
Posted by David Hildenbrand 6 months, 2 weeks ago
On 05.06.25 16:22, Oscar Salvador wrote:
> memory-tier is only concerned when a numa node changes its memory state,
> because it then needs to re-create the demotion list.
> So stop using the memory notifier and use the new numa node notifer
> instead.
> 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
> Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>   mm/memory-tiers.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
> index fc14fe53e9b7..67f06e6264a1 100644
> --- a/mm/memory-tiers.c
> +++ b/mm/memory-tiers.c
> @@ -872,25 +872,25 @@ static int __meminit memtier_hotplug_callback(struct notifier_block *self,
>   					      unsigned long action, void *_arg)
>   {
>   	struct memory_tier *memtier;
> -	struct memory_notify *arg = _arg;
> +	struct node_notify *narg = _arg;
>   
>   	/*
>   	 * Only update the node migration order when a node is
>   	 * changing status, like online->offline.
>   	 */
> -	if (arg->status_change_nid < 0)
> +	if (narg->nid < 0)
>   		return notifier_from_errno(0);

Ehm, why are we ever calling a node notifier with nid < 0 ?

We shouldn't do that.

Can be adding first / removing last from something that ... is not a 
valid node? :)

Maybe it's already do that way, in that case just drop this check here.

-- 
Cheers,

David / dhildenb