Skip to content

Commit 704b862

Browse files
labbotttorvalds
authored andcommitted
mm/vmalloc.c: don't unconditonally use __GFP_HIGHMEM
Commit 19809c2 ("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 trigger a BUG in gfp_zone. Only add __GFP_HIGHMEM if we aren't using GFP_DMA/GFP_DMA32. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1482249 Link: http://lkml.kernel.org/r/20170816220705.31374-1-labbott@redhat.com Fixes: 19809c2 ("mm, vmalloc: use __GFP_HIGHMEM implicitly") Signed-off-by: Laura Abbott <labbott@redhat.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 73223e4 commit 704b862

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mm/vmalloc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,15 +1671,18 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
16711671
struct page **pages;
16721672
unsigned int nr_pages, array_size, i;
16731673
const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1674-
const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN;
1674+
const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
1675+
const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
1676+
0 :
1677+
__GFP_HIGHMEM;
16751678

16761679
nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
16771680
array_size = (nr_pages * sizeof(struct page *));
16781681

16791682
area->nr_pages = nr_pages;
16801683
/* Please note that the recursion is strictly bounded. */
16811684
if (array_size > PAGE_SIZE) {
1682-
pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,
1685+
pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
16831686
PAGE_KERNEL, node, area->caller);
16841687
} else {
16851688
pages = kmalloc_node(array_size, nested_gfp, node);
@@ -1700,17 +1703,17 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
17001703
}
17011704

17021705
if (node == NUMA_NO_NODE)
1703-
page = alloc_page(alloc_mask);
1706+
page = alloc_page(alloc_mask|highmem_mask);
17041707
else
1705-
page = alloc_pages_node(node, alloc_mask, 0);
1708+
page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
17061709

17071710
if (unlikely(!page)) {
17081711
/* Successfully allocated i pages, free them in __vunmap() */
17091712
area->nr_pages = i;
17101713
goto fail;
17111714
}
17121715
area->pages[i] = page;
1713-
if (gfpflags_allow_blocking(gfp_mask))
1716+
if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
17141717
cond_resched();
17151718
}
17161719

0 commit comments

Comments
 (0)