From d3cec809aa65109e2dfe8b28dbd6667b2e51ceed Mon Sep 17 00:00:00 2001 From: t_jeang Date: Tue, 6 Jan 2009 12:06:06 +0000 Subject: [PATCH] imported patch oom-debug-me-harder --- mm/oom_kill.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 54ffd8bc..351f5c36 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -49,6 +49,8 @@ int sysctl_panic_on_oom; unsigned long badness(struct task_struct *p, unsigned long uptime) { unsigned long points, cpu_time, run_time, s; + unsigned long nr_children = 0, child_points = 0; + int is_nice = 0, is_super = 0, is_rawio = 0; struct mm_struct *mm; struct task_struct *child; @@ -86,9 +88,13 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) list_for_each_entry(child, &p->children, sibling) { task_lock(child); if (child->mm != mm && child->mm) - points += child->mm->total_vm/2 + 1; + { + nr_children++; + child_points += child->mm->total_vm/2 + 1; + } task_unlock(child); } + points += child_points; /* * CPU time is in tens of seconds and run time is in thousands @@ -115,7 +121,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) * their badness points. */ if (task_nice(p) > 0) + { + is_nice = 1; points *= 2; + } /* * Superuser processes are usually more important, so we make it @@ -123,7 +132,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) */ if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_ADMIN) || p->uid == 0 || p->euid == 0) + { + is_super = 1; points /= 4; + } /* * We don't want to kill a process with direct hardware access. @@ -132,7 +144,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) * of as important. */ if (cap_t(p->cap_effective) & CAP_TO_MASK(CAP_SYS_RAWIO)) + { + is_rawio = 1; points /= 4; + } /* * If p's nodes don't overlap ours, it may still help to kill p @@ -153,8 +168,11 @@ unsigned long badness(struct task_struct *p, unsigned long uptime) } #ifdef DEBUG - printk(KERN_INFO "OOMkill: task %d (%s) got %ld points\n", - p->pid, p->comm, points); + printk(KERN_INFO "OOMkill: task %d (%s) got %ld points " + "(base total_vm %ld, %ld children gave %ld points, cpu_time %ld, runtime %ld, " + "is_nice %s, is_super %s, is_rawio %s, adj %d)\n", + p->pid, p->comm, points, mm->total_vm, nr_children, child_points, cpu_time, run_time, + is_nice?"yes":"no", is_super?"yes":"no", is_rawio?"yes":"no", p->oomkilladj); #endif return points; } -- 2.39.5