]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm,slub: use node-notifier instead of memory-notifier
authorOscar Salvador <osalvador@suse.de>
Mon, 16 Jun 2025 13:51:47 +0000 (15:51 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:15 +0000 (16:38 -0700)
slub is only concerned when a numa node changes its memory state, so stop
using the memory notifier and use the new numa node notifer instead.

[akpm@linux-foundation.org: slub.c needs node.h for struct node_notify]
Link: https://lore.kernel.org/oe-kbuild-all/202506202144.dGkFxasv-lkp@intel.com/
Link: https://lkml.kernel.org/r/20250616135158.450136-5-osalvador@suse.de
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>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/slub.c

index db3280cc678db61b13fe26472bf06e3bb082e2b8..c4b64821e6805b9e9e3b71c0740451553716a271 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -23,6 +23,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/kasan.h>
+#include <linux/node.h>
 #include <linux/kmsan.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
@@ -6149,7 +6150,7 @@ int __kmem_cache_shrink(struct kmem_cache *s)
        return __kmem_cache_do_shrink(s);
 }
 
-static int slab_mem_going_offline_callback(void *arg)
+static int slab_mem_going_offline_callback(void)
 {
        struct kmem_cache *s;
 
@@ -6163,21 +6164,12 @@ static int slab_mem_going_offline_callback(void *arg)
        return 0;
 }
 
-static int slab_mem_going_online_callback(void *arg)
+static int slab_mem_going_online_callback(int nid)
 {
        struct kmem_cache_node *n;
        struct kmem_cache *s;
-       struct memory_notify *marg = arg;
-       int nid = marg->status_change_nid;
        int ret = 0;
 
-       /*
-        * If the node's memory is already available, then kmem_cache_node is
-        * already created. Nothing to do.
-        */
-       if (nid < 0)
-               return 0;
-
        /*
         * We are bringing a node online. No memory is available yet. We must
         * allocate a kmem_cache_node structure in order to bring the node
@@ -6217,17 +6209,16 @@ out:
 static int slab_memory_callback(struct notifier_block *self,
                                unsigned long action, void *arg)
 {
+       struct node_notify *nn = arg;
+       int nid = nn->nid;
        int ret = 0;
 
        switch (action) {
-       case MEM_GOING_ONLINE:
-               ret = slab_mem_going_online_callback(arg);
-               break;
-       case MEM_GOING_OFFLINE:
-               ret = slab_mem_going_offline_callback(arg);
+       case NODE_ADDING_FIRST_MEMORY:
+               ret = slab_mem_going_online_callback(nid);
                break;
-       case MEM_ONLINE:
-       case MEM_CANCEL_OFFLINE:
+       case NODE_REMOVING_LAST_MEMORY:
+               ret = slab_mem_going_offline_callback();
                break;
        }
        if (ret)
@@ -6303,7 +6294,7 @@ void __init kmem_cache_init(void)
                        sizeof(struct kmem_cache_node),
                        SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0);
 
-       hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
+       hotplug_node_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
 
        /* Able to allocate the per node structures */
        slab_state = PARTIAL;