Commit 096ad875 authored by Liu Shixin's avatar Liu Shixin
Browse files

dhugetlb: introduce page_belong_to_dynamic_hugetlb() function

hulk inclusion
category: cleanup
bugzilla: https://gitee.com/openeuler/kernel/issues/I8YWPT


CVE: NA

--------------------------------

Use page_belong_to_dynamic_hugetlb() helper to check whether a page is
from dynamic hugetlb pool.

No functional change.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent e0207e27
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,
+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)