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;
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
* their badness points.
*/
if (task_nice(p) > 0)
+ {
+ is_nice = 1;
points *= 2;
+ }
/*
* Superuser processes are usually more important, so we make it
*/
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.
* 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
}
#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;
}