static int compare_victims(const struct task_info *ta, const struct task_info *tb)
{
- /*
- * Firstly, sort by oom_score_adj
- * Secondly, sort by task size
- */
- assert(ta != NULL);
- assert(tb != NULL);
-
- if (ta->oom_score_lru != tb->oom_score_lru)
- return tb->oom_score_lru - ta->oom_score_lru;
-
- /*
- * Get memory usage for tasks with the same oom score.
- * Since there could be multiple tasks with the same pgid,
- * we sum all of the tasks.
- * Even though we calculate memory usage when we should compare it,
- * there could be frequent cases to get memory usage of tasks that
- * would not be selected as victim. Therefore we just use RSS + Swap,
- * which causes much less overhead.
- */
- return (int)(tb->size) - (int)(ta->size);
-}
-
-static int compare_victims_point(const struct task_info *ta, const struct task_info *tb)
-{
unsigned int pa, pb;
assert(ta != NULL);
/*
* followed by kernel badness point calculation using heuristic.
* oom_score_adj is normalized by its unit, which varies -1000 ~ 1000.
- * Since we only consider tasks with oom_score_adj larger than 0
- * as victim candidates, point always has positive value.
*/
- pa = ta->oom_score_lru * (ktotalram / 1000) + ta->size;
- pb = tb->oom_score_lru * (ktotalram / 1000) + tb->size;
+ pa = ta->oom_score_lru * (ktotalram / 2000) + ta->size;
+ pb = tb->oom_score_lru * (ktotalram / 2000) + tb->size;
return pb - pa;
}
if (start_oom == OOMADJ_SU)
lowmem_get_pids_proc(candidates);
- if (start_oom <= OOMADJ_BACKGRD_LOCKED || start_oom >= OOMADJ_BACKGRD_OLD)
+ g_array_sort(candidates, (GCompareFunc)compare_victims);
+/* if (start_oom <= OOMADJ_BACKGRD_LOCKED || start_oom >= OOMADJ_BACKGRD_OLD)
g_array_sort(candidates, (GCompareFunc)compare_victims_point);
else
- g_array_sort(candidates, (GCompareFunc)compare_victims);
+ g_array_sort(candidates, (GCompareFunc)compare_victims);*/
for (i = 0; i < candidates->len; i++) {
struct task_info *tsk;