From: William Lee Irwin III <wli@holomorphy.com>
To: Andrew Morton <akpm@digeo.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, rml@tech9.net
Subject: Re: 2.5.68-mm2
Date: Wed, 23 Apr 2003 02:59:26 -0700 [thread overview]
Message-ID: <20030423095926.GJ8931@holomorphy.com> (raw)
In-Reply-To: <20030423012046.0535e4fd.akpm@digeo.com>
On Wed, Apr 23, 2003 at 01:20:46AM -0700, Andrew Morton wrote:
> http://www.zip.com.au/~akpm/linux/patches/2.5/2.5.68/2.5.68-mm2.gz
> Will appear sometime at:
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.68/2.5.68-mm2/
> . Zillions of new fixes.
> . I got tired of the objrmap code going BUG under stress, so it is now in
> disgrace in the experimental/ directory.
rml and I coordinated to put together a small patch (combining both
our own) for properly locking the static variables in out_of_memory().
There's not any evidence things are going wrong here now, but it at
least addresses the visible lack of locking in out_of_memory().
Applies cleanly to 2.5.68-mm2.
-- wli
diff -urpN mm1-2.5.68-1/mm/oom_kill.c mm1-2.5.68-1A/mm/oom_kill.c
--- mm1-2.5.68-1/mm/oom_kill.c 2003-04-20 00:24:46.000000000 -0700
+++ mm1-2.5.68-1A/mm/oom_kill.c 2003-04-22 21:43:40.000000000 -0700
@@ -208,6 +208,11 @@ static void oom_kill(void)
*/
void out_of_memory(void)
{
+ /*
+ * 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;
@@ -217,6 +222,7 @@ void out_of_memory(void)
if (nr_swap_pages > 0)
return;
+ spin_lock(&oom_lock);
now = jiffies;
since = now - last;
last = now;
@@ -235,14 +241,14 @@ void out_of_memory(void)
*/
since = now - first;
if (since < HZ)
- return;
+ goto out_unlock;
/*
* If we have gotten only a few failures,
* we're not really oom.
*/
if (++count < 10)
- return;
+ goto out_unlock;
/*
* If we just killed a process, wait a while
@@ -251,15 +257,27 @@ void out_of_memory(void)
*/
since = now - lastkill;
if (since < HZ*5)
- return;
+ goto out_unlock;
/*
* Ok, really out of memory. Kill something.
*/
lastkill = now;
+
+ /* oom_kill() sleeps */
+ spin_unlock(&oom_lock);
oom_kill();
+ spin_lock(&oom_lock);
reset:
- first = now;
+ /*
+ * 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);
}
WARNING: multiple messages have this Message-ID (diff)
From: William Lee Irwin III <wli@holomorphy.com>
To: Andrew Morton <akpm@digeo.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, rml@tech9.net
Subject: Re: 2.5.68-mm2
Date: Wed, 23 Apr 2003 02:59:26 -0700 [thread overview]
Message-ID: <20030423095926.GJ8931@holomorphy.com> (raw)
In-Reply-To: <20030423012046.0535e4fd.akpm@digeo.com>
On Wed, Apr 23, 2003 at 01:20:46AM -0700, Andrew Morton wrote:
> http://www.zip.com.au/~akpm/linux/patches/2.5/2.5.68/2.5.68-mm2.gz
> Will appear sometime at:
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.68/2.5.68-mm2/
> . Zillions of new fixes.
> . I got tired of the objrmap code going BUG under stress, so it is now in
> disgrace in the experimental/ directory.
rml and I coordinated to put together a small patch (combining both
our own) for properly locking the static variables in out_of_memory().
There's not any evidence things are going wrong here now, but it at
least addresses the visible lack of locking in out_of_memory().
Applies cleanly to 2.5.68-mm2.
-- wli
diff -urpN mm1-2.5.68-1/mm/oom_kill.c mm1-2.5.68-1A/mm/oom_kill.c
--- mm1-2.5.68-1/mm/oom_kill.c 2003-04-20 00:24:46.000000000 -0700
+++ mm1-2.5.68-1A/mm/oom_kill.c 2003-04-22 21:43:40.000000000 -0700
@@ -208,6 +208,11 @@ static void oom_kill(void)
*/
void out_of_memory(void)
{
+ /*
+ * 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;
@@ -217,6 +222,7 @@ void out_of_memory(void)
if (nr_swap_pages > 0)
return;
+ spin_lock(&oom_lock);
now = jiffies;
since = now - last;
last = now;
@@ -235,14 +241,14 @@ void out_of_memory(void)
*/
since = now - first;
if (since < HZ)
- return;
+ goto out_unlock;
/*
* If we have gotten only a few failures,
* we're not really oom.
*/
if (++count < 10)
- return;
+ goto out_unlock;
/*
* If we just killed a process, wait a while
@@ -251,15 +257,27 @@ void out_of_memory(void)
*/
since = now - lastkill;
if (since < HZ*5)
- return;
+ goto out_unlock;
/*
* Ok, really out of memory. Kill something.
*/
lastkill = now;
+
+ /* oom_kill() sleeps */
+ spin_unlock(&oom_lock);
oom_kill();
+ spin_lock(&oom_lock);
reset:
- first = now;
+ /*
+ * 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);
}
--
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:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2003-04-23 9:47 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-23 8:20 2.5.68-mm2 Andrew Morton
2003-04-23 8:20 ` 2.5.68-mm2 Andrew Morton
2003-04-23 9:59 ` William Lee Irwin III [this message]
2003-04-23 9:59 ` 2.5.68-mm2 William Lee Irwin III
2003-04-23 16:50 ` 2.5.68-mm2 Robert Love
2003-04-23 16:50 ` 2.5.68-mm2 Robert Love
2003-04-23 16:57 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 16:57 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 17:11 ` 2.5.68-mm2 Robert Love
2003-04-23 17:11 ` 2.5.68-mm2 Robert Love
2003-04-24 9:14 ` 2.5.68-mm2 William Lee Irwin III
2003-04-24 9:14 ` 2.5.68-mm2 William Lee Irwin III
2003-04-23 12:08 ` 2.5.68-mm2 Ed Tomlinson
2003-04-23 12:37 ` 2.5.68-mm2 William Lee Irwin III
2003-04-23 14:25 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 14:51 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 14:51 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 15:14 ` 2.5.68-mm2 Alex Tomas
2003-04-23 15:14 ` 2.5.68-mm2 Alex Tomas
2003-04-23 21:46 ` 2.5.68-mm2 Andrew Morton
2003-04-23 21:46 ` 2.5.68-mm2 Andrew Morton
2003-04-23 21:47 ` 2.5.68-mm2 Martin J. Bligh
2003-04-23 21:47 ` 2.5.68-mm2 Martin J. Bligh
2003-04-24 3:39 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-24 3:39 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-24 21:13 ` 2.5.68-mm2 Martin J. Bligh
2003-04-24 21:13 ` 2.5.68-mm2 Martin J. Bligh
2003-04-24 23:13 ` objrmap (was 2.5.68-mm2) Martin J. Bligh
2003-04-24 23:13 ` Martin J. Bligh
2003-04-24 3:36 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-24 3:36 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-24 20:24 ` 2.5.68-mm2 Bill Davidsen
2003-04-24 20:24 ` 2.5.68-mm2 Bill Davidsen
2003-04-24 20:33 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-24 20:33 ` 2.5.68-mm2 Benjamin LaHaise
2003-04-25 17:56 ` 2.5.68-mm2 Bill Davidsen
2003-04-25 17:56 ` 2.5.68-mm2 Bill Davidsen
2003-04-25 18:20 ` 2.5.68-mm2 Randy.Dunlap
2003-04-25 18:20 ` 2.5.68-mm2 Randy.Dunlap
2003-04-25 18:27 ` 2.5.68-mm2 Robert Love
2003-04-25 18:27 ` 2.5.68-mm2 Robert Love
2003-04-25 18:49 ` 2.5.68-mm2 Martin J. Bligh
2003-04-25 18:49 ` 2.5.68-mm2 Martin J. Bligh
2003-04-26 10:34 ` 2.5.68-mm2 Bill Davidsen
2003-04-26 10:34 ` 2.5.68-mm2 Bill Davidsen
2003-04-26 15:34 ` 2.5.68-mm2 Martin J. Bligh
2003-04-26 15:34 ` 2.5.68-mm2 Martin J. Bligh
2003-05-01 6:19 ` [BUG] 2.5.68-mm2 and list.h Alexander Hoogerhuis
2003-05-01 6:19 ` Alexander Hoogerhuis
2003-05-01 6:31 ` Andrew Morton
2003-05-01 6:31 ` Andrew Morton
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=20030423095926.GJ8931@holomorphy.com \
--to=wli@holomorphy.com \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rml@tech9.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.