Unverified Commit 6eb8fb4a authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1245 hugetlb: Fix some incorrect behavior

Merge Pull Request from: @ci-robot 
 
PR sync from: Liu Shixin <liushixin2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/NL3WSSDH4CG2P2J6NDYTGUIS3A4PSEFY/ 
Fix two bugfix of hugetlb:
1) Invalid use of nr_online_nodes;
2) Inconsistency between 1G hugepage and 2M hugepage.

Peng Liu (2):
  hugetlb: fix wrong use of nr_online_nodes
  hugetlb: fix hugepages_setup when deal with pernode


-- 
2.25.1
 
 
Link:https://gitee.com/openeuler/kernel/pulls/1245

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents c3fc37ec 3aa26c25
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -2727,9 +2727,6 @@ int __alloc_bootmem_huge_page(struct hstate *h, int nid)
	struct huge_bootmem_page *m = NULL; /* initialize for clang */
	int nr_nodes, node;

	if (nid != NUMA_NO_NODE && nid >= nr_online_nodes)
		return 0;

	if (!huge_page_limit_check(HUGE_PAGE_BOOTMEM_ALLOC, huge_page_size(h), nid))
		return 0;

@@ -2840,7 +2837,7 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
	}

	/* do node specific alloc */
	for (i = 0; i < nr_online_nodes; i++) {
	for_each_online_node(i) {
		if (h->max_huge_pages_node[i] > 0) {
			hugetlb_hstate_alloc_pages_onenode(h, i);
			node_specific_alloc = true;
@@ -3577,7 +3574,7 @@ static int __init hugetlb_init(void)
			default_hstate.max_huge_pages =
				default_hstate_max_huge_pages;

			for (i = 0; i < nr_online_nodes; i++)
			for_each_online_node(i)
				default_hstate.max_huge_pages_node[i] =
					default_hugepages_in_node[i];
		}
@@ -3648,6 +3645,20 @@ bool __init __weak hugetlb_node_alloc_supported(void)
{
	return true;
}

static void __init hugepages_clear_pages_in_node(void)
{
	if (!hugetlb_max_hstate) {
		default_hstate_max_huge_pages = 0;
		memset(default_hugepages_in_node, 0,
			MAX_NUMNODES * sizeof(unsigned int));
	} else {
		parsed_hstate->max_huge_pages = 0;
		memset(parsed_hstate->max_huge_pages_node, 0,
			MAX_NUMNODES * sizeof(unsigned int));
	}
}

/*
 * hugepages command line processing
 * hugepages normally follows a valid hugepagsz or default_hugepagsz
@@ -3696,7 +3707,7 @@ static int __init hugepages_setup(char *s)
				pr_warn("HugeTLB: architecture can't support node specific alloc, ignoring!\n");
				return 0;
			}
			if (tmp >= nr_online_nodes)
			if (tmp >= MAX_NUMNODES || !node_online(tmp))
				goto invalid;
			node = tmp;
			p += count + 1;
@@ -3735,6 +3746,7 @@ static int __init hugepages_setup(char *s)

invalid:
	pr_warn("HugeTLB: Invalid hugepages parameter %s\n", p);
	hugepages_clear_pages_in_node();
	return 0;
}
__setup("hugepages=", hugepages_setup);
@@ -3826,7 +3838,7 @@ static int __init default_hugepagesz_setup(char *s)
	 */
	if (default_hstate_max_huge_pages) {
		default_hstate.max_huge_pages = default_hstate_max_huge_pages;
		for (i = 0; i < nr_online_nodes; i++)
		for_each_online_node(i)
			default_hstate.max_huge_pages_node[i] =
				default_hugepages_in_node[i];
		if (hstate_is_gigantic(&default_hstate))