]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/memory_hotplug: clean up try_offline_node
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 22 Mar 2022 21:47:22 +0000 (14:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:10 +0000 (15:57 -0700)
We can use helper macro node_spanned_pages to check whether node spans
pages.  And we can change the parameter of check_cpu_on_node to nid as
that's what it really cares.  Thus we can further get rid of the local
variable pgdat and improve the readability a bit.

Link: https://lkml.kernel.org/r/20220207133643.23427-4-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory_hotplug.c

index 947ba4fc8124caec369531e9355aa76fc0b54d76..bb1893f10f0f46b851c2fb530ec675dc84120c29 100644 (file)
@@ -2005,12 +2005,12 @@ static int get_nr_vmemmap_pages_cb(struct memory_block *mem, void *arg)
        return mem->nr_vmemmap_pages;
 }
 
-static int check_cpu_on_node(pg_data_t *pgdat)
+static int check_cpu_on_node(int nid)
 {
        int cpu;
 
        for_each_present_cpu(cpu) {
-               if (cpu_to_node(cpu) == pgdat->node_id)
+               if (cpu_to_node(cpu) == nid)
                        /*
                         * the cpu on this node isn't removed, and we can't
                         * offline this node.
@@ -2044,7 +2044,6 @@ static int check_no_memblock_for_node_cb(struct memory_block *mem, void *arg)
  */
 void try_offline_node(int nid)
 {
-       pg_data_t *pgdat = NODE_DATA(nid);
        int rc;
 
        /*
@@ -2052,7 +2051,7 @@ void try_offline_node(int nid)
         * offline it. A node spans memory after move_pfn_range_to_zone(),
         * e.g., after the memory block was onlined.
         */
-       if (pgdat->node_spanned_pages)
+       if (node_spanned_pages(nid))
                return;
 
        /*
@@ -2064,7 +2063,7 @@ void try_offline_node(int nid)
        if (rc)
                return;
 
-       if (check_cpu_on_node(pgdat))
+       if (check_cpu_on_node(nid))
                return;
 
        /*