From 925b5be0fba715b0ea54bfb3af4c8170a1a34c19 Mon Sep 17 00:00:00 2001 From: Zhou Guanghui Date: Sat, 30 Oct 2021 11:09:41 +0800 Subject: [PATCH] shmem/ascend: charge pages to the memcg of current task ascend inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI CVE: NA ------------------------------------------------------- In the share pool scenario, when the shared memory is applied for, the do_mm_populate function is performed at the same time, that is, the corresponding pages are allocated. In the current share pool implementation, the memory is charged to the memcg of the first task added to this share pool group. This is unreasonable and may cause memcg of first task oom. So, we should charge the pages to the memcg of current task. Signed-off-by: Zhou Guanghui Reviewed-by: Weilong Chen Signed-off-by: Yang Yingliang --- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 54c5cc0610e6..90e75a0fa5bc 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -36,6 +36,7 @@ #include #include #include +#include #include /* for arch/microblaze update_mmu_cache() */ @@ -1769,7 +1770,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, * bring it back from swap or allocate. */ sbinfo = SHMEM_SB(inode->i_sb); - charge_mm = vma ? vma->vm_mm : current->mm; + charge_mm = vma && !sp_check_vm_share_pool(vma->vm_flags) ? + vma->vm_mm : current->mm; if (swap.val) { /* Look it up and read it in.. */ -- GitLab