diff options
author | Joonsoo Kim <js1304@gmail.com> | 2013-04-29 18:07:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:34 -0400 |
commit | 4341fa454796b8a37efd5db98112524e85e7114e (patch) | |
tree | cf2814c34a2f6321529fa6e317a05c3a614f2a87 /mm/vmalloc.c | |
parent | f1c4069e1dc128dc8a851174cba2e273652e9216 (diff) |
mm, vmalloc: remove list management of vmlist after initializing vmalloc
Now, there is no need to maintain vmlist after initializing vmalloc. So
remove related code and data structure.
Signed-off-by: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmalloc.c')
-rw-r--r-- | mm/vmalloc.c | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 7e63984eb585..151da8ac53fa 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -273,10 +273,6 @@ static unsigned long cached_align; | |||
273 | 273 | ||
274 | static unsigned long vmap_area_pcpu_hole; | 274 | static unsigned long vmap_area_pcpu_hole; |
275 | 275 | ||
276 | /*** Old vmalloc interfaces ***/ | ||
277 | static DEFINE_RWLOCK(vmlist_lock); | ||
278 | static struct vm_struct *vmlist; | ||
279 | |||
280 | static struct vmap_area *__find_vmap_area(unsigned long addr) | 276 | static struct vmap_area *__find_vmap_area(unsigned long addr) |
281 | { | 277 | { |
282 | struct rb_node *n = vmap_area_root.rb_node; | 278 | struct rb_node *n = vmap_area_root.rb_node; |
@@ -318,7 +314,7 @@ static void __insert_vmap_area(struct vmap_area *va) | |||
318 | rb_link_node(&va->rb_node, parent, p); | 314 | rb_link_node(&va->rb_node, parent, p); |
319 | rb_insert_color(&va->rb_node, &vmap_area_root); | 315 | rb_insert_color(&va->rb_node, &vmap_area_root); |
320 | 316 | ||
321 | /* address-sort this list so it is usable like the vmlist */ | 317 | /* address-sort this list */ |
322 | tmp = rb_prev(&va->rb_node); | 318 | tmp = rb_prev(&va->rb_node); |
323 | if (tmp) { | 319 | if (tmp) { |
324 | struct vmap_area *prev; | 320 | struct vmap_area *prev; |
@@ -1130,6 +1126,7 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro | |||
1130 | } | 1126 | } |
1131 | EXPORT_SYMBOL(vm_map_ram); | 1127 | EXPORT_SYMBOL(vm_map_ram); |
1132 | 1128 | ||
1129 | static struct vm_struct *vmlist __initdata; | ||
1133 | /** | 1130 | /** |
1134 | * vm_area_add_early - add vmap area early during boot | 1131 | * vm_area_add_early - add vmap area early during boot |
1135 | * @vm: vm_struct to add | 1132 | * @vm: vm_struct to add |
@@ -1301,10 +1298,8 @@ static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, | |||
1301 | spin_unlock(&vmap_area_lock); | 1298 | spin_unlock(&vmap_area_lock); |
1302 | } | 1299 | } |
1303 | 1300 | ||
1304 | static void insert_vmalloc_vmlist(struct vm_struct *vm) | 1301 | static void clear_vm_unlist(struct vm_struct *vm) |
1305 | { | 1302 | { |
1306 | struct vm_struct *tmp, **p; | ||
1307 | |||
1308 | /* | 1303 | /* |
1309 | * Before removing VM_UNLIST, | 1304 | * Before removing VM_UNLIST, |
1310 | * we should make sure that vm has proper values. | 1305 | * we should make sure that vm has proper values. |
@@ -1312,22 +1307,13 @@ static void insert_vmalloc_vmlist(struct vm_struct *vm) | |||
1312 | */ | 1307 | */ |
1313 | smp_wmb(); | 1308 | smp_wmb(); |
1314 | vm->flags &= ~VM_UNLIST; | 1309 | vm->flags &= ~VM_UNLIST; |
1315 | |||
1316 | write_lock(&vmlist_lock); | ||
1317 | for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) { | ||
1318 | if (tmp->addr >= vm->addr) | ||
1319 | break; | ||
1320 | } | ||
1321 | vm->next = *p; | ||
1322 | *p = vm; | ||
1323 | write_unlock(&vmlist_lock); | ||
1324 | } | 1310 | } |
1325 | 1311 | ||
1326 | static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, | 1312 | static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, |
1327 | unsigned long flags, const void *caller) | 1313 | unsigned long flags, const void *caller) |
1328 | { | 1314 | { |
1329 | setup_vmalloc_vm(vm, va, flags, caller); | 1315 | setup_vmalloc_vm(vm, va, flags, caller); |
1330 | insert_vmalloc_vmlist(vm); | 1316 | clear_vm_unlist(vm); |
1331 | } | 1317 | } |
1332 | 1318 | ||
1333 | static struct vm_struct *__get_vm_area_node(unsigned long size, | 1319 | static struct vm_struct *__get_vm_area_node(unsigned long size, |
@@ -1370,10 +1356,9 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, | |||
1370 | 1356 | ||
1371 | /* | 1357 | /* |
1372 | * When this function is called from __vmalloc_node_range, | 1358 | * When this function is called from __vmalloc_node_range, |
1373 | * we do not add vm_struct to vmlist here to avoid | 1359 | * we add VM_UNLIST flag to avoid accessing uninitialized |
1374 | * accessing uninitialized members of vm_struct such as | 1360 | * members of vm_struct such as pages and nr_pages fields. |
1375 | * pages and nr_pages fields. They will be set later. | 1361 | * They will be set later. |
1376 | * To distinguish it from others, we use a VM_UNLIST flag. | ||
1377 | */ | 1362 | */ |
1378 | if (flags & VM_UNLIST) | 1363 | if (flags & VM_UNLIST) |
1379 | setup_vmalloc_vm(area, va, flags, caller); | 1364 | setup_vmalloc_vm(area, va, flags, caller); |
@@ -1462,20 +1447,6 @@ struct vm_struct *remove_vm_area(const void *addr) | |||
1462 | va->flags &= ~VM_VM_AREA; | 1447 | va->flags &= ~VM_VM_AREA; |
1463 | spin_unlock(&vmap_area_lock); | 1448 | spin_unlock(&vmap_area_lock); |
1464 | 1449 | ||
1465 | if (!(vm->flags & VM_UNLIST)) { | ||
1466 | struct vm_struct *tmp, **p; | ||
1467 | /* | ||
1468 | * remove from list and disallow access to | ||
1469 | * this vm_struct before unmap. (address range | ||
1470 | * confliction is maintained by vmap.) | ||
1471 | */ | ||
1472 | write_lock(&vmlist_lock); | ||
1473 | for (p = &vmlist; (tmp = *p) != vm; p = &tmp->next) | ||
1474 | ; | ||
1475 | *p = tmp->next; | ||
1476 | write_unlock(&vmlist_lock); | ||
1477 | } | ||
1478 | |||
1479 | vmap_debug_free_range(va->va_start, va->va_end); | 1450 | vmap_debug_free_range(va->va_start, va->va_end); |
1480 | free_unmap_vmap_area(va); | 1451 | free_unmap_vmap_area(va); |
1481 | vm->size -= PAGE_SIZE; | 1452 | vm->size -= PAGE_SIZE; |
@@ -1695,10 +1666,11 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, | |||
1695 | return NULL; | 1666 | return NULL; |
1696 | 1667 | ||
1697 | /* | 1668 | /* |
1698 | * In this function, newly allocated vm_struct is not added | 1669 | * In this function, newly allocated vm_struct has VM_UNLIST flag. |
1699 | * to vmlist at __get_vm_area_node(). so, it is added here. | 1670 | * It means that vm_struct is not fully initialized. |
1671 | * Now, it is fully initialized, so remove this flag here. | ||
1700 | */ | 1672 | */ |
1701 | insert_vmalloc_vmlist(area); | 1673 | clear_vm_unlist(area); |
1702 | 1674 | ||
1703 | /* | 1675 | /* |
1704 | * A ref_count = 3 is needed because the vm_struct and vmap_area | 1676 | * A ref_count = 3 is needed because the vm_struct and vmap_area |
@@ -2594,7 +2566,7 @@ static void show_numa_info(struct seq_file *m, struct vm_struct *v) | |||
2594 | if (!counters) | 2566 | if (!counters) |
2595 | return; | 2567 | return; |
2596 | 2568 | ||
2597 | /* Pair with smp_wmb() in insert_vmalloc_vmlist() */ | 2569 | /* Pair with smp_wmb() in clear_vm_unlist() */ |
2598 | smp_rmb(); | 2570 | smp_rmb(); |
2599 | if (v->flags & VM_UNLIST) | 2571 | if (v->flags & VM_UNLIST) |
2600 | return; | 2572 | return; |