From: Chris Mason <mason@suse.com>
To: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH] race in mempool_alloc/free
Date: Thu, 11 Mar 2004 15:39:04 -0500 [thread overview]
Message-ID: <1079037543.27197.50.camel@watt.suse.com> (raw)
Hello everyone,
mempool_alloc and mempool_free check pool->curr_nr without any locks
held. This can lead to skipping a wakeup when there are people waiting,
and sleeping when there are free elements in the pool.
I can't trigger this reliably, but sooner or later someone on ppc is
probably going to hit it.
-chris
--- linux.t.orig/mm/mempool.c 2004-03-11 14:34:50.000000000 -0500
+++ linux.t/mm/mempool.c 2004-03-11 14:38:30.000000000 -0500
@@ -203,6 +203,7 @@
* If the pool is less than 50% full and we can perform effective
* page reclaim then try harder to allocate an element.
*/
+ mb();
if ((gfp_mask & __GFP_FS) && (gfp_mask != gfp_nowait) &&
(pool->curr_nr <= pool->min_nr/2)) {
element = pool->alloc(gfp_mask, pool->pool_data);
@@ -230,6 +231,7 @@
blk_run_queues();
prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
+ mb();
if (!pool->curr_nr)
io_schedule();
finish_wait(&pool->wait, &wait);
@@ -250,6 +252,7 @@
{
unsigned long flags;
+ mb();
if (pool->curr_nr < pool->min_nr) {
spin_lock_irqsave(&pool->lock, flags);
if (pool->curr_nr < pool->min_nr) {
reply other threads:[~2004-03-11 20:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1079037543.27197.50.camel@watt.suse.com \
--to=mason@suse.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®