summaryrefslogtreecommitdiffstats
path: root/drivers/base/node.c
diff options
context:
space:
mode:
authorPavel Tatashin <pasha.tatashin@oracle.com>2018-04-05 19:22:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-06 00:36:25 -0400
commitfc44f7f9231a73821fc858f5bc48883a9e78f6de (patch)
tree52d633c375d235c3fd059d885981e821f0ee31f4 /drivers/base/node.c
parentb77eab7079d9e477489d2416cceda05d3c1cf21f (diff)
mm/memory_hotplug: don't read nid from struct page during hotplug
During memory hotplugging the probe routine will leave struct pages uninitialized, the same as it is currently done during boot. Therefore, we do not want to access the inside of struct pages before __init_single_page() is called during onlining. Because during hotplug we know that pages in one memory block belong to the same numa node, we can skip the checking. We should keep checking for the boot case. [pasha.tatashin@oracle.com: s/register_new_memory()/hotplug_memory_register()] Link: http://lkml.kernel.org/r/20180228030308.1116-6-pasha.tatashin@oracle.com Link: http://lkml.kernel.org/r/20180215165920.8570-6-pasha.tatashin@oracle.com Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Ingo Molnar <mingo@kernel.org> Cc: Baoquan He <bhe@redhat.com> Cc: Bharata B Rao <bharata@linux.vnet.ibm.com> Cc: Daniel Jordan <daniel.m.jordan@oracle.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Steven Sistare <steven.sistare@oracle.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base/node.c')
-rw-r--r--drivers/base/node.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c
index c5f81fc621ac..92b00a7e6a02 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -399,7 +399,8 @@ static int __ref get_nid_for_pfn(unsigned long pfn)
399} 399}
400 400
401/* register memory section under specified node if it spans that node */ 401/* register memory section under specified node if it spans that node */
402int register_mem_sect_under_node(struct memory_block *mem_blk, int nid) 402int register_mem_sect_under_node(struct memory_block *mem_blk, int nid,
403 bool check_nid)
403{ 404{
404 int ret; 405 int ret;
405 unsigned long pfn, sect_start_pfn, sect_end_pfn; 406 unsigned long pfn, sect_start_pfn, sect_end_pfn;
@@ -425,11 +426,18 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
425 continue; 426 continue;
426 } 427 }
427 428
428 page_nid = get_nid_for_pfn(pfn); 429 /*
429 if (page_nid < 0) 430 * We need to check if page belongs to nid only for the boot
430 continue; 431 * case, during hotplug we know that all pages in the memory
431 if (page_nid != nid) 432 * block belong to the same node.
432 continue; 433 */
434 if (check_nid) {
435 page_nid = get_nid_for_pfn(pfn);
436 if (page_nid < 0)
437 continue;
438 if (page_nid != nid)
439 continue;
440 }
433 ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj, 441 ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
434 &mem_blk->dev.kobj, 442 &mem_blk->dev.kobj,
435 kobject_name(&mem_blk->dev.kobj)); 443 kobject_name(&mem_blk->dev.kobj));
@@ -504,7 +512,7 @@ int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
504 512
505 mem_blk = find_memory_block_hinted(mem_sect, mem_blk); 513 mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
506 514
507 ret = register_mem_sect_under_node(mem_blk, nid); 515 ret = register_mem_sect_under_node(mem_blk, nid, true);
508 if (!err) 516 if (!err)
509 err = ret; 517 err = ret;
510 518