提交 d079da8f 编写于 作者: G Guo Mengqi 提交者: Yang Yingliang

mm: share_pool: adjust sp_alloc behavior when coredump

ascend inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4MUV2
CVE: NA

when sp_alloc is being executed ont the whole sharepool group,
and one process coredumps, allocation will skip the coredumped process and
continue on the rest processes in the group.
Signed-off-by: NGuo Mengqi <guomengqi3@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 391fe830
......@@ -2163,6 +2163,7 @@ static unsigned long sp_mmap(struct mm_struct *mm, struct file *file,
#define ALLOC_NORMAL 1
#define ALLOC_RETRY 2
#define ALLOC_NOMEM 3
#define ALLOC_COREDUMP 4
struct sp_alloc_context {
struct sp_group *spg;
......@@ -2341,8 +2342,7 @@ static int sp_alloc_mmap(struct mm_struct *mm, struct sp_area *spa,
down_write(&mm->mmap_sem);
if (unlikely(mm->core_state)) {
up_write(&mm->mmap_sem);
sp_alloc_unmap(mm, spa, spg_node);
ac->state = ALLOC_NOMEM;
ac->state = ALLOC_COREDUMP;
pr_info("allocation encountered coredump\n");
return -EFAULT;
}
......@@ -2484,7 +2484,8 @@ static int __sp_alloc_mmap_populate(struct mm_struct *mm, struct sp_area *spa,
static int sp_alloc_mmap_populate(struct sp_area *spa,
struct sp_alloc_context *ac)
{
int ret;
int ret = -EINVAL;
int mmap_ret = 0;
struct mm_struct *mm;
struct sp_group_node *spg_node;
......@@ -2494,9 +2495,19 @@ static int sp_alloc_mmap_populate(struct sp_area *spa,
/* create mapping for each process in the group */
list_for_each_entry(spg_node, &spa->spg->procs, proc_node) {
mm = spg_node->master->mm;
ret = __sp_alloc_mmap_populate(mm, spa, spg_node, ac);
if (ret)
return ret;
mmap_ret = __sp_alloc_mmap_populate(mm, spa, spg_node, ac);
if (mmap_ret) {
if (ac->state != ALLOC_COREDUMP)
return mmap_ret;
if (ac->spg == spg_none) {
sp_alloc_unmap(mm, spa, spg_node);
pr_err("dvpp allocation failed due to coredump");
return mmap_ret;
}
ac->state = ALLOC_NORMAL;
continue;
}
ret = mmap_ret;
}
}
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册