Skip to content

Commit 95a301e

Browse files
lorenzo-stoakesakpm00
authored andcommitted
mm/vmalloc: do not output a spurious warning when huge vmalloc() fails
In __vmalloc_area_node() we always warn_alloc() when an allocation performed by vm_area_alloc_pages() fails unless it was due to a pending fatal signal. However, huge page allocations instigated either by vmalloc_huge() or __vmalloc_node_range() (or a caller that invokes this like kvmalloc() or kvmalloc_node()) always falls back to order-0 allocations if the huge page allocation fails. This renders the warning useless and noisy, especially as all callers appear to be aware that this may fallback. This has already resulted in at least one bug report from a user who was confused by this (see link). Therefore, simply update the code to only output this warning for order-0 pages when no fatal signal is pending. Link: https://bugzilla.suse.com/show_bug.cgi?id=1211410 Link: https://lkml.kernel.org/r/[email protected] Fixes: 80b1d8f ("mm: vmalloc: correct use of __GFP_NOWARN mask in __vmalloc_area_node()") Signed-off-by: Lorenzo Stoakes <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Reviewed-by: Baoquan He <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Uladzislau Rezki (Sony) <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 77795f9 commit 95a301e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

mm/vmalloc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,11 +3098,20 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
30983098
* allocation request, free them via vfree() if any.
30993099
*/
31003100
if (area->nr_pages != nr_small_pages) {
3101-
/* vm_area_alloc_pages() can also fail due to a fatal signal */
3102-
if (!fatal_signal_pending(current))
3101+
/*
3102+
* vm_area_alloc_pages() can fail due to insufficient memory but
3103+
* also:-
3104+
*
3105+
* - a pending fatal signal
3106+
* - insufficient huge page-order pages
3107+
*
3108+
* Since we always retry allocations at order-0 in the huge page
3109+
* case a warning for either is spurious.
3110+
*/
3111+
if (!fatal_signal_pending(current) && page_order == 0)
31033112
warn_alloc(gfp_mask, NULL,
3104-
"vmalloc error: size %lu, page order %u, failed to allocate pages",
3105-
area->nr_pages * PAGE_SIZE, page_order);
3113+
"vmalloc error: size %lu, failed to allocate pages",
3114+
area->nr_pages * PAGE_SIZE);
31063115
goto fail;
31073116
}
31083117

0 commit comments

Comments
 (0)