Commit cf082a0e authored by Liu Shixin's avatar Liu Shixin
Browse files

mm/dynamic_pool: compatible with HugeTLB Vmemmap

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: default avatarLiu Shixin <liushixin2@huawei.com>
parent 93b77bfa
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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>
@@ -1230,6 +1231,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);
@@ -1266,6 +1276,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);
+4 −0
Original line number Diff line number Diff line
@@ -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;