diff mbox series

[2/3] mm/vmalloc: Use kvmalloc to allocate the table of pages

Message ID 20210510150233.1496689-2-willy@infradead.org (mailing list archive)
State New
Headers show
Series [1/3] mm/util: Add kvmalloc_node_caller | expand

Commit Message

Matthew Wilcox May 10, 2021, 3:02 p.m. UTC
If we're trying to allocate 4MB of memory, the table will be 8KiB in size
(1024 pointers * 8 bytes per pointer), which can usually be satisfied
by a kmalloc (which is significantly faster).  Instead of changing this
open-coded implementation, just use kvmalloc().

This improves the allocation speed of vmalloc(4MB) by approximately
5% in our benchmark.  It's still dominated by the 1024 calls to
alloc_pages_node(), which will be the subject of a later patch.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: David Rientjes <rientjes@google.com>
---
 mm/vmalloc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a13ac524f6ff..867c155c07e0 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2774,13 +2774,8 @@  static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 		gfp_mask |= __GFP_HIGHMEM;
 
 	/* Please note that the recursion is strictly bounded. */
-	if (array_size > PAGE_SIZE) {
-		pages = __vmalloc_node(array_size, 1, nested_gfp, node,
-					area->caller);
-	} else {
-		pages = kmalloc_node(array_size, nested_gfp, node);
-	}
-
+	pages = kvmalloc_node_caller(array_size, nested_gfp, node,
+					(unsigned long)area->caller);
 	if (!pages) {
 		free_vm_area(area);
 		warn_alloc(gfp_mask, NULL,