Skip to contentSkip to conversation

mm, vmalloc: Only call setup_vmalloc_vm only in __get_vm_area_node

PATCH In review Zhang Yanfei 2 participants 4 messages Jun 3, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mm, vmalloc: Only call setup_vmalloc_vm only in __get_vm_area_node

From: Zhang Yanfei <[email protected]>

Now for insert_vmalloc_vm, it only calls the two functions:
- setup_vmalloc_vm: fill vm_struct and vmap_area instances
- clear_vm_unlist: clear VM_UNLIST bit in vm_struct->flags

So in function __get_vm_area_node, if VM_UNLIST bit unset in flags, that is the else branch here, we don't need to clear VM_UNLIST bit for vm->flags since this bit is obviously not set. That is to say, we could only call setup_vmalloc_vm instead of insert_vmalloc_vm here. And then we could even remove the if test here.

---
 mm/vmalloc.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
mm/vmalloc.c +1 -10
index d365724..6580c76 100644
@@ -1367,16 +1367,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
 		return NULL;
 	}
 
-	/*
-	 * When this function is called from __vmalloc_node_range,
-	 * we add VM_UNLIST flag to avoid accessing uninitialized
-	 * members of vm_struct such as pages and nr_pages fields.
-	 * They will be set later.
-	 */
-	if (flags & VM_UNLIST)
-		setup_vmalloc_vm(area, va, flags, caller);
-	else
-		insert_vmalloc_vm(area, va, flags, caller);
+	setup_vmalloc_vm(area, va, flags, caller);
 
 	return area;
 }
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH 2/3 mm, vmalloc: Call setup_vmalloc_vm instead of insert_vmalloc_vm

From: Zhang Yanfei <[email protected]>

Here we pass flags with only VM_ALLOC bit set, it is unnecessary to call clear_vm_unlist to clear VM_UNLIST bit. So use setup_vmalloc_vm instead of insert_vmalloc_vm.

---
 mm/vmalloc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
mm/vmalloc.c +2 -2
index 6580c76..edbfad0 100644
@@ -2503,8 +2503,8 @@ found:
 
 	/* insert all vm's */
 	for (area = 0; area < nr_vms; area++)
-		insert_vmalloc_vm(vms[area], vas[area], VM_ALLOC,
-				  pcpu_get_vm_areas);
+		setup_vmalloc_vm(vms[area], vas[area], VM_ALLOC,
+				 pcpu_get_vm_areas);
 
 	kfree(vas);
 	return vms;
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

PATCH 3/3 mm, vmalloc: Remove insert_vmalloc_vm

In reply to Zhang Yanfei

From: Zhang Yanfei <[email protected]>

Now this function is nowhere used, we can remove it directly.

---
 mm/vmalloc.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
mm/vmalloc.c +0 -7
index edbfad0..e0a786d 100644
@@ -1322,13 +1322,6 @@ static void clear_vm_unlist(struct vm_struct *vm)
 	vm->flags &= ~VM_UNLIST;
 }
 
-static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
-			      unsigned long flags, const void *caller)
-{
-	setup_vmalloc_vm(vm, va, flags, caller);
-	clear_vm_unlist(vm);
-}
-
 static struct vm_struct *__get_vm_area_node(unsigned long size,
 		unsigned long align, unsigned long flags, unsigned long start,
 		unsigned long end, int node, gfp_t gfp_mask, const void *caller)
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/3
#3 lore raw
In reply to Zhang Yanfei

Hello, Zhang.

2013/6/4 Zhang Yanfei <[email protected]>:

Quoted 6 lines

From: Zhang Yanfei <[email protected]>

Now for insert_vmalloc_vm, it only calls the two functions:
- setup_vmalloc_vm: fill vm_struct and vmap_area instances
- clear_vm_unlist: clear VM_UNLIST bit in vm_struct->flags

Quoted 8 lines

So in function __get_vm_area_node, if VM_UNLIST bit unset in flags, that is the else branch here, we don't need to clear VM_UNLIST bit for vm->flags since this bit is obviously not set. That is to say, we could only call setup_vmalloc_vm instead of insert_vmalloc_vm here. And then we could even remove the if test here.

For all three patches,

Quoted 27 lines
---
 mm/vmalloc.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
mm/vmalloc.c +1 -11
index d365724..6580c76 100644
@@ -1367,16 +1367,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
                return NULL;
        }
 
-       /*
-        * When this function is called from __vmalloc_node_range,
-        * we add VM_UNLIST flag to avoid accessing uninitialized
-        * members of vm_struct such as pages and nr_pages fields.
-        * They will be set later.
-        */
-       if (flags & VM_UNLIST)
-               setup_vmalloc_vm(area, va, flags, caller);
-       else
-               insert_vmalloc_vm(area, va, flags, caller);
+       setup_vmalloc_vm(area, va, flags, caller);
 
        return area;
 }
--
Quoted 1 line

1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>