提交 925b5be0 编写于 作者: Z Zhou Guanghui 提交者: Yang Yingliang

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: NZhou Guanghui <zhouguanghui1@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7ef56b57
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/khugepaged.h> #include <linux/khugepaged.h>
#include <linux/hugetlb.h> #include <linux/hugetlb.h>
#include <linux/share_pool.h>
#include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */ #include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
...@@ -1769,7 +1770,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, ...@@ -1769,7 +1770,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
* bring it back from swap or allocate. * bring it back from swap or allocate.
*/ */
sbinfo = SHMEM_SB(inode->i_sb); 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) { if (swap.val) {
/* Look it up and read it in.. */ /* Look it up and read it in.. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册