Commit 036ab0bb authored by Liu Shixin's avatar Liu Shixin
Browse files

mm/dynamic_hugetlb: support dynamic hugetlb on arm64

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6XOIE


CVE: NA

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

To support dynamic hugetlb on arm64, we need to do two more things. The
first one is to fix kabi broken in mem_cgroup, we use kabi_reserve_5 to
fix it in previous patch. The second one is to check cont-bit hugetlb
since this feature only support for PMD-size and PUD-size hugepage.

This feature only support for 4KB pagesize, not support for 16KB and 64KB.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent fc47477c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON

config DYNAMIC_HUGETLB
	bool "Dynamic HugeTLB"
	depends on X86_64
	depends on X86_64 || (ARM64 && ARM64_4K_PAGES)
	depends on HUGETLBFS
	depends on MEMCG && CGROUP_HUGETLB
	help
+1 −1
Original line number Diff line number Diff line
@@ -1213,7 +1213,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
	 */
	mpol_shared_policy_init(&p->policy, NULL);
	/* Initialize hpool here in case of a quick call to destroy */
	link_hpool(p);
	link_hpool(p, sbinfo->hstate);

	return &p->vfs_inode;
}
+2 −2
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ bool free_page_to_dhugetlb_pool(struct page *page);
void free_page_list_to_dhugetlb_pool(struct list_head *list);
int task_has_mem_in_hpool(struct task_struct *tsk);

void link_hpool(struct hugetlbfs_inode_info *p);
void link_hpool(struct hugetlbfs_inode_info *p, struct hstate *h);
void unlink_hpool(struct hugetlbfs_inode_info *p);
bool file_has_mem_in_hpool(struct hugetlbfs_inode_info *p);
int dhugetlb_acct_memory(struct hstate *h, long delta, struct hugetlbfs_inode_info *p);
@@ -147,7 +147,7 @@ static inline int task_has_mem_in_hpool(struct task_struct *tsk)
}

#ifdef CONFIG_HUGETLBFS
static inline void link_hpool(struct hugetlbfs_inode_info *p)
static inline void link_hpool(struct hugetlbfs_inode_info *p, struct hstate *h)
{
}
static inline void unlink_hpool(struct hugetlbfs_inode_info *p)
+10 −3
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

#include <linux/rmap.h>
#include <linux/migrate.h>
#include <linux/memblock.h>
#include <linux/memory_hotplug.h>
#include <linux/dynamic_hugetlb.h>

@@ -618,14 +619,20 @@ void free_page_list_to_dhugetlb_pool(struct list_head *list)
	}
}

void link_hpool(struct hugetlbfs_inode_info *p)
void link_hpool(struct hugetlbfs_inode_info *p, struct hstate *h)
{
	unsigned long size;

	if (!dhugetlb_enabled || !p)
		return;

	size = huge_page_size(h);
	if (size == PMD_SIZE || size == PUD_SIZE) {
		p->hpool = find_hpool_by_task(current);
		if (!get_hpool_unless_zero(p->hpool))
			p->hpool = NULL;
	} else
		p->hpool = NULL;
}

void unlink_hpool(struct hugetlbfs_inode_info *p)