]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm,page_ext: derive the node from the pfn
authorOscar Salvador <osalvador@suse.de>
Mon, 16 Jun 2025 13:51:53 +0000 (15:51 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:16 +0000 (16:38 -0700)
page_ext is the only user of 'status_change_nid', which is set in
online/offline operations, to know to which node we are adding/removing
memory.

Prior to call any notifiers, the memmap is initialized via, which among
other things, sets the node the pages belong to, to all corresponging
pages.  This means that there is no need to keep using 'status_change_nid'
since we can derive the node from the pfn.  This will allow us to finally
drop 'status_change_nid' from the memory_notify struct.

Link: https://lkml.kernel.org/r/20250616135158.450136-11-osalvador@suse.de
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Suggested-by: David Hildenbrand <david@redhat.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: Joanthan Cameron <Jonathan.Cameron@huawei.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_ext.c

index c351fdfe9e9a50dc6293e2c99e1e0c154e2f08d7..d7396a8970e5e3d4174c6cfa3a4d267d14a9cdcc 100644 (file)
@@ -369,25 +369,15 @@ static void __invalidate_page_ext(unsigned long pfn)
 }
 
 static int __meminit online_page_ext(unsigned long start_pfn,
-                               unsigned long nr_pages,
-                               int nid)
+                               unsigned long nr_pages)
 {
+       int nid = pfn_to_nid(start_pfn);
        unsigned long start, end, pfn;
        int fail = 0;
 
        start = SECTION_ALIGN_DOWN(start_pfn);
        end = SECTION_ALIGN_UP(start_pfn + nr_pages);
 
-       if (nid == NUMA_NO_NODE) {
-               /*
-                * In this case, "nid" already exists and contains valid memory.
-                * "start_pfn" passed to us is a pfn which is an arg for
-                * online__pages(), and start_pfn should exist.
-                */
-               nid = pfn_to_nid(start_pfn);
-               VM_BUG_ON(!node_online(nid));
-       }
-
        for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION)
                fail = init_section_page_ext(pfn, nid);
        if (!fail)
@@ -435,8 +425,7 @@ static int __meminit page_ext_callback(struct notifier_block *self,
 
        switch (action) {
        case MEM_GOING_ONLINE:
-               ret = online_page_ext(mn->start_pfn,
-                                  mn->nr_pages, mn->status_change_nid);
+               ret = online_page_ext(mn->start_pfn, mn->nr_pages);
                break;
        case MEM_OFFLINE:
                offline_page_ext(mn->start_pfn,