mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 14:14:01 +08:00
a21558618c
The case of a new numa node got missed in avoiding using the node info
from page_struct during hotplug. In this path we have a call to
register_mem_sect_under_node (which allows us to specify it is hotplug
so don't change the node), via link_mem_sections which unfortunately
does not.
Fix is to pass check_nid through link_mem_sections as well and disable
it in the new numa node path.
Note the bug only 'sometimes' manifests depending on what happens to be
in the struct page structures - there are lots of them and it only needs
to match one of them.
The result of the bug is that (with a new memory only node) we never
successfully call register_mem_sect_under_node so don't get the memory
associated with the node in sysfs and meminfo for the node doesn't
report it.
It came up whilst testing some arm64 hotplug patches, but appears to be
universal. Whilst I'm triggering it by removing then reinserting memory
to a node with no other elements (thus making the node disappear then
appear again), it appears it would happen on hotplugging memory where
there was none before and it doesn't seem to be related the arm64
patches.
These patches call __add_pages (where most of the issue was fixed by
Pavel's patch). If there is a node at the time of the __add_pages call
then all is well as it calls register_mem_sect_under_node from there
with check_nid set to false. Without a node that function returns
having not done the sysfs related stuff as there is no node to use.
This is expected but it is the resulting path that fails...
Exact path to the problem is as follows:
mm/memory_hotplug.c: add_memory_resource()
The node is not online so we enter the 'if (new_node)' twice, on the
second such block there is a call to link_mem_sections which calls
into
drivers/node.c: link_mem_sections() which calls
drivers/node.c: register_mem_sect_under_node() which calls
get_nid_for_pfn and keeps trying until the output of that matches
the expected node (passed all the way down from
add_memory_resource)
It is effectively the same fix as the one referred to in the fixes tag
just in the code path for a new node where the comments point out we
have to rerun the link creation because it will have failed in
register_new_memory (as there was no node at the time). (actually that
comment is wrong now as we don't have register_new_memory any more it
got renamed to hotplug_memory_register in Pavel's patch).
Link: http://lkml.kernel.org/r/20180504085311.1240-1-Jonathan.Cameron@huawei.com
Fixes: fc44f7f923
("mm/memory_hotplug: don't read nid from struct page during hotplug")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
121 lines
3.1 KiB
C
121 lines
3.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* include/linux/node.h - generic node definition
|
|
*
|
|
* This is mainly for topological representation. We define the
|
|
* basic 'struct node' here, which can be embedded in per-arch
|
|
* definitions of processors.
|
|
*
|
|
* Basic handling of the devices is done in drivers/base/node.c
|
|
* and system devices are handled in drivers/base/sys.c.
|
|
*
|
|
* Nodes are exported via driverfs in the class/node/devices/
|
|
* directory.
|
|
*/
|
|
#ifndef _LINUX_NODE_H_
|
|
#define _LINUX_NODE_H_
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
struct node {
|
|
struct device dev;
|
|
|
|
#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
|
|
struct work_struct node_work;
|
|
#endif
|
|
};
|
|
|
|
struct memory_block;
|
|
extern struct node *node_devices[];
|
|
typedef void (*node_registration_func_t)(struct node *);
|
|
|
|
#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_NUMA)
|
|
extern int link_mem_sections(int nid, unsigned long start_pfn,
|
|
unsigned long nr_pages, bool check_nid);
|
|
#else
|
|
static inline int link_mem_sections(int nid, unsigned long start_pfn,
|
|
unsigned long nr_pages, bool check_nid)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
extern void unregister_node(struct node *node);
|
|
#ifdef CONFIG_NUMA
|
|
/* Core of the node registration - only memory hotplug should use this */
|
|
extern int __register_one_node(int nid);
|
|
|
|
/* Registers an online node */
|
|
static inline int register_one_node(int nid)
|
|
{
|
|
int error = 0;
|
|
|
|
if (node_online(nid)) {
|
|
struct pglist_data *pgdat = NODE_DATA(nid);
|
|
|
|
error = __register_one_node(nid);
|
|
if (error)
|
|
return error;
|
|
/* link memory sections under this node */
|
|
error = link_mem_sections(nid, pgdat->node_start_pfn, pgdat->node_spanned_pages, true);
|
|
}
|
|
|
|
return error;
|
|
}
|
|
|
|
extern void unregister_one_node(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 register_mem_sect_under_node(struct memory_block *mem_blk,
|
|
int nid, bool check_nid);
|
|
extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
|
unsigned long phys_index);
|
|
|
|
#ifdef CONFIG_HUGETLBFS
|
|
extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
|
|
node_registration_func_t unregister);
|
|
#endif
|
|
#else
|
|
static inline int __register_one_node(int nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int register_one_node(int nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int unregister_one_node(int nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int register_cpu_under_node(unsigned int cpu, unsigned int nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
|
|
int nid, bool check_nid)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
|
unsigned long phys_index)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
|
|
node_registration_func_t unreg)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#define to_node(device) container_of(device, struct node, dev)
|
|
|
|
#endif /* _LINUX_NODE_H_ */
|