From: Liu Shixin liushixin2@huawei.com
hulk inclusion category: feature bugzilla: 46904, https://gitee.com/openeuler/kernel/issues/I6BDME CVE: NA
--------------------------------
For now, we only support 1G and 2M hugepage on arm64 with 4K pages. So restrict the config depends on ARM64_4K_PAGES and only setting hpool for 1G and 2M hugepage.
Signed-off-by: Liu Shixin liushixin2@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- fs/Kconfig | 1 + fs/hugetlbfs/inode.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/Kconfig b/fs/Kconfig index e8800d8a73b3..2265e95cf17e 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -216,6 +216,7 @@ config DYNAMIC_HUGETLB depends on HUGETLB_PAGE depends on MEMCG depends on CGROUP_HUGETLB + depends on X86_64 || (ARM64 && ARM64_4K_PAGES) help Dynamic hugepage are used in memcg and can be splited into small pages automatically. The tasks in the memcg prefer to alloc dynamic hugepage. diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index e411103d2cf4..5fcd3586c81f 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1166,7 +1166,9 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) mpol_shared_policy_init(&p->policy, NULL); #ifdef CONFIG_DYNAMIC_HUGETLB /* Initialize hpool here in case of a quick call to destroy */ - p->hpool = get_dhugetlb_pool_from_task(current); + if (huge_page_size(sbinfo->hstate) == PMD_SIZE || + huge_page_size(sbinfo->hstate) == PUD_SIZE) + p->hpool = get_dhugetlb_pool_from_task(current); #endif
return &p->vfs_inode;