diff -NurpP --minimal linux-2.6.18.3-vs2.1.1.2.2/include/linux/vs_memory.h linux-2.6.18.3-vs2.1.1.2.3/include/linux/vs_memory.h --- linux-2.6.18.3-vs2.1.1.2.2/include/linux/vs_memory.h 2006-11-26 21:23:33 +0100 +++ linux-2.6.18.3-vs2.1.1.2.3/include/linux/vs_memory.h 2006-11-27 03:08:42 +0100 @@ -150,6 +150,9 @@ void __vx_page_fault(struct mm_struct *m #define vx_page_fault(mm,vma,type,ret) __vx_page_fault(mm,vma,type,ret) #endif + +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm); + #else #warning duplicate inclusion #endif diff -NurpP --minimal linux-2.6.18.3-vs2.1.1.2.2/kernel/vserver/limit.c linux-2.6.18.3-vs2.1.1.2.3/kernel/vserver/limit.c --- linux-2.6.18.3-vs2.1.1.2.2/kernel/vserver/limit.c 2006-11-26 19:43:50 +0100 +++ linux-2.6.18.3-vs2.1.1.2.3/kernel/vserver/limit.c 2006-11-27 03:25:09 +0100 @@ -259,7 +259,7 @@ void vx_vsi_meminfo(struct sysinfo *val) totalram = (v != RLIM_INFINITY) ? v : val->totalram; /* total minus used equals free */ - v = __rlim_get(&vxi->limit, RLIMIT_RSS); + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS); freeram = (v < totalram) ? totalram - v : 0; val->totalram = totalram; @@ -287,7 +287,7 @@ void vx_vsi_swapinfo(struct sysinfo *val totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap; /* currently 'used' swap */ - w = __rlim_get(&vxi->limit, RLIMIT_RSS); + w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS); w -= (w > v) ? v : w; /* total minus used equals free */ @@ -298,3 +298,20 @@ void vx_vsi_swapinfo(struct sysinfo *val return; } + +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm) +{ + struct vx_info *vxi = mm->mm_vx_info; + unsigned long points; + rlim_t v, w; + + if (!vxi) + return 0; + + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS); + w = __rlim_soft(&vxi->limit, RLIMIT_RSS); + points = (v > w) ? (v - w) : 0; + + return points; +} + diff -NurpP --minimal linux-2.6.18.3-vs2.1.1.2.2/mm/oom_kill.c linux-2.6.18.3-vs2.1.1.2.3/mm/oom_kill.c --- linux-2.6.18.3-vs2.1.1.2.2/mm/oom_kill.c 2006-11-07 05:55:55 +0100 +++ linux-2.6.18.3-vs2.1.1.2.3/mm/oom_kill.c 2006-11-27 03:01:40 +0100 @@ -21,6 +21,7 @@ #include #include #include +#include int sysctl_panic_on_oom; /* #define DEBUG */ @@ -62,13 +63,17 @@ unsigned long badness(struct task_struct */ points = mm->total_vm; + /* + * add points for context badness + */ + + points += vx_badness(p, mm); + /* * After this unlock we can no longer dereference local variable `mm' */ task_unlock(p); - /* FIXME: add vserver badness ;) */ - /* * Processes which fork a lot of child processes are likely * a good choice. We add half the vmsize of the children if they