Commit e4f3f59b authored by Jing Xiangfeng's avatar Jing Xiangfeng Committed by Zheng Zengkai
Browse files

mm: fix oom killing for disabled pid

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I46IUJ


CVE: NA

--------------------------------------

In oom_next_task(), if points is equal to LONG_MIN, then we choose it to
kill. That is not correct. LONG_MIN means to disable killing it. So fix
it.

Fixes: 4da32073 ("memcg: support priority for oom")
Signed-off-by: default avatarJing Xiangfeng <jingxiangfeng@huawei.com>
Reviewed-by: default avatarChen Wandun <chenwandun@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent cf8d8755
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -311,15 +311,15 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
 * choose the task with the highest number of 'points'.
 */
static bool oom_next_task(struct task_struct *task, struct oom_control *oc,
			unsigned long points)
			long points)
{
	struct mem_cgroup *cur_memcg;
	struct mem_cgroup *oc_memcg;

	if (!static_branch_likely(&memcg_qos_stat_key))
		return !points || points < oc->chosen_points;
		return (points == LONG_MIN || points < oc->chosen_points);

	if (!points)
	if (points == LONG_MIN)
		return true;

	if (!oc->chosen)
@@ -341,9 +341,9 @@ static bool oom_next_task(struct task_struct *task, struct oom_control *oc,
}
#else
static inline bool oom_next_task(struct task_struct *task,
				struct oom_control *oc, unsigned long points)
				struct oom_control *oc, long points)
{
	return !points || points < oc->chosen_points;
	return (points == LONG_MIN || points < oc->chosen_points);
}
#endif