Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
a7f638f999ff ("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>

authored by

David Rientjes and committed by
Linus Torvalds
1e11ad8d 72494504

+2 -2
+2 -2
mm/oom_kill.c
··· 183 183 unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, 184 184 const nodemask_t *nodemask, unsigned long totalpages) 185 185 { 186 - unsigned long points; 186 + long points; 187 187 188 188 if (oom_unkillable_task(p, memcg, nodemask)) 189 189 return 0; ··· 223 223 * Never return 0 for an eligible task regardless of the root bonus and 224 224 * oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here). 225 225 */ 226 - return points ? points : 1; 226 + return points > 0 ? points : 1; 227 227 } 228 228 229 229 /*