oom: always return a badness score of non-zero for eligible tasks
A task's badness score is roughly a proportion of its rss and swap compared to the system's capacity. The scale ranges from 0 to 1000 with the highest score chosen for kill. Thus, this scale operates on a resolution of 0.1% of RAM + swap. Admin tasks are also given a 3% bonus, so the badness score of an admin task using 3% of memory, for example, would still be 0. It's possible that an exceptionally large number of tasks will combine to exhaust all resources but never have a single task that uses more than 0.1% of RAM and swap (or 3.0% for admin tasks). This patch ensures that the badness score of any eligible task is never 0 so the machine doesn't unnecessarily panic because it cannot find a task to kill. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Dave Hansen <dave@linux.vnet.ibm.com> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
767b68e969
commit
f19e8aa11a
|
@ -208,8 +208,13 @@ unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
|
|||
*/
|
||||
points += p->signal->oom_score_adj;
|
||||
|
||||
if (points < 0)
|
||||
return 0;
|
||||
/*
|
||||
* Never return 0 for an eligible task that may be killed since it's
|
||||
* possible that no single user task uses more than 0.1% of memory and
|
||||
* no single admin tasks uses more than 3.0%.
|
||||
*/
|
||||
if (points <= 0)
|
||||
return 1;
|
||||
return (points < 1000) ? points : 1000;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue