rk30 pm.c: fix ctr bits parameter to support help inf,add arm\logic suspend volt...
[firefly-linux-kernel-4.4.55.git] / mm / memory_hotplug.c
index 02159c755136ea0463f57a2a951f9cad223aceb1..e0a3e51d5191578e60b33a17cda90e677afcbdbf 100644 (file)
@@ -116,9 +116,6 @@ static void register_page_bootmem_info_section(unsigned long start_pfn)
        struct mem_section *ms;
        struct page *page, *memmap;
 
-       if (!pfn_valid(start_pfn))
-               return;
-
        section_nr = pfn_to_section_nr(start_pfn);
        ms = __nr_to_section(section_nr);
 
@@ -177,9 +174,16 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat)
        end_pfn = pfn + pgdat->node_spanned_pages;
 
        /* register_section info */
-       for (; pfn < end_pfn; pfn += PAGES_PER_SECTION)
-               register_page_bootmem_info_section(pfn);
-
+       for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
+               /*
+                * Some platforms can assign the same pfn to multiple nodes - on
+                * node0 as well as nodeN.  To avoid registering a pfn against
+                * multiple nodes we check that this pfn does not already
+                * reside in some other node.
+                */
+               if (pfn_valid(pfn) && (pfn_to_nid(pfn) == node))
+                       register_page_bootmem_info_section(pfn);
+       }
 }
 #endif /* !CONFIG_SPARSEMEM_VMEMMAP */
 
@@ -498,7 +502,9 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
         * The node we allocated has no zone fallback lists. For avoiding
         * to access not-initialized zonelist, build here.
         */
+       mutex_lock(&zonelists_mutex);
        build_all_zonelists(NULL);
+       mutex_unlock(&zonelists_mutex);
 
        return pgdat;
 }
@@ -521,7 +527,7 @@ int mem_online_node(int nid)
 
        lock_memory_hotplug();
        pgdat = hotadd_new_pgdat(nid, 0);
-       if (pgdat) {
+       if (!pgdat) {
                ret = -ENOMEM;
                goto out;
        }
@@ -745,7 +751,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
                }
                /* this function returns # of failed pages */
                ret = migrate_pages(&source, hotremove_migrate_alloc, 0,
-                                                               true, true);
+                                                       true, MIGRATE_SYNC);
                if (ret)
                        putback_lru_pages(&source);
        }