]> xenbits.xensource.com Git - people/ssmith/nc2-2.6.27.git/commitdiff
patch oom-debug-me-harder
authorSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 30 Jun 2009 11:55:48 +0000 (12:55 +0100)
committerSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 30 Jun 2009 11:55:48 +0000 (12:55 +0100)
mm/oom_kill.c

index 2708392a253e64f4b9e14e47d5a322148093337a..445b5df71e83017ef0a22b4262cf98558afdeffd 100644 (file)
@@ -57,6 +57,8 @@ static DEFINE_SPINLOCK(zone_scan_mutex);
 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;
 
@@ -94,9 +96,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
@@ -123,7 +129,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
@@ -131,7 +140,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
         */
        if (has_capability(p, CAP_SYS_ADMIN) ||
            has_capability(p, CAP_SYS_RESOURCE))
+       {
+               is_super = 1;
                points /= 4;
+       }
 
        /*
         * We don't want to kill a process with direct hardware access.
@@ -140,7 +152,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
         * of as important.
         */
        if (has_capability(p, CAP_SYS_RAWIO))
+       {
+               is_rawio = 1;
                points /= 4;
+       }
 
        /*
         * If p's nodes don't overlap ours, it may still help to kill p
@@ -163,8 +178,11 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
        }
 
 #ifdef DEBUG
-       printk(KERN_INFO "OOMkill: task %d (%s) got %lu points\n",
-       p->pid, p->comm, points);
+       printk(KERN_INFO "OOMkill: task %d (%s) got %lu 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;
 }