All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-mm <linux-mm@kvack.org>
Subject: [PATCH] mm: call into direct reclaim without PF_MEMALLOC set
Date: Wed, 15 Nov 2006 22:23:35 +0100	[thread overview]
Message-ID: <1163625815.5968.66.camel@twins> (raw)
In-Reply-To: <20061115124228.db0b42a6.akpm@osdl.org>

(Sorry about the dup Andrew, I noticed I hit the wrong reply button)

OK, so how about this?

No use running direct reclaim if we're already in there.

---

PF_MEMALLOC is also used to prevent recursion of direct reclaim.
However this invocation does not set PF_MEMALLOC nor checks it and
hence a can make it nest a single time. Either by reaching this
spot from reclaim and then calling it again or entering here and 
encountering a __GFP_WAIT alloc from within.

So check for PF_MEMALLOC and avoid a second invocation and otherwise
set PF_MEMALLOC.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/buffer.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Index: linux-2.6-git/fs/buffer.c
===================================================================
--- linux-2.6-git.orig/fs/buffer.c	2006-11-15 20:32:14.000000000 +0100
+++ linux-2.6-git/fs/buffer.c	2006-11-15 21:52:05.000000000 +0100
@@ -360,8 +360,18 @@ static void free_more_memory(void)
 
 	for_each_online_pgdat(pgdat) {
 		zones = pgdat->node_zonelists[gfp_zone(GFP_NOFS)].zones;
-		if (*zones)
+		if (*zones && !(current->flags & PF_MEMALLOC)) {
+			struct task_struct *p = current;
+			struct reclaim_state reclaim_state = { 0 };
+
+			p->flags |= PF_MEMALLOC;
+			p->reclaim_state = &reclaim_state;
+
 			try_to_free_pages(zones, GFP_NOFS);
+
+			p->reclaim_state = NULL;
+			p->flags &= ~PF_MEMALLOC;
+		}
 	}
 }
 


--
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:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2006-11-15 21:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-15 19:25 mm: call into direct reclaim without PF_MEMALLOC set Peter Zijlstra
2006-11-15 20:42 ` Andrew Morton
2006-11-15 21:23   ` Peter Zijlstra [this message]
2006-11-15 21:32     ` [PATCH] " Andrew Morton
     [not found]   ` <1163625058.5968.64.camel@twins>
     [not found]     ` <20061115132340.3cbf4008.akpm@osdl.org>
2006-11-15 21:32       ` Peter Zijlstra
2006-11-15 22:00         ` Andrew Morton
2006-11-15 22:12           ` Arjan van de Ven
2006-11-15 22:24             ` Andrew Morton
2006-11-16  9:52           ` [PATCH] mm: cleanup and document reclaim recursion Peter Zijlstra
2006-11-17  0:16             ` Andrew Morton
2006-11-17  8:31               ` Peter Zijlstra
2006-11-17 12:18               ` Peter Zijlstra

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=1163625815.5968.66.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@osdl.org \
    --cc=linux-mm@kvack.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 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.