From: Ding Tianhong dingtianhong@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4M253 CVE: NA
-------------------------------------------------
No need to record the redundant message for out of memory, the kernel already handle it when oom.
Signed-off-by: Ding Tianhong dingtianhong@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- mm/share_pool.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/mm/share_pool.c b/mm/share_pool.c index 2cc15f894cf84..ea61f69cdd6ad 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -137,10 +137,8 @@ static struct sp_group_master *sp_init_group_master_locked( }
master = kmalloc(sizeof(struct sp_group_master), GFP_KERNEL); - if (master == NULL) { - pr_err_ratelimited("no memory for spg master\n"); + if (master == NULL) return ERR_PTR(-ENOMEM); - }
INIT_LIST_HEAD(&master->node_list); master->count = 0; @@ -192,10 +190,8 @@ static struct sp_proc_stat *create_proc_stat(struct mm_struct *mm, struct sp_proc_stat *stat;
stat = kmalloc(sizeof(*stat), GFP_KERNEL); - if (stat == NULL) { - pr_err_ratelimited("no memory for proc stat\n"); + if (stat == NULL) return ERR_PTR(-ENOMEM); - }
atomic_set(&stat->use_count, 1); atomic64_set(&stat->alloc_size, 0); @@ -342,10 +338,8 @@ static struct spg_proc_stat *create_spg_proc_stat(int tgid, int spg_id) struct spg_proc_stat *stat;
stat = kmalloc(sizeof(struct spg_proc_stat), GFP_KERNEL); - if (stat == NULL) { - pr_err_ratelimited("no memory for spg proc stat\n"); + if (stat == NULL) return ERR_PTR(-ENOMEM); - }
stat->tgid = tgid; stat->spg_id = spg_id; @@ -413,10 +407,8 @@ static struct sp_spg_stat *create_spg_stat(int spg_id) struct sp_spg_stat *stat;
stat = kmalloc(sizeof(*stat), GFP_KERNEL); - if (stat == NULL) { - pr_err_ratelimited("no memory for spg stat\n"); + if (stat == NULL) return ERR_PTR(-ENOMEM); - }
stat->spg_id = spg_id; atomic_set(&stat->hugepage_failures, 0); @@ -1624,10 +1616,8 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags, }
spa = __kmalloc_node(sizeof(struct sp_area), GFP_KERNEL, node_id); - if (unlikely(!spa)) { - pr_err_ratelimited("no memory for spa\n"); + if (unlikely(!spa)) return ERR_PTR(-ENOMEM); - }
spin_lock(&sp_area_lock);
From: Ding Tianhong dingtianhong@huawei.com
ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4M23J CVE: NA
-------------------------------------------------
Don't use the spa's va_start if the spa is not valid.
Signed-off-by: Ding Tianhong dingtianhong@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- mm/share_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/share_pool.c b/mm/share_pool.c index ea61f69cdd6ad..c9079e6a40b1a 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -2500,13 +2500,14 @@ static void sp_alloc_finish(int result, struct sp_area *spa, sp_update_process_stat(current, true, spa);
/* this will free spa if mmap failed */ - if (spa && !IS_ERR(spa)) + if (spa && !IS_ERR(spa)) { __sp_area_drop(spa); + trace_sp_alloc_finish(ac, spa->va_start); + }
if (!is_pass_through) sp_group_drop(spg);
- trace_sp_alloc_finish(ac, spa->va_start); sp_dump_stack(); sp_try_to_compact(); }