Unverified Commit 7799a03c authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2798 handle uninitialized numa nodes gracefully.

Merge Pull Request from: @ci-robot 
 
PR sync from: Wupeng Ma <mawupeng1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/BNWWDNCSUKNCM7WJ6LSGQIJ5R2I5VN27/ 
From: Ma Wupeng <mawupeng1@huawei.com>

handle uninitialized numa nodes gracefully.

Haifeng Xu (1):
  mm/memcontrol: do not tweak node in mem_cgroup_init()

Michal Hocko (5):
  mm, memory_hotplug: make arch_alloc_nodedata independent on
    CONFIG_MEMORY_HOTPLUG
  mm: handle uninitialized numa nodes gracefully
  mm, memory_hotplug: drop arch_free_nodedata
  mm, memory_hotplug: reorganize new pgdat initialization
  mm: make free_area_init_node aware of memory less nodes

Oscar Salvador (1):
  arch/x86/mm/numa: Do not initialize nodes twice

Srikar Dronamraju (1):
  powerpc/numa: Handle partially initialized numa nodes

Wei Yang (1):
  memcg: do not tweak node in alloc_mem_cgroup_per_node_info


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I8EQ3K 
 
Link:https://gitee.com/openeuler/kernel/pulls/2798

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents b8d20195 9f69f75d
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -630,17 +630,11 @@ void __init paging_init(void)
	zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
}

#ifdef CONFIG_MEMORY_HOTPLUG
pg_data_t *arch_alloc_nodedata(int nid)
pg_data_t * __init arch_alloc_nodedata(int nid)
{
	unsigned long size = compute_pernodesize(nid);

	return kzalloc(size, GFP_KERNEL);
}

void arch_free_nodedata(pg_data_t *pgdat)
{
	kfree(pgdat);
	return memblock_alloc(size, SMP_CACHE_BYTES);
}

void arch_refresh_nodedata(int update_node, pg_data_t *update_pgdat)
@@ -648,7 +642,6 @@ void arch_refresh_nodedata(int update_node, pg_data_t *update_pgdat)
	pgdat_list[update_node] = update_pgdat;
	scatter_node_data();
}
#endif

#ifdef CONFIG_SPARSEMEM_VMEMMAP
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
+1 −1
Original line number Diff line number Diff line
@@ -1452,7 +1452,7 @@ int find_and_online_cpu_nid(int cpu)
	if (new_nid < 0 || !node_possible(new_nid))
		new_nid = first_online_node;

	if (NODE_DATA(new_nid) == NULL) {
	if (!node_online(new_nid)) {
#ifdef CONFIG_MEMORY_HOTPLUG
		/*
		 * Need to ensure that NODE_DATA is initialized for a node from
+20 −13
Original line number Diff line number Diff line
@@ -739,17 +739,6 @@ void __init x86_numa_init(void)
	numa_init(dummy_numa_init);
}

static void __init init_memory_less_node(int nid)
{
	/* Allocate and initialize node data. Memory-less node is now online.*/
	alloc_node_data(nid);
	free_area_init_memoryless_node(nid);

	/*
	 * All zonelists will be built later in start_kernel() after per cpu
	 * areas are initialized.
	 */
}

/*
 * A node may exist which has one or more Generic Initiators but no CPUs and no
@@ -767,9 +756,18 @@ void __init init_gi_nodes(void)
{
	int nid;

	/*
	 * Exclude this node from
	 * bringup_nonboot_cpus
	 *  cpu_up
	 *   __try_online_node
	 *    register_one_node
	 * because node_subsys is not initialized yet.
	 * TODO remove dependency on node_online
	 */
	for_each_node_state(nid, N_GENERIC_INITIATOR)
		if (!node_online(nid))
			init_memory_less_node(nid);
			node_set_online(nid);
}

/*
@@ -799,8 +797,17 @@ void __init init_cpu_to_node(void)
		if (node == NUMA_NO_NODE)
			continue;

		/*
		 * Exclude this node from
		 * bringup_nonboot_cpus
		 *  cpu_up
		 *   __try_online_node
		 *    register_one_node
		 * because node_subsys is not initialized yet.
		 * TODO remove dependency on node_online
		 */
		if (!node_online(node))
			init_memory_less_node(node);
			node_set_online(node);

		numa_set_node(cpu, node);
	}
+57 −61
Original line number Diff line number Diff line
@@ -15,6 +15,62 @@ struct memory_block;
struct resource;
struct vmem_altmap;

#ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION
/*
 * For supporting node-hotadd, we have to allocate a new pgdat.
 *
 * If an arch has generic style NODE_DATA(),
 * node_data[nid] = kzalloc() works well. But it depends on the architecture.
 *
 * In general, generic_alloc_nodedata() is used.
 *
 */
extern pg_data_t *arch_alloc_nodedata(int nid);
extern void arch_refresh_nodedata(int nid, pg_data_t *pgdat);

#else /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */

#define arch_alloc_nodedata(nid)	generic_alloc_nodedata(nid)

#ifdef CONFIG_NUMA
/*
 * XXX: node aware allocation can't work well to get new node's memory at this time.
 *	Because, pgdat for the new node is not allocated/initialized yet itself.
 *	To use new node's memory, more consideration will be necessary.
 */
#define generic_alloc_nodedata(nid)				\
({								\
	memblock_alloc(sizeof(*pgdat), SMP_CACHE_BYTES);	\
})
/*
 * This definition is just for error path in node hotadd.
 * For node hotremove, we have to replace this.
 */
#define generic_free_nodedata(pgdat)	kfree(pgdat)

extern pg_data_t *node_data[];
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
{
	node_data[nid] = pgdat;
}

#else /* !CONFIG_NUMA */

/* never called */
static inline pg_data_t *generic_alloc_nodedata(int nid)
{
	BUG();
	return NULL;
}
static inline void generic_free_nodedata(pg_data_t *pgdat)
{
}
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
{
}
#endif /* CONFIG_NUMA */
#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */

#ifdef CONFIG_MEMORY_HOTPLUG
/*
 * Return page for the valid pfn only if the page is online. All pfn
@@ -150,66 +206,6 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
	      struct mhp_params *params);
#endif /* ARCH_HAS_ADD_PAGES */

#ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION
/*
 * For supporting node-hotadd, we have to allocate a new pgdat.
 *
 * If an arch has generic style NODE_DATA(),
 * node_data[nid] = kzalloc() works well. But it depends on the architecture.
 *
 * In general, generic_alloc_nodedata() is used.
 * Now, arch_free_nodedata() is just defined for error path of node_hot_add.
 *
 */
extern pg_data_t *arch_alloc_nodedata(int nid);
extern void arch_free_nodedata(pg_data_t *pgdat);
extern void arch_refresh_nodedata(int nid, pg_data_t *pgdat);

#else /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */

#define arch_alloc_nodedata(nid)	generic_alloc_nodedata(nid)
#define arch_free_nodedata(pgdat)	generic_free_nodedata(pgdat)

#ifdef CONFIG_NUMA
/*
 * If ARCH_HAS_NODEDATA_EXTENSION=n, this func is used to allocate pgdat.
 * XXX: kmalloc_node() can't work well to get new node's memory at this time.
 *	Because, pgdat for the new node is not allocated/initialized yet itself.
 *	To use new node's memory, more consideration will be necessary.
 */
#define generic_alloc_nodedata(nid)				\
({								\
	kzalloc(sizeof(pg_data_t), GFP_KERNEL);			\
})
/*
 * This definition is just for error path in node hotadd.
 * For node hotremove, we have to replace this.
 */
#define generic_free_nodedata(pgdat)	kfree(pgdat)

extern pg_data_t *node_data[];
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
{
	node_data[nid] = pgdat;
}

#else /* !CONFIG_NUMA */

/* never called */
static inline pg_data_t *generic_alloc_nodedata(int nid)
{
	BUG();
	return NULL;
}
static inline void generic_free_nodedata(pg_data_t *pgdat)
{
}
static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
{
}
#endif /* CONFIG_NUMA */
#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */

void get_online_mems(void);
void put_online_mems(void);

@@ -318,7 +314,7 @@ extern void clear_zone_contiguous(struct zone *zone);
#ifdef CONFIG_MEMORY_HOTPLUG
extern struct acpi_device *hotplug_mdev[MAX_NUMNODES];

extern void __ref free_area_init_core_hotplug(int nid);
extern void __ref free_area_init_core_hotplug(struct pglist_data *pgdat);
extern int __add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags);
extern int add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags);
extern int add_memory_resource(int nid, struct resource *resource,
+0 −1
Original line number Diff line number Diff line
@@ -2402,7 +2402,6 @@ static inline spinlock_t *pud_lock(struct mm_struct *mm, pud_t *pud)
}

extern void __init pagecache_init(void);
extern void __init free_area_init_memoryless_node(int nid);
extern void free_initmem(void);

/*
Loading