[patch 10/11 -mmotm] oom: avoid oom kill if no interruptible tasks

From: David Rientjes
Date: Sun May 10 2009 - 18:10:37 EST


If there are no interruptible system tasks other than kthreads, no task
should be chosen for oom kill since they won't respond to the SIGKILL
anyway. Instead, we choose to simply fail page allocations if reclaim
cannot free memory and hope for the best.

Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
---
mm/oom_kill.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -209,6 +209,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
struct task_struct *g, *p;
struct task_struct *chosen = NULL;
struct timespec uptime;
+ unsigned long nr_interruptible = 0;
*ppoints = 0;
*freed = 0;

@@ -225,6 +226,8 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
/* skip the init task */
if (is_global_init(p))
continue;
+ if (!(p->state & TASK_UNINTERRUPTIBLE))
+ nr_interruptible++;
if (mem && !task_in_mem_cgroup(p, mem))
continue;

@@ -277,7 +280,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
}
} while_each_thread(g, p);

- return chosen;
+ return nr_interruptible ? chosen : ERR_PTR(-1UL);
}

/**
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/