linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Laura Abbott <labbott@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmalloc: Don't unconditonally use __GFP_HIGHMEM
Date: Thu, 17 Aug 2017 09:40:06 +0200	[thread overview]
Message-ID: <20170817074006.GC17781@dhcp22.suse.cz> (raw)
In-Reply-To: <20170816220705.31374-1-labbott@redhat.com>

On Wed 16-08-17 15:07:05, Laura Abbott wrote:
> Commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly")
> added use of __GFP_HIGHMEM for allocations. vmalloc_32 may use
> GFP_DMA/GFP_DMA32 which does not play nice with __GFP_HIGHMEM
> and will drigger a BUG in gfp_zone. Only add __GFP_HIGHMEM if

s@drigger@trigger@

> we aren't using GFP_DMA/GFP_DMA32.
>
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1482249
> Fixes: 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly")
> Signed-off-by: Laura Abbott <labbott@redhat.com>

Sorry about that. My fault! I have completely missed that VM_BUG_ON.
I was double checking that GFP_DMA|__GFP_HIGHMEM works as inteded
which is the case because DMA has always a preference. I have reached
the same conclusion for GFP_DMA32 but now that I am looking at the
GFP_ZONE_TABLE again I was wrong because we would end up in ZONE_DMA
AFAICS because bit 1 wouldn't be set.

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  mm/vmalloc.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 8698c1c86c4d..a47e3894c775 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1671,7 +1671,10 @@ 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_HIGHMEM | __GFP_NOWARN;
> +	const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
> +	const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
> +					0 :
> +					__GFP_HIGHMEM;
>  
>  	nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
>  	array_size = (nr_pages * sizeof(struct page *));
> @@ -1679,7 +1682,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|__GFP_HIGHMEM,
> +		pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
>  				PAGE_KERNEL, node, area->caller);
>  	} else {
>  		pages = kmalloc_node(array_size, nested_gfp, node);
> @@ -1700,9 +1703,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
>  		}
>  
>  		if (node == NUMA_NO_NODE)
> -			page = alloc_page(alloc_mask);
> +			page = alloc_page(alloc_mask|highmem_mask);
>  		else
> -			page = alloc_pages_node(node, alloc_mask, 0);
> +			page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
>  
>  		if (unlikely(!page)) {
>  			/* Successfully allocated i pages, free them in __vunmap() */
> @@ -1710,7 +1713,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))
> +		if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
>  			cond_resched();
>  	}
>  
> -- 
> 2.13.0
> 

-- 
Michal Hocko
SUSE Labs

--
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:[~2017-08-17  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 22:07 Laura Abbott
2017-08-17  7:40 ` Michal Hocko [this message]

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=20170817074006.GC17781@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /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