The patch titled Subject: mm, vmalloc: protect va->vm by vmap_area_lock has been added to the -mm tree. Its filename is mm-vmalloc-protect-va-vm-by-vmap_area_lock.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Joonsoo Kim <js1304@xxxxxxxxx> Subject: 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: Joonsoo Kim <js1304@xxxxxxxxx> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> Cc: Atsushi Kumagai <kumagai-atsushi@xxxxxxxxxxxxxxxxx> Cc: Chris Metcalf <cmetcalf@xxxxxxxxxx> Cc: Dave Anderson <anderson@xxxxxxxxxx> Cc: Eric Biederman <ebiederm@xxxxxxxxxxxx> Cc: Guan Xuetao <gxt@xxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Vivek Goyal <vgoyal@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN mm/vmalloc.c~mm-vmalloc-protect-va-vm-by-vmap_area_lock mm/vmalloc.c --- a/mm/vmalloc.c~mm-vmalloc-protect-va-vm-by-vmap_area_lock +++ a/mm/vmalloc.c @@ -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) { + spin_lock(&vmap_area_lock); 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; + spin_unlock(&vmap_area_lock); } static void insert_vmalloc_vmlist(struct vm_struct *vm) @@ -1447,6 +1449,11 @@ struct vm_struct *remove_vm_area(const v if (va && va->flags & VM_VM_AREA) { struct vm_struct *vm = va->vm; + spin_lock(&vmap_area_lock); + va->vm = NULL; + va->flags &= ~VM_VM_AREA; + spin_unlock(&vmap_area_lock); + if (!(vm->flags & VM_UNLIST)) { struct vm_struct *tmp, **p; /* _ Patches currently in -mm which might be from js1304@xxxxxxxxx are linux-next.patch mm-vmalloc-change-iterating-a-vmlist-to-find_vm_area.patch mm-vmalloc-move-get_vmalloc_info-to-vmallocc.patch mm-vmalloc-protect-va-vm-by-vmap_area_lock.patch mm-vmalloc-iterate-vmap_area_list-instead-of-vmlist-in-vread-vwrite.patch mm-vmalloc-iterate-vmap_area_list-in-get_vmalloc_info.patch mm-vmalloc-iterate-vmap_area_list-instead-of-vmlist-in-vmallocinfo.patch mm-vmalloc-export-vmap_area_list-instead-of-vmlist.patch mm-vmalloc-remove-list-management-of-vmlist-after-initializing-vmalloc.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html