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>
#endif
/* The badness from the OOM killer */
#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;
static int proc_oom_score(struct task_struct *task, char *buffer)
{
unsigned long points = 0;
do_posix_clock_monotonic_gettime(&uptime);
read_lock(&tasklist_lock);
if (pid_alive(task))
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);
}
read_unlock(&tasklist_lock);
return sprintf(buffer, "%lu\n", points);
}
* algorithm has been meticulously tuned to meet the principle
* of least surprise ... (be careful when you change it)
*/
* algorithm has been meticulously tuned to meet the principle
* of least surprise ... (be careful when you change it)
*/
-
-unsigned long badness(struct task_struct *p, unsigned long uptime)
+unsigned long badness(struct task_struct *p, struct mem_cgroup *mem,
+ const nodemask_t *nodemask, unsigned long uptime)
{
unsigned long points, cpu_time, run_time;
struct task_struct *child;
{
unsigned long points, cpu_time, run_time;
struct task_struct *child;
unsigned long utime;
unsigned long stime;
unsigned long utime;
unsigned long stime;
+ if (oom_unkillable_task(p, mem, nodemask))
+ return 0;
if (oom_adj == OOM_DISABLE)
return 0;
if (oom_adj == OOM_DISABLE)
return 0;
if (p->signal->oom_adj == OOM_DISABLE)
continue;
if (p->signal->oom_adj == OOM_DISABLE)
continue;
- points = badness(p, uptime.tv_sec);
+ points = badness(p, mem, nodemask, uptime.tv_sec);
if (points > *ppoints || !chosen) {
chosen = p;
*ppoints = points;
if (points > *ppoints || !chosen) {
chosen = p;
*ppoints = points;
if (child->mm == p->mm)
continue;
if (child->mm == p->mm)
continue;
- if (oom_unkillable_task(p, mem, nodemask))
- continue;
/* badness() returns 0 if the thread is unkillable */
/* badness() returns 0 if the thread is unkillable */
- child_points = badness(child, uptime.tv_sec);
+ child_points = badness(child, mem, nodemask,
+ uptime.tv_sec);
if (child_points > victim_points) {
victim = child;
victim_points = child_points;
if (child_points > victim_points) {
victim = child;
victim_points = child_points;