mm, oom: fix badness score underflow
If the privileges given to root threads (3% of allowable memory) or a
negative value of /proc/pid/oom_score_adj happen to exceed the amount of
rss of a thread, its badness score overflows as a result of commit
a7f638f999
("mm, oom: normalize oom scores to oom_score_adj scale only
for userspace").
Fix this by making the type signed and return 1, meaning the thread is
still eligible for kill, if the value is negative.
Reported-by: Dave Jones <davej@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
7249450449
commit
1e11ad8dc4
@@ -183,7 +183,7 @@ static bool oom_unkillable_task(struct task_struct *p,
|
|||||||
unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
|
unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
|
||||||
const nodemask_t *nodemask, unsigned long totalpages)
|
const nodemask_t *nodemask, unsigned long totalpages)
|
||||||
{
|
{
|
||||||
unsigned long points;
|
long points;
|
||||||
|
|
||||||
if (oom_unkillable_task(p, memcg, nodemask))
|
if (oom_unkillable_task(p, memcg, nodemask))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -223,7 +223,7 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
|
|||||||
* Never return 0 for an eligible task regardless of the root bonus and
|
* Never return 0 for an eligible task regardless of the root bonus and
|
||||||
* oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here).
|
* oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here).
|
||||||
*/
|
*/
|
||||||
return points ? points : 1;
|
return points > 0 ? points : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user