Skip to content

Commit 4b68a77

Browse files
Baoquan Heakpm00
authored andcommitted
mm/vmalloc.c: optimize to reduce arguments of alloc_vmap_area()
If called by __get_vm_area_node(), by open coding the field assignments of 'struct vm_struct *vm', and move the vm->flags and vm->caller assignments into __get_vm_area_node(), the passed in arguments 'flags' and 'caller' can be removed. This alleviates overloaded arguments passed in for alloc_vmap_area(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5c46d53 commit 4b68a77

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

mm/vmalloc.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
19441944
unsigned long align,
19451945
unsigned long vstart, unsigned long vend,
19461946
int node, gfp_t gfp_mask,
1947-
unsigned long va_flags, struct vm_struct *vm,
1948-
unsigned long flags, const void *caller)
1947+
unsigned long va_flags, struct vm_struct *vm)
19491948
{
19501949
struct vmap_node *vn;
19511950
struct vmap_area *va;
@@ -2008,8 +2007,11 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
20082007
va->vm = NULL;
20092008
va->flags = (va_flags | vn_id);
20102009

2011-
if (vm)
2012-
setup_vmalloc_vm(vm, va, flags, caller);
2010+
if (vm) {
2011+
vm->addr = (void *)va->va_start;
2012+
vm->size = va->va_end - va->va_start;
2013+
va->vm = vm;
2014+
}
20132015

20142016
vn = addr_to_node(va->va_start);
20152017

@@ -2588,8 +2590,7 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask)
25882590
va = alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE,
25892591
VMALLOC_START, VMALLOC_END,
25902592
node, gfp_mask,
2591-
VMAP_RAM|VMAP_BLOCK, NULL,
2592-
0, NULL);
2593+
VMAP_RAM|VMAP_BLOCK, NULL);
25932594
if (IS_ERR(va)) {
25942595
kfree(vb);
25952596
return ERR_CAST(va);
@@ -2947,7 +2948,7 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node)
29472948
va = alloc_vmap_area(size, PAGE_SIZE,
29482949
VMALLOC_START, VMALLOC_END,
29492950
node, GFP_KERNEL, VMAP_RAM,
2950-
NULL, 0, NULL);
2951+
NULL);
29512952
if (IS_ERR(va))
29522953
return NULL;
29532954

@@ -3086,7 +3087,10 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
30863087
if (!(flags & VM_NO_GUARD))
30873088
size += PAGE_SIZE;
30883089

3089-
va = alloc_vmap_area(size, align, start, end, node, gfp_mask, 0, area, flags, caller);
3090+
area->flags = flags;
3091+
area->caller = caller;
3092+
3093+
va = alloc_vmap_area(size, align, start, end, node, gfp_mask, 0, area);
30903094
if (IS_ERR(va)) {
30913095
kfree(area);
30923096
return NULL;

0 commit comments

Comments
 (0)