path: root/mm/vmalloc.c
diff options
authorSong Liu <>2022-04-15 09:44:10 -0700
committerLinus Torvalds <>2022-04-19 12:08:57 -0700
commit559089e0a93d44280ec3ab478830af319c56dbe3 (patch)
treeb4480a72841a160200f7ba9d3097d9db1d92cf9c /mm/vmalloc.c
parentb7f73403a3e922c20bb278ba3cfcc3c61930d82a (diff)
vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP
Huge page backed vmalloc memory could benefit performance in many cases. However, some users of vmalloc may not be ready to handle huge pages for various reasons: hardware constraints, potential pages split, etc. VM_NO_HUGE_VMAP was introduced to allow vmalloc users to opt-out huge pages. However, it is not easy to track down all the users that require the opt-out, as the allocation are passed different stacks and may cause issues in different layers. To address this issue, replace VM_NO_HUGE_VMAP with an opt-in flag, VM_ALLOW_HUGE_VMAP, so that users that benefit from huge pages could ask specificially. Also, remove vmalloc_no_huge() and add opt-in helper vmalloc_huge(). Fixes: fac54e2bfb5b ("x86/Kconfig: Select HAVE_ARCH_HUGE_VMALLOC with HAVE_ARCH_HUGE_VMAP") Link:" Reviewed-by: Christoph Hellwig <> Signed-off-by: Song Liu <> Reviewed-by: Rik van Riel <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/vmalloc.c')
1 files changed, 10 insertions, 7 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0b17498a34f1..07da85ae825b 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3095,7 +3095,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
return NULL;
- if (vmap_allow_huge && !(vm_flags & VM_NO_HUGE_VMAP)) {
+ if (vmap_allow_huge && (vm_flags & VM_ALLOW_HUGE_VMAP)) {
unsigned long size_per_node;
@@ -3262,21 +3262,24 @@ void *vmalloc(unsigned long size)
- * vmalloc_no_huge - allocate virtually contiguous memory using small pages
- * @size: allocation size
+ * vmalloc_huge - allocate virtually contiguous memory, allow huge pages
+ * @size: allocation size
+ * @gfp_mask: flags for the page level allocator
- * Allocate enough non-huge pages to cover @size from the page level
+ * Allocate enough pages to cover @size from the page level
* allocator and map them into contiguous kernel virtual space.
+ * If @size is greater than or equal to PMD_SIZE, allow using
+ * huge pages for the memory
* Return: pointer to the allocated memory or %NULL on error
-void *vmalloc_no_huge(unsigned long size)
+void *vmalloc_huge(unsigned long size, gfp_t gfp_mask)
return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
NUMA_NO_NODE, __builtin_return_address(0));
* vzalloc - allocate virtually contiguous memory with zero fill