]> xenbits.xen.org Git - xenclient/kernel.git/commitdiff
imported patch oom-debug-me-harder oom-debugging
authort_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:06 +0000 (12:06 +0000)
committert_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:06:06 +0000 (12:06 +0000)
mm/oom_kill.c

index 54ffd8bceb8f0ff140d936a8b152971e337eb061..351f5c36f1ff89dfc6072dea294538234ca15bbe 100644 (file)
@@ -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;
 }