linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kai Heng Feng <kai.heng.feng@canonical.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>, Laura Abbott <labbott@redhat.com>,
	linux-mm@kvack.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Regression after commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly")
Date: Fri, 9 Feb 2018 17:12:56 +0800	[thread overview]
Message-ID: <2DB8D5E5-0955-47CF-A142-09A5BA71DF70@canonical.com> (raw)
In-Reply-To: <20180209040814.GA23828@bombadil.infradead.org>

Hi Matthew,

> On Feb 9, 2018, at 12:08 PM, Matthew Wilcox <willy@infradead.org> wrote:
> Alternatively, try this.  It passes in GFP_DMA32 from vmalloc_32,
> regardless of whether ZONE_DMA32 exists or not.  If ZONE_DMA32 doesn't
> exist, then we clear it in __vmalloc_area_node(), after using it to
> determine that we shouldn't set __GFP_HIGHMEM.

IIUC, I need to let drivers/media drivers start using vmalloc_32() with  
your patch, right?

Kai-Heng

>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 673942094328..91e8a95123c4 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1669,10 +1669,11 @@ static void *__vmalloc_area_node(struct vm_struct  
> *area, gfp_t gfp_mask,
>  	struct page **pages;
>  	unsigned int nr_pages, array_size, i;
>  	const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
> -	const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
> -	const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
> -					0 :
> -					__GFP_HIGHMEM;
> +	gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
> +	if (!(alloc_mask & GFP_ZONEMASK))
> +		alloc_mask |= __GFP_HIGHMEM;
> +	if (!IS_ENABLED(CONFIG_ZONE_DMA32) && (alloc_mask & __GFP_DMA32))
> +		alloc_mask &= ~__GFP_DMA32;
>
>  	nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
>  	array_size = (nr_pages * sizeof(struct page *));
> @@ -1680,7 +1681,7 @@ static void *__vmalloc_area_node(struct vm_struct  
> *area, gfp_t gfp_mask,
>  	area->nr_pages = nr_pages;
>  	/* Please note that the recursion is strictly bounded. */
>  	if (array_size > PAGE_SIZE) {
> -		pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
> +		pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,
>  				PAGE_KERNEL, node, area->caller);
>  	} else {
>  		pages = kmalloc_node(array_size, nested_gfp, node);
> @@ -1696,9 +1697,9 @@ static void *__vmalloc_area_node(struct vm_struct  
> *area, gfp_t gfp_mask,
>  		struct page *page;
>
>  		if (node == NUMA_NO_NODE)
> -			page = alloc_page(alloc_mask|highmem_mask);
> +			page = alloc_page(alloc_mask);
>  		else
> -			page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
> +			page = alloc_pages_node(node, alloc_mask, 0);
>
>  		if (unlikely(!page)) {
>  			/* Successfully allocated i pages, free them in __vunmap() */
> @@ -1706,7 +1707,7 @@ static void *__vmalloc_area_node(struct vm_struct  
> *area, gfp_t gfp_mask,
>  			goto fail;
>  		}
>  		area->pages[i] = page;
> -		if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
> +		if (gfpflags_allow_blocking(gfp_mask))
>  			cond_resched();
>  	}
>
> @@ -1942,12 +1943,10 @@ void *vmalloc_exec(unsigned long size)
>  			      NUMA_NO_NODE, __builtin_return_address(0));
>  }
>
> -#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)
> -#define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL
> -#elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA)
> +#if defined(CONFIG_64BIT) && !defined(CONFIG_ZONE_DMA32)
>  #define GFP_VMALLOC32 GFP_DMA | GFP_KERNEL
>  #else
> -#define GFP_VMALLOC32 GFP_KERNEL
> +#define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL
>  #endif
>
>  /**

--
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:[~2018-02-09  9:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08  6:29 Kai Heng Feng
2018-02-08 13:06 ` Matthew Wilcox
2018-02-08 17:56   ` Laura Abbott
2018-02-08 18:18     ` Matthew Wilcox
2018-02-08 18:34       ` Laura Abbott
2018-02-08 23:20   ` Matthew Wilcox
2018-02-09  4:08     ` Matthew Wilcox
2018-02-09  9:12       ` Kai Heng Feng [this message]
2018-02-09 14:07         ` Matthew Wilcox
2018-02-11  9:26     ` Michal Hocko
2018-02-11 11:28       ` Matthew Wilcox
2018-02-11 12:05         ` Matthew Wilcox
2018-02-11 23:51           ` Matthew Wilcox
2018-02-14 14:04             ` Michal Hocko
2018-02-12  9:50         ` Michal Hocko

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=2DB8D5E5-0955-47CF-A142-09A5BA71DF70@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox