diff options
author | Laura Abbott <labbott@redhat.com> | 2017-08-18 18:16:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-08-18 18:32:02 -0400 |
commit | 704b862f9efd6d4c87a8d0a344dda19bda9c6b69 (patch) | |
tree | 7e5b86e24c47e8ac8c021be6a08a705c40a134e2 | |
parent | 73223e4e2e3867ebf033a5a8eb2e5df0158ccc99 (diff) |
mm/vmalloc.c: don't unconditonally use __GFP_HIGHMEM
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
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: 19809c2da28a ("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>
-rw-r--r-- | mm/vmalloc.c | 13 |
1 files 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, | |||
1671 | struct page **pages; | 1671 | struct page **pages; |
1672 | unsigned int nr_pages, array_size, i; | 1672 | unsigned int nr_pages, array_size, i; |
1673 | const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; | 1673 | 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; | ||
1675 | 1678 | ||
1676 | nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; | 1679 | nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; |
1677 | array_size = (nr_pages * sizeof(struct page *)); | 1680 | array_size = (nr_pages * sizeof(struct page *)); |
@@ -1679,7 +1682,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, | |||
1679 | area->nr_pages = nr_pages; | 1682 | area->nr_pages = nr_pages; |
1680 | /* Please note that the recursion is strictly bounded. */ | 1683 | /* Please note that the recursion is strictly bounded. */ |
1681 | if (array_size > PAGE_SIZE) { | 1684 | 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, |
1683 | PAGE_KERNEL, node, area->caller); | 1686 | PAGE_KERNEL, node, area->caller); |
1684 | } else { | 1687 | } else { |
1685 | pages = kmalloc_node(array_size, nested_gfp, node); | 1688 | 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, | |||
1700 | } | 1703 | } |
1701 | 1704 | ||
1702 | if (node == NUMA_NO_NODE) | 1705 | if (node == NUMA_NO_NODE) |
1703 | page = alloc_page(alloc_mask); | 1706 | page = alloc_page(alloc_mask|highmem_mask); |
1704 | else | 1707 | else |
1705 | page = alloc_pages_node(node, alloc_mask, 0); | 1708 | page = alloc_pages_node(node, alloc_mask|highmem_mask, 0); |
1706 | 1709 | ||
1707 | if (unlikely(!page)) { | 1710 | if (unlikely(!page)) { |
1708 | /* Successfully allocated i pages, free them in __vunmap() */ | 1711 | /* 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, | |||
1710 | goto fail; | 1713 | goto fail; |
1711 | } | 1714 | } |
1712 | area->pages[i] = page; | 1715 | area->pages[i] = page; |
1713 | if (gfpflags_allow_blocking(gfp_mask)) | 1716 | if (gfpflags_allow_blocking(gfp_mask|highmem_mask)) |
1714 | cond_resched(); | 1717 | cond_resched(); |
1715 | } | 1718 | } |
1716 | 1719 | ||