public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reserved buffers only for PF_MEMALLOC
@ 2004-08-10 17:20 Rik van Riel
  2004-08-10 19:04 ` Marcelo Tosatti
  2004-08-10 20:16 ` Marcelo Tosatti
  0 siblings, 2 replies; 7+ messages in thread
From: Rik van Riel @ 2004-08-10 17:20 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel, Matt Domsch, Ernie Petrides


The buffer allocation path in 2.4 has a long standing bug,
where non-PF_MEMALLOC tasks can dig into the reserved pool
in get_unused_buffer_head().  The following patch makes the
reserved pool only accessible to PF_MEMALLOC tasks.

Other processes will loop in create_buffers() - the only
function that calls get_unused_buffer_head() - and will call
try_to_free_pages(GFP_NOIO), freeing any buffer heads that
have become freeable due to IO completion.

Note that PF_MEMALLOC tasks will NOT do anything inside
try_to_free_pages(), so it is needed that they are able to
dig into the reserved buffer heads while other tasks are
not.

Signed-off-by:  Rik van Riel <riel@redhat.com>

--- linux/fs/buffer.c.deadlock	2004-08-10 11:33:08.000000000 -0400
+++ linux/fs/buffer.c	2004-08-10 11:34:54.000000000 -0400
@@ -1260,8 +1260,9 @@ struct buffer_head * get_unused_buffer_h
 
 	/*
 	 * If we need an async buffer, use the reserved buffer heads.
+	 * Non-PF_MEMALLOC tasks can just loop in create_buffers().
 	 */
-	if (async) {
+	if (async && (current->flags & PF_MEMALLOC)) {
 		spin_lock(&unused_list_lock);
 		if (unused_list) {
 			bh = unused_list;


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-10-20 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-10 17:20 [PATCH] reserved buffers only for PF_MEMALLOC Rik van Riel
2004-08-10 19:04 ` Marcelo Tosatti
2004-08-10 20:42   ` Matt Domsch
2004-08-10 19:50     ` Marcelo Tosatti
2004-08-10 20:59       ` Rik van Riel
2004-08-10 20:16 ` Marcelo Tosatti
2004-10-20 14:02   ` Matt Domsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox