hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8S9BY CVE: NA
--------------------------------
Disable hugetlb vmemmep optimization for HugeTLB pages in dpool.
Signed-off-by: Liu Shixin liushixin2@huawei.com --- mm/dynamic_pool.c | 11 +++++++++++ mm/hugetlb_vmemmap.c | 4 ++++ 2 files changed, 15 insertions(+)
diff --git a/mm/dynamic_pool.c b/mm/dynamic_pool.c index fccb10bfd278..88cb3333ba9f 100644 --- a/mm/dynamic_pool.c +++ b/mm/dynamic_pool.c @@ -10,6 +10,7 @@ #include <linux/memblock.h> #include <linux/dynamic_pool.h> #include "internal.h" +#include "hugetlb_vmemmap.h"
#define CREATE_TRACE_POINTS #include <trace/events/dynamic_pool.h> @@ -1222,6 +1223,15 @@ static int dpool_fill_from_hugetlb(struct dynamic_pool *dpool, void *arg) spin_unlock(&hugetlb_lock);
list_for_each_entry_safe(page, next, &page_list, lru) { + if (hugetlb_vmemmap_restore(h, page)) { + spin_lock(&hugetlb_lock); + enqueue_hugetlb_folio(h, folio); + spin_unlock(&hugetlb_lock); + pr_err("restore hugetlb_vmemmap failed page 0x%px\n", + page); + continue; + } + __SetPageDpool(page); spin_lock(&dpool->lock); list_move(&page->lru, &pool->freelist); @@ -1258,6 +1268,7 @@ static int dpool_drain_to_hugetlb(struct dynamic_pool *dpool) spin_unlock(&dpool->lock);
list_for_each_entry_safe(page, next, &page_list, lru) { + hugetlb_vmemmap_optimize(h, page); spin_lock(&hugetlb_lock); enqueue_hugetlb_folio(h, page_folio(page)); spin_unlock(&hugetlb_lock); diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index b5a8587a0bad..90aee2cd3dab 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -13,6 +13,7 @@ #include <linux/pgtable.h> #include <linux/moduleparam.h> #include <linux/bootmem_info.h> +#include <linux/dynamic_pool.h> #include <asm/pgalloc.h> #include <asm/tlbflush.h> #include "hugetlb_vmemmap.h" @@ -488,6 +489,9 @@ static bool vmemmap_should_optimize(const struct hstate *h, const struct page *h if (!hugetlb_vmemmap_optimizable(h)) return false;
+ if (page_in_dynamic_pool((struct page *)head)) + return false; + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) { pmd_t *pmdp, pmd; struct page *vmemmap_page;