From: Andrea Arcangeli <andrea@suse.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@osdl.org>,
marcelo.tosatti@cyclades.com, LKML <linux-kernel@vger.kernel.org>,
Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: [PATCH] oom killer (Core)
Date: Thu, 2 Dec 2004 04:36:19 +0100 [thread overview]
Message-ID: <20041202033619.GA32635@dualathlon.random> (raw)
In-Reply-To: <1101938767.13353.62.camel@tglx.tec.linutronix.de>
Could you please test this? Perhaps it won't be as effective as the
hacks I nuked, but it fixed basic things for me in a quick test so I
like it more. It's important to use pages_high to avoid livelocks.
Thanks.
Signed-off-by: Andrea Arcangeli <andrea@suse.de>
Index: x/mm/oom_kill.c
===================================================================
RCS file: /home/andrea/crypto/cvs/linux-2.5/mm/oom_kill.c,v
retrieving revision 1.31
diff -u -p -r1.31 oom_kill.c
--- x/mm/oom_kill.c 14 Oct 2004 04:27:49 -0000 1.31
+++ x/mm/oom_kill.c 2 Dec 2004 03:34:05 -0000
@@ -229,72 +229,8 @@ retry:
*/
void out_of_memory(int gfp_mask)
{
- /*
- * oom_lock protects out_of_memory()'s static variables.
- * It's a global lock; this is not performance-critical.
- */
- static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED;
- static unsigned long first, last, count, lastkill;
- unsigned long now, since;
-
- spin_lock(&oom_lock);
- now = jiffies;
- since = now - last;
- last = now;
-
- /*
- * If it's been a long time since last failure,
- * we're not oom.
- */
- if (since > 5*HZ)
- goto reset;
-
- /*
- * If we haven't tried for at least one second,
- * we're not really oom.
- */
- since = now - first;
- if (since < HZ)
- goto out_unlock;
-
- /*
- * If we have gotten only a few failures,
- * we're not really oom.
- */
- if (++count < 10)
- goto out_unlock;
-
- /*
- * If we just killed a process, wait a while
- * to give that task a chance to exit. This
- * avoids killing multiple processes needlessly.
- */
- since = now - lastkill;
- if (since < HZ*5)
- goto out_unlock;
-
- /*
- * Ok, really out of memory. Kill something.
- */
- lastkill = now;
-
printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
show_free_areas();
-
- /* oom_kill() sleeps */
- spin_unlock(&oom_lock);
+ dump_stack();
oom_kill();
- spin_lock(&oom_lock);
-
-reset:
- /*
- * We dropped the lock above, so check to be sure the variable
- * first only ever increases to prevent false OOM's.
- */
- if (time_after(now, first))
- first = now;
- count = 0;
-
-out_unlock:
- spin_unlock(&oom_lock);
}
Index: x/mm/page_alloc.c
===================================================================
RCS file: /home/andrea/crypto/cvs/linux-2.5/mm/page_alloc.c,v
retrieving revision 1.236
diff -u -p -r1.236 page_alloc.c
--- x/mm/page_alloc.c 16 Nov 2004 03:53:53 -0000 1.236
+++ x/mm/page_alloc.c 2 Dec 2004 02:21:18 -0000
@@ -611,6 +611,7 @@ __alloc_pages(unsigned int gfp_mask, uns
int alloc_type;
int do_retry;
int can_try_harder;
+ int did_some_progress;
might_sleep_if(wait);
@@ -686,18 +687,19 @@ rebalance:
reclaim_state.reclaimed_slab = 0;
p->reclaim_state = &reclaim_state;
- try_to_free_pages(zones, gfp_mask, order);
+ did_some_progress = try_to_free_pages(zones, gfp_mask, order);
p->reclaim_state = NULL;
p->flags &= ~PF_MEMALLOC;
- /* go through the zonelist yet one more time */
+ /*
+ * Go through the zonelist yet one more time, keep
+ * very high watermark here, this is only to catch
+ * a parallel oom killing, we must fail if we're still
+ * under heavy pressure.
+ */
for (i = 0; (z = zones[i]) != NULL; i++) {
- min = z->pages_min;
- if (gfp_mask & __GFP_HIGH)
- min /= 2;
- if (can_try_harder)
- min -= min / 4;
+ min = z->pages_high;
min += (1<<order) + z->protection[alloc_type];
if (z->free_pages < min)
@@ -708,6 +710,9 @@ rebalance:
goto got_pg;
}
+ if (unlikely(!did_some_progress) && (gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
+ out_of_memory(gfp_mask);
+
/*
* Don't let big-order allocations loop unless the caller explicitly
* requests that. Wait for some write requests to complete then retry.
Index: x/mm/vmscan.c
===================================================================
RCS file: /home/andrea/crypto/cvs/linux-2.5/mm/vmscan.c,v
retrieving revision 1.225
diff -u -p -r1.225 vmscan.c
--- x/mm/vmscan.c 19 Nov 2004 22:54:22 -0000 1.225
+++ x/mm/vmscan.c 2 Dec 2004 01:56:50 -0000
@@ -935,8 +935,6 @@ int try_to_free_pages(struct zone **zone
if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
blk_congestion_wait(WRITE, HZ/10);
}
- if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
- out_of_memory(gfp_mask);
out:
for (i = 0; zones[i] != 0; i++)
zones[i]->prev_priority = zones[i]->temp_priority;
next prev parent reply other threads:[~2004-12-02 3:36 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-01 9:49 [PATCH] oom killer (Core) tglx
2004-12-01 21:16 ` Andrea Arcangeli
2004-12-01 22:06 ` Thomas Gleixner
2004-12-01 22:33 ` Andrea Arcangeli
2004-12-02 3:36 ` Andrea Arcangeli [this message]
2004-12-02 11:09 ` Thomas Gleixner
2004-12-02 13:48 ` Thomas Gleixner
2004-12-02 16:47 ` Andrea Arcangeli
2004-12-02 16:55 ` Andrew Morton
2004-12-02 11:18 ` Marcelo Tosatti
2004-12-02 17:17 ` Thomas Gleixner
2004-12-02 17:27 ` Andrew Morton
2004-12-02 18:08 ` Andrea Arcangeli
2004-12-02 18:29 ` Andrew Morton
2004-12-02 19:01 ` Thomas Gleixner
2004-12-02 18:55 ` Thomas Gleixner
2004-12-02 19:07 ` Andrew Morton
2004-12-02 19:08 ` Thomas Gleixner
2004-12-02 19:22 ` Andrew Morton
2004-12-02 19:24 ` Thomas Gleixner
2004-12-02 20:11 ` Andre Tomt
2004-12-03 22:45 ` Thomas Gleixner
2004-12-02 23:47 ` Andrea Arcangeli
2004-12-03 14:41 ` Helge Hafting
2004-12-03 21:20 ` Thomas Gleixner
2004-12-05 21:14 ` Helge Hafting
2004-12-02 23:35 ` Andrea Arcangeli
2004-12-03 2:28 ` Andrea Arcangeli
2004-12-03 22:37 ` Thomas Gleixner
2004-12-03 22:51 ` Thomas Gleixner
2004-12-03 23:08 ` Andrea Arcangeli
2004-12-10 16:36 ` William Lee Irwin III
2004-12-10 17:35 ` Andrea Arcangeli
2004-12-10 17:43 ` William Lee Irwin III
2004-12-10 17:55 ` Andrea Arcangeli
2004-12-10 18:00 ` William Lee Irwin III
2004-12-10 18:15 ` Andrea Arcangeli
2004-12-10 18:19 ` William Lee Irwin III
2004-12-10 19:05 ` Andrea Arcangeli
2004-12-10 16:51 ` William Lee Irwin III
2004-12-03 21:10 ` Thomas Gleixner
2004-12-03 22:21 ` Andrea Arcangeli
2004-12-05 2:52 ` William Lee Irwin III
2004-12-05 13:38 ` Thomas Gleixner
2004-12-05 15:22 ` Andrea Arcangeli
2004-12-10 16:32 ` William Lee Irwin III
2004-12-10 16:52 ` Thomas Gleixner
2004-12-10 17:43 ` William Lee Irwin III
2004-12-10 17:47 ` William Lee Irwin III
2004-12-10 17:49 ` Andrea Arcangeli
2004-12-10 17:57 ` William Lee Irwin III
2004-12-12 0:12 ` William Lee Irwin III
2004-12-24 1:18 ` Andrea Arcangeli
-- strict thread matches above, loose matches on Subject: below --
2004-12-01 10:21 tvrtko.ursulin
2004-12-04 7:00 Voluspa
2004-12-04 8:08 ` Andrea Arcangeli
2004-12-04 12:42 Voluspa
2004-12-04 16:43 ` Andrea Arcangeli
2004-12-04 18:33 ` Thomas Gleixner
2004-12-04 21:02 ` Thomas Gleixner
2004-12-05 0:27 ` Andrea Arcangeli
2004-12-05 14:55 ` Thomas Gleixner
2004-12-05 15:34 ` Andrea Arcangeli
2004-12-05 16:29 ` Thomas Gleixner
2004-12-05 2:22 Voluspa
2004-12-05 8:32 Voluspa
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=20041202033619.GA32635@dualathlon.random \
--to=andrea@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com \
--cc=nickpiggin@yahoo.com.au \
--cc=tglx@linutronix.de \
/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