Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/vmalloc: respect passed gfp_mask when doing preloading

Allocation functions should comply with the given gfp_mask as much as
possible. The preallocation code in alloc_vmap_area doesn't follow that
pattern and it is using a hardcoded GFP_KERNEL. Although this doesn't
really make much difference because vmalloc is not GFP_NOWAIT compliant
in general (e.g. page table allocations are GFP_KERNEL) there is no
reason to spread that bad habit and it is good to fix the antipattern.

[mhocko@suse.com: rewrite changelog]
Link: http://lkml.kernel.org/r/20191016095438.12391-2-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Uladzislau Rezki (Sony) and committed by
Linus Torvalds
f07116d7 81f1ba58

+4 -4
+4 -4
mm/vmalloc.c
··· 1063 1063 return ERR_PTR(-EBUSY); 1064 1064 1065 1065 might_sleep(); 1066 + gfp_mask = gfp_mask & GFP_RECLAIM_MASK; 1066 1067 1067 - va = kmem_cache_alloc_node(vmap_area_cachep, 1068 - gfp_mask & GFP_RECLAIM_MASK, node); 1068 + va = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); 1069 1069 if (unlikely(!va)) 1070 1070 return ERR_PTR(-ENOMEM); 1071 1071 ··· 1073 1073 * Only scan the relevant parts containing pointers to other objects 1074 1074 * to avoid false negatives. 1075 1075 */ 1076 - kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask & GFP_RECLAIM_MASK); 1076 + kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); 1077 1077 1078 1078 retry: 1079 1079 /* ··· 1099 1099 * Just proceed as it is. If needed "overflow" path 1100 1100 * will refill the cache we allocate from. 1101 1101 */ 1102 - pva = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, node); 1102 + pva = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); 1103 1103 1104 1104 spin_lock(&vmap_area_lock); 1105 1105