oom: /proc/<pid>/oom_score treat kernel thread honestly
If a kernel thread is using use_mm(), badness() returns a positive value. This is not a big issue because caller take care of it correctly. But there is one exception, /proc/<pid>/oom_score calls badness() directly and doesn't care that the task is a regular process. Another example, /proc/1/oom_score return !0 value. But it's unkillable. This incorrectness makes administration a little confusing. This patch fixes it. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: David Rientjes <rientjes@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
f88ccad588
commit
26ebc98491
@@ -428,7 +428,8 @@ static const struct file_operations proc_lstats_operations = {
|
||||
#endif
|
||||
|
||||
/* The badness from the OOM killer */
|
||||
unsigned long badness(struct task_struct *p, unsigned long uptime);
|
||||
unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
|
||||
nodemask_t *nodemask, unsigned long uptime);
|
||||
static int proc_oom_score(struct task_struct *task, char *buffer)
|
||||
{
|
||||
unsigned long points = 0;
|
||||
@@ -437,7 +438,7 @@ static int proc_oom_score(struct task_struct *task, char *buffer)
|
||||
do_posix_clock_monotonic_gettime(&uptime);
|
||||
read_lock(&tasklist_lock);
|
||||
if (pid_alive(task))
|
||||
points = badness(task, uptime.tv_sec);
|
||||
points = badness(task, NULL, NULL, uptime.tv_sec);
|
||||
read_unlock(&tasklist_lock);
|
||||
return sprintf(buffer, "%lu\n", points);
|
||||
}
|
||||
|
Reference in New Issue
Block a user