Unverified Commit 480e1a43 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4209 dhugetlb: skip unexpected migration

Merge Pull Request from: @ci-robot 
 
PR sync from: Liu Shixin <liushixin2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/TDESCVUSVJUFTUXYCQLMQOZF7PSOFJUZ/ 
Fix unexpected migration of pages from dynamic hugetlb pool.

Liu Shixin (2):
  dhugetlb: introduce page_belong_to_dynamic_hugetlb() function
  dhugetlb: skip unexpected migration


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I8YWPT 
 
Link:https://gitee.com/openeuler/kernel/pulls/4209

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: default avatarLiu YongQiang <liuyongqiang13@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents acf72db5 596500bd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -745,6 +745,7 @@ void move_pages_from_smpool_to_hpool(struct dhugetlb_pool *hpool,
				     struct small_page_pool *smpool);
void dhugetlb_reserve_hugepages(struct dhugetlb_pool *hpool,
				unsigned long count, bool gigantic);
bool page_belong_to_dynamic_hugetlb(struct page *page);
#else
#define enable_dhugetlb		0
#define dhugetlb_enabled	0
@@ -760,6 +761,10 @@ static inline struct dhugetlb_pool *get_dhugetlb_pool_from_dhugetlb_pagelist(
	return NULL;
}
static inline void dhugetlb_pool_put(struct dhugetlb_pool *hpool) { return; }
static inline bool page_belong_to_dynamic_hugetlb(struct page *page)
{
	return false;
}
#endif /* CONFIG_DYNAMIC_HUGETLB */

static inline spinlock_t *huge_pte_lock(struct hstate *h,
+5 −1
Original line number Diff line number Diff line
@@ -38,9 +38,13 @@ static inline struct page *new_page_nodemask(struct page *page,
	unsigned int order = 0;
	struct page *new_page = NULL;

	if (PageHuge(page))
	if (PageHuge(page)) {
		if (page_belong_to_dynamic_hugetlb(page))
			return NULL;

		return alloc_huge_page_nodemask(page_hstate(compound_head(page)),
				preferred_nid, nodemask);
	}

	if (PageTransHuge(page)) {
		gfp_mask |= GFP_TRANSHUGE;
+3 −0
Original line number Diff line number Diff line
@@ -1271,6 +1271,9 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
		if (!page)
			continue;

		if (page_belong_to_dynamic_hugetlb(page))
			continue;

		/* If isolation recently failed, do not retry */
		if (!isolation_suitable(cc, page))
			continue;
+11 −5
Original line number Diff line number Diff line
@@ -1762,7 +1762,6 @@ static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed,
int dissolve_free_huge_page(struct page *page)
{
	int rc = -EBUSY;
	struct dhugetlb_pool *hpool;

retry:
	/* Not to disrupt normal path by vainly holding hugetlb_lock */
@@ -1770,11 +1769,8 @@ int dissolve_free_huge_page(struct page *page)
		return 0;

	/* Skip dissolve hugepage for dynamic hugetlb */
	hpool = get_dhugetlb_pool_from_dhugetlb_pagelist(page);
	if (hpool) {
		dhugetlb_pool_put(hpool);
	if (page_belong_to_dynamic_hugetlb(page))
		return -EBUSY;
	}

	spin_lock(&hugetlb_lock);
	if (!PageHuge(page)) {
@@ -4210,6 +4206,16 @@ static int dhugetlb_acct_memory(struct hstate *h, long delta,

	return ret;
}

bool page_belong_to_dynamic_hugetlb(struct page *page)
{
	struct dhugetlb_pool *hpool;

	hpool = get_dhugetlb_pool_from_dhugetlb_pagelist(page);
	dhugetlb_pool_put(hpool);

	return !!hpool;
}
#else
static int dhugetlb_acct_memory(struct hstate *h, long delta,
				struct dhugetlb_pool *hpool)
+8 −2
Original line number Diff line number Diff line
@@ -1040,10 +1040,13 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist,
/* page allocation callback for NUMA node migration */
struct page *alloc_new_node_page(struct page *page, unsigned long node)
{
	if (PageHuge(page))
	if (PageHuge(page)) {
		if (page_belong_to_dynamic_hugetlb(page))
			return NULL;

		return alloc_huge_page_node(page_hstate(compound_head(page)),
					node);
	else if (PageTransHuge(page)) {
	} else if (PageTransHuge(page)) {
		struct page *thp;

		thp = alloc_pages_node(node,
@@ -1217,6 +1220,9 @@ static struct page *new_page(struct page *page, unsigned long start)
	}

	if (PageHuge(page)) {
		if (page_belong_to_dynamic_hugetlb(page))
			return NULL;

		return alloc_huge_page_vma(page_hstate(compound_head(page)),
				vma, address);
	} else if (PageTransHuge(page)) {
Loading