Commit c69480ad authored by Joonsoo Kim's avatar Joonsoo Kim Committed by Linus Torvalds

mm, vmalloc: protect va->vm by vmap_area_lock

Inserting and removing an entry to vmlist is linear time complexity, so
it is inefficient.  Following patches will try to remove vmlist
entirely.  This patch is preparing step for it.

For removing vmlist, iterating vmlist codes should be changed to
iterating a vmap_area_list.  Before implementing that, we should make
sure that when we iterate a vmap_area_list, accessing to va->vm doesn't
cause a race condition.  This patch ensure that when iterating a
vmap_area_list, there is no race condition for accessing to vm_struct.
Signed-off-by: default avatarJoonsoo Kim <>
Signed-off-by: default avatarJoonsoo Kim <>
Cc: Thomas Gleixner <>
Cc: "H. Peter Anvin" <>
Cc: Atsushi Kumagai <>
Cc: Chris Metcalf <>
Cc: Dave Anderson <>
Cc: Eric Biederman <>
Cc: Guan Xuetao <>
Cc: Ingo Molnar <>
Cc: Vivek Goyal <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent db3808c1
......@@ -1290,12 +1290,14 @@ struct vm_struct *vmlist;
static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
unsigned long flags, const void *caller)
vm->flags = flags;
vm->addr = (void *)va->va_start;
vm->size = va->va_end - va->va_start;
vm->caller = caller;
va->vm = vm;
va->flags |= VM_VM_AREA;
static void insert_vmalloc_vmlist(struct vm_struct *vm)
......@@ -1447,6 +1449,11 @@ struct vm_struct *remove_vm_area(const void *addr)
if (va && va->flags & VM_VM_AREA) {
struct vm_struct *vm = va->vm;
va->vm = NULL;
va->flags &= ~VM_VM_AREA;
if (!(vm->flags & VM_UNLIST)) {
struct vm_struct *tmp, **p;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment