]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.19.2/fix-oom-killing-of-swapoff.patch
5.15-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.19.2 / fix-oom-killing-of-swapoff.patch
1 From stable-bounces@linux.kernel.org Fri Jan 5 16:57:46 2007
2 Message-Id: <200701060037.l060bUhd013413@shell0.pdx.osdl.net>
3 To: torvalds@osdl.org
4 From: akpm@osdl.org
5 Date: Fri, 05 Jan 2007 16:37:03 -0800
6 Cc: akpm@osdl.org, hugh@veritas.com, stable@kernel.org
7 Subject: fix OOM killing of swapoff
8
9 From: Hugh Dickins <hugh@veritas.com>
10
11 These days, if you swapoff when there isn't enough memory, OOM killer gives
12 "BUG: scheduling while atomic" and the machine hangs: badness() needs to do
13 its PF_SWAPOFF return after the task_unlock (tasklist_lock is also held
14 here, so p isn't going to be freed: PF_SWAPOFF might get turned off at any
15 moment, but that doesn't really matter).
16
17 Signed-off-by: Hugh Dickins <hugh@veritas.com>
18 Cc: <stable@kernel.org>
19 Signed-off-by: Andrew Morton <akpm@osdl.org>
20 Signed-off-by: Chris Wright <chrisw@sous-sol.org>
21 ---
22
23 mm/oom_kill.c | 12 ++++++------
24 1 file changed, 6 insertions(+), 6 deletions(-)
25
26 --- linux-2.6.19.1.orig/mm/oom_kill.c
27 +++ linux-2.6.19.1/mm/oom_kill.c
28 @@ -61,12 +61,6 @@ unsigned long badness(struct task_struct
29 }
30
31 /*
32 - * swapoff can easily use up all memory, so kill those first.
33 - */
34 - if (p->flags & PF_SWAPOFF)
35 - return ULONG_MAX;
36 -
37 - /*
38 * The memory size of the process is the basis for the badness.
39 */
40 points = mm->total_vm;
41 @@ -77,6 +71,12 @@ unsigned long badness(struct task_struct
42 task_unlock(p);
43
44 /*
45 + * swapoff can easily use up all memory, so kill those first.
46 + */
47 + if (p->flags & PF_SWAPOFF)
48 + return ULONG_MAX;
49 +
50 + /*
51 * Processes which fork a lot of child processes are likely
52 * a good choice. We add half the vmsize of the children if they
53 * have an own mm. This prevents forking servers to flood the