linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: akpm@linux-foundation.org
From: Andrew Morton <akpm@linux-foundation.org>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, thomas.jarosch@intra2net.com
Subject: [patch 1/1] alloc_pages(): permit get_zeroed_page(GFP_ATOMIC) from interrupt context
Date: Thu, 23 Aug 2007 14:07:33 -0700	[thread overview]
Message-ID: <200708232107.l7NL7XDt026979@imap1.linux-foundation.org> (raw)

See http://bugzilla.kernel.org/show_bug.cgi?id=8928

I think it makes sense to permit a non-BUGging get_zeroed_page(GFP_ATOMIC)
from interrupt context.

We could fix this in several places, but I do think we want to keep the sanity
checks in kmap_atomic() even for non-highmem pages, so that people who are
testing new code on non-highmem machines get their bugs detected earlier.

Cc: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff -puN mm/page_alloc.c~alloc_pages-permit-get_zeroed_pagegfp_atomic-from-interrupt-context mm/page_alloc.c
--- a/mm/page_alloc.c~alloc_pages-permit-get_zeroed_pagegfp_atomic-from-interrupt-context
+++ a/mm/page_alloc.c
@@ -284,13 +284,25 @@ static inline void prep_zero_page(struct
 	int i;
 
 	VM_BUG_ON((gfp_flags & (__GFP_WAIT | __GFP_HIGHMEM)) == __GFP_HIGHMEM);
-	/*
-	 * clear_highpage() will use KM_USER0, so it's a bug to use __GFP_ZERO
-	 * and __GFP_HIGHMEM from hard or soft interrupt context.
-	 */
-	VM_BUG_ON((gfp_flags & __GFP_HIGHMEM) && in_interrupt());
-	for (i = 0; i < (1 << order); i++)
-		clear_highpage(page + i);
+	if (gfp_flags & __GFP_HIGHMEM) {
+		/*
+		 * clear_highpage() will use KM_USER0, so it's a bug to use
+		 * __GFP_ZERO and __GFP_HIGHMEM from hard or soft interrupt
+		 * context.
+		 */
+		VM_BUG_ON(in_interrupt());
+		for (i = 0; i < (1 << order); i++)
+			clear_highpage(page + i);
+	} else {
+		/*
+		 * Go direct to clear_page(), because the caller might be
+		 * performing a non-highmem GFP_ZERO allocation from interrupt
+		 * context.  kmap_atomic() will go BUG when that happens, but it
+		 * is a legitimate thing to do
+		 */
+		for (i = 0; i < (1 << order); i++)
+			clear_page(page + i);
+	}
 }
 
 /*
_

--
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:[~2007-08-23 21:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 21:07 akpm, Andrew Morton [this message]
2007-08-27 20:13 ` Christoph Lameter
2007-08-27 20:33   ` Andrew Morton
2007-08-27 21:00     ` Christoph Lameter
2007-08-27 21:04       ` Andrew Morton
2007-08-27 21:20         ` Christoph Lameter
2007-08-27 21:32           ` Christoph Lameter
2007-08-27 21:34           ` Andrew Morton
2007-08-27 21:43             ` Christoph Lameter
2007-08-27 22:11               ` Andrew Morton
2007-08-27 22:12                 ` Christoph Lameter
2007-08-27 22:45                   ` Andrew Morton
2007-08-27 23:01                     ` Christoph Lameter
2007-08-27 23:40                       ` Andrew Morton
2007-08-27 23:48                         ` Christoph Lameter

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=200708232107.l7NL7XDt026979@imap1.linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=thomas.jarosch@intra2net.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