mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 22:54:05 +08:00
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>
This commit is contained in:
parent
b77eab7079
commit
fc44f7f923
@ -712,7 +712,7 @@ static int add_memory_block(int base_section_nr)
|
|||||||
* need an interface for the VM to add new memory regions,
|
* need an interface for the VM to add new memory regions,
|
||||||
* but without onlining it.
|
* but without onlining it.
|
||||||
*/
|
*/
|
||||||
int register_new_memory(int nid, struct mem_section *section)
|
int hotplug_memory_register(int nid, struct mem_section *section)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct memory_block *mem;
|
struct memory_block *mem;
|
||||||
@ -731,7 +731,7 @@ int register_new_memory(int nid, struct mem_section *section)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mem->section_count == sections_per_block)
|
if (mem->section_count == sections_per_block)
|
||||||
ret = register_mem_sect_under_node(mem, nid);
|
ret = register_mem_sect_under_node(mem, nid, false);
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&mem_sysfs_mutex);
|
mutex_unlock(&mem_sysfs_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -399,7 +399,8 @@ static int __ref get_nid_for_pfn(unsigned long pfn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* register memory section under specified node if it spans that node */
|
/* register memory section under specified node if it spans that node */
|
||||||
int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
|
int register_mem_sect_under_node(struct memory_block *mem_blk, int nid,
|
||||||
|
bool check_nid)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned long pfn, sect_start_pfn, sect_end_pfn;
|
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)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to check if page belongs to nid only for the boot
|
||||||
|
* case, during hotplug we know that all pages in the memory
|
||||||
|
* block belong to the same node.
|
||||||
|
*/
|
||||||
|
if (check_nid) {
|
||||||
page_nid = get_nid_for_pfn(pfn);
|
page_nid = get_nid_for_pfn(pfn);
|
||||||
if (page_nid < 0)
|
if (page_nid < 0)
|
||||||
continue;
|
continue;
|
||||||
if (page_nid != nid)
|
if (page_nid != nid)
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
|
ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
|
||||||
&mem_blk->dev.kobj,
|
&mem_blk->dev.kobj,
|
||||||
kobject_name(&mem_blk->dev.kobj));
|
kobject_name(&mem_blk->dev.kobj));
|
||||||
@ -504,7 +512,7 @@ int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages)
|
|||||||
|
|
||||||
mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
|
mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
|
||||||
|
|
||||||
ret = register_mem_sect_under_node(mem_blk, nid);
|
ret = register_mem_sect_under_node(mem_blk, nid, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = ret;
|
err = ret;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ extern int register_memory_notifier(struct notifier_block *nb);
|
|||||||
extern void unregister_memory_notifier(struct notifier_block *nb);
|
extern void unregister_memory_notifier(struct notifier_block *nb);
|
||||||
extern int register_memory_isolate_notifier(struct notifier_block *nb);
|
extern int register_memory_isolate_notifier(struct notifier_block *nb);
|
||||||
extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
|
extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
|
||||||
extern int register_new_memory(int, struct mem_section *);
|
int hotplug_memory_register(int nid, struct mem_section *section);
|
||||||
#ifdef CONFIG_MEMORY_HOTREMOVE
|
#ifdef CONFIG_MEMORY_HOTREMOVE
|
||||||
extern int unregister_memory_section(struct mem_section *);
|
extern int unregister_memory_section(struct mem_section *);
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,7 +67,7 @@ extern void unregister_one_node(int nid);
|
|||||||
extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
|
extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
|
||||||
extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
|
extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
|
||||||
extern int register_mem_sect_under_node(struct memory_block *mem_blk,
|
extern int register_mem_sect_under_node(struct memory_block *mem_blk,
|
||||||
int nid);
|
int nid, bool check_nid);
|
||||||
extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
||||||
unsigned long phys_index);
|
unsigned long phys_index);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
|
static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
|
||||||
int nid)
|
int nid, bool check_nid)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
|
|||||||
if (!want_memblock)
|
if (!want_memblock)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return register_new_memory(nid, __pfn_to_section(phys_start_pfn));
|
return hotplug_memory_register(nid, __pfn_to_section(phys_start_pfn));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user