From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Jens Axboe <axboe@suse.de>, <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@zip.com.au>
Subject: [patch] mempool-2.5.1-D2
Date: Fri, 14 Dec 2001 20:13:49 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.33.0112142008520.14764-200000@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.33.0112141908420.12688-200000@localhost.localdomain>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 135 bytes --]
Andrew Morton noticed another bug, run_tasklist() should not be called as
TASK_UNINTERRUPTIBLE. The attached patch fixes this.
Ingo
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2026 bytes --]
--- linux/mm/mempool.c.orig Fri Dec 14 16:55:12 2001
+++ linux/mm/mempool.c Fri Dec 14 18:03:07 2001
@@ -176,7 +176,8 @@
*
* this function only sleeps if the alloc_fn function sleeps or
* returns NULL. Note that due to preallocation, this function
- * *never* fails.
+ * *never* fails when called from process contexts. (it might
+ * fail if called from an IRQ context.)
*/
void * mempool_alloc(mempool_t *pool, int gfp_mask)
{
@@ -185,7 +186,7 @@
struct list_head *tmp;
int curr_nr;
DECLARE_WAITQUEUE(wait, current);
- int gfp_nowait = gfp_mask & ~__GFP_WAIT;
+ int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
repeat_alloc:
element = pool->alloc(gfp_nowait, pool->pool_data);
@@ -196,15 +197,11 @@
* If the pool is less than 50% full then try harder
* to allocate an element:
*/
- if (gfp_mask != gfp_nowait) {
- if (pool->curr_nr <= pool->min_nr/2) {
- element = pool->alloc(gfp_mask, pool->pool_data);
- if (likely(element != NULL))
- return element;
- }
- } else
- /* we must not sleep */
- return NULL;
+ if ((gfp_mask != gfp_nowait) && (pool->curr_nr <= pool->min_nr/2)) {
+ element = pool->alloc(gfp_mask, pool->pool_data);
+ if (likely(element != NULL))
+ return element;
+ }
/*
* Kick the VM at this point.
@@ -218,19 +215,25 @@
element = tmp;
pool->curr_nr--;
spin_unlock_irqrestore(&pool->lock, flags);
-
return element;
}
+ spin_unlock_irqrestore(&pool->lock, flags);
+
+ /* We must not sleep in the GFP_ATOMIC case */
+ if (gfp_mask == gfp_nowait)
+ return NULL;
+
+ run_task_queue(&tq_disk);
+
add_wait_queue_exclusive(&pool->wait, &wait);
set_task_state(current, TASK_UNINTERRUPTIBLE);
+ spin_lock_irqsave(&pool->lock, flags);
curr_nr = pool->curr_nr;
spin_unlock_irqrestore(&pool->lock, flags);
- if (!curr_nr) {
- run_task_queue(&tq_disk);
+ if (!curr_nr)
schedule();
- }
current->state = TASK_RUNNING;
remove_wait_queue(&pool->wait, &wait);
next prev parent reply other threads:[~2001-12-14 17:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-14 13:49 [patch] mempool-2.5.1-D0 Ingo Molnar
2001-12-14 18:14 ` [patch] mempool-2.5.1-D1 Ingo Molnar
2001-12-14 19:13 ` Ingo Molnar [this message]
2001-12-14 22:27 ` [patch] mempool-2.5.1-D2 Benjamin LaHaise
2001-12-15 6:41 ` Ingo Molnar
2001-12-15 5:29 ` Benjamin LaHaise
2001-12-18 0:46 ` Pavel Machek
2001-12-15 17:50 ` Stephan von Krawczynski
2001-12-15 22:17 Ingo Molnar
2001-12-17 16:19 ` Stephan von Krawczynski
2001-12-17 20:56 ` Ingo Molnar
2001-12-17 20:44 ` Benjamin LaHaise
2001-12-17 23:57 ` Stephan von Krawczynski
2001-12-18 15:36 ` Stephan von Krawczynski
2001-12-18 16:43 ` Ingo Molnar
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=Pine.LNX.4.33.0112142008520.14764-200000@localhost.localdomain \
--to=mingo@elte.hu \
--cc=akpm@zip.com.au \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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®