linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Rik van Riel <riel@redhat.com>,
	linux-mm@kvack.org
Subject: Re: [patch] mm: fail GFP_DMA allocations when ZONE_DMA is not configured
Date: Thu, 14 Apr 2011 14:54:58 -0700	[thread overview]
Message-ID: <20110414145458.f9bb7744.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.00.1104141443260.13286@chino.kir.corp.google.com>

On Thu, 14 Apr 2011 14:46:56 -0700 (PDT)
David Rientjes <rientjes@google.com> wrote:

> The page allocator will improperly return a page from ZONE_NORMAL even 
> when __GFP_DMA is passed if CONFIG_ZONE_DMA is disabled.  The caller 
> expects DMA memory, perhaps for ISA devices with 16-bit address 
> registers, and may get higher memory resulting in undefined behavior.
> 
> This patch causes the page allocator to return NULL in such circumstances 
> with a warning emitted to the kernel log on the first occurrence.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  mm/page_alloc.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2225,6 +2225,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
>  
>  	if (should_fail_alloc_page(gfp_mask, order))
>  		return NULL;
> +#ifndef CONFIG_ZONE_DMA
> +	if (WARN_ON_ONCE(gfp_mask & __GFP_DMA))
> +		return NULL;
> +#endif

Worried.  We have a large number of drivers which use GFP_DMA and I bet
some of them didn't really need to set it, and can use DMA32 memory. 
They will now break.

What is drivers/pci/intel-iommu.c doing with GFP_DMA btw?

How commonly are people disabling ZONE_DMA?

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-04-14 21:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14 21:46 [patch] mm: fail GFP_DMA allocations when ZONE_DMA is not configured David Rientjes
2011-04-14 21:54 ` Andrew Morton [this message]
2011-05-04 19:33   ` David Rientjes

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=20110414145458.f9bb7744.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=riel@redhat.com \
    --cc=rientjes@google.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;
as well as URLs for NNTP newsgroup(s).