linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@cpushare.com>
To: linux-mm@kvack.org
Subject: [PATCH 07 of 13] don't depend on PF_EXITING tasks to go away
Date: Tue, 08 Jan 2008 08:50:38 +0100	[thread overview]
Message-ID: <ee9691f08d054949b771.1199778638@v2.random> (raw)
In-Reply-To: <patchbomb.1199778631@v2.random>

# HG changeset patch
# User Andrea Arcangeli <andrea@suse.de>
# Date 1199470022 -3600
# Node ID ee9691f08d054949b7718cff94c4f132d97626de
# Parent  dd5900d0aa4e5f1b81364346465be53db897246f
don't depend on PF_EXITING tasks to go away

A PF_EXITING task don't have TIF_MEMDIE set so it might get stuck in
memory allocations without access to the PF_MEMALLOC pool (said that
ideally do_exit would better not require memory allocations, especially
not before calling exit_mm). The same way we raise its privilege to
TIF_MEMDIE if it's the current task, we should do it even if it's not
the current task to speedup oom killing.

Signed-off-by: Andrea Arcangeli <andrea@suse.de>

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -233,16 +233,16 @@ static struct task_struct *select_bad_pr
 		 * This is in the process of releasing memory so wait for it
 		 * to finish before killing some other task by mistake.
 		 *
-		 * However, if p is the current task, we allow the 'kill' to
-		 * go ahead if it is exiting: this will simply set TIF_MEMDIE,
-		 * which will allow it to gain access to memory reserves in
-		 * the process of exiting and releasing its resources.
-		 * Otherwise we could get an easy OOM deadlock.
+		 * We must however set TIF_MEMDIE on this task so we select it with
+		 * maximum points. This PF_EXITING task may be out of the scheduler
+		 * and zombie and it may have released all its memory already and
+		 * furthermore we want to give it access to all the memory reserves.
+		 *
+		 * If it's too late and this selected task can't release any memory
+		 * anymore the memdie_jiffies will timeout and fallback in killing
+		 * a new task later.
 		 */
 		if (p->flags & PF_EXITING) {
-			if (p != current)
-				return ERR_PTR(-1UL);
-
 			chosen = p;
 			*ppoints = ULONG_MAX;
 		}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2008-01-08  7:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  7:50 [PATCH 00 of 13] oom deadlock fixes # try 2 Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 01 of 13] limit shrink zone scanning Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 02 of 13] avoid oom deadlock in nfs_create_request Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 03 of 13] prevent oom deadlocks during read/write operations Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 04 of 13] avoid selecting already killed tasks Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 05 of 13] reduce the probability of an OOM livelock Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 06 of 13] balance_pgdat doesn't return the number of pages freed Andrea Arcangeli
2008-01-08  7:50 ` Andrea Arcangeli [this message]
2008-01-08  7:50 ` [PATCH 08 of 13] stop useless vm trashing while we wait the TIF_MEMDIE task to exit Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 09 of 13] oom select should only take rss into account Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 10 of 13] limit reclaim if enough pages have been freed Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 11 of 13] not-wait-memdie Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 12 of 13] gfp-repeat stop with TIF_MEMDIE Andrea Arcangeli
2008-01-08  7:50 ` [PATCH 13 of 13] congestion wait Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9691f08d054949b771.1199778638@v2.random \
    --to=andrea@cpushare.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox