+ set_tsk_thread_flag(p, TIF_MEMDIE);
+
+ force_sig(SIGKILL, p);
+}
+
+static int oom_kill_task(struct task_struct *p)
+{
+ struct mm_struct *mm;
+ struct task_struct *g, *q;
+
+ mm = p->mm;
+
+ /* WARNING: mm may not be dereferenced since we did not obtain its
+ * value from get_task_mm(p). This is OK since all we need to do is
+ * compare mm to q->mm below.
+ *
+ * Furthermore, even if mm contains a non-NULL value, p->mm may
+ * change to NULL at any time since we do not hold task_lock(p).
+ * However, this is of no concern to us.
+ */
+
+ if (mm == NULL)
+ return 1;
+
+ /*
+ * Don't kill the process if any threads are set to OOM_DISABLE
+ */
+ do_each_thread(g, q) {
+ if (q->mm == mm && q->oomkilladj == OOM_DISABLE)
+ return 1;
+ } while_each_thread(g, q);
+
+ __oom_kill_task(p, 1);
+
+ /*
+ * kill all processes that share the ->mm (i.e. all threads),
+ * but are in a different thread group. Don't let them have access
+ * to memory reserves though, otherwise we might deplete all memory.
+ */
+ do_each_thread(g, q) {
+ if (q->mm == mm && q->tgid != p->tgid)
+ force_sig(SIGKILL, q);
+ } while_each_thread(g, q);
+
+ return 0;
+}
+
+static int oom_kill_process(struct task_struct *p, unsigned long points,
+ const char *message)
+{
+ struct task_struct *c;
+ struct list_head *tsk;