@@ -273,10 +273,6 @@ static unsigned long cached_align;
273273
274274static unsigned long vmap_area_pcpu_hole ;
275275
276- /*** Old vmalloc interfaces ***/
277- static DEFINE_RWLOCK (vmlist_lock );
278- static struct vm_struct * vmlist ;
279-
280276static struct vmap_area * __find_vmap_area (unsigned long addr )
281277{
282278 struct rb_node * n = vmap_area_root .rb_node ;
@@ -318,7 +314,7 @@ static void __insert_vmap_area(struct vmap_area *va)
318314 rb_link_node (& va -> rb_node , parent , p );
319315 rb_insert_color (& va -> rb_node , & vmap_area_root );
320316
321- /* address-sort this list so it is usable like the vmlist */
317+ /* address-sort this list */
322318 tmp = rb_prev (& va -> rb_node );
323319 if (tmp ) {
324320 struct vmap_area * prev ;
@@ -1130,6 +1126,7 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
11301126}
11311127EXPORT_SYMBOL (vm_map_ram );
11321128
1129+ static struct vm_struct * vmlist __initdata ;
11331130/**
11341131 * vm_area_add_early - add vmap area early during boot
11351132 * @vm: vm_struct to add
@@ -1301,33 +1298,22 @@ static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
13011298 spin_unlock (& vmap_area_lock );
13021299}
13031300
1304- static void insert_vmalloc_vmlist (struct vm_struct * vm )
1301+ static void clear_vm_unlist (struct vm_struct * vm )
13051302{
1306- struct vm_struct * tmp , * * p ;
1307-
13081303 /*
13091304 * Before removing VM_UNLIST,
13101305 * we should make sure that vm has proper values.
13111306 * Pair with smp_rmb() in show_numa_info().
13121307 */
13131308 smp_wmb ();
13141309 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 );
13241310}
13251311
13261312static void insert_vmalloc_vm (struct vm_struct * vm , struct vmap_area * va ,
13271313 unsigned long flags , const void * caller )
13281314{
13291315 setup_vmalloc_vm (vm , va , flags , caller );
1330- insert_vmalloc_vmlist (vm );
1316+ clear_vm_unlist (vm );
13311317}
13321318
13331319static 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,
13701356
13711357 /*
13721358 * When this function is called from __vmalloc_node_range,
1373- * we do not add vm_struct to vmlist here to avoid
1374- * accessing uninitialized members of vm_struct such as
1375- * pages and nr_pages fields. They will be set later.
1376- * To distinguish it from others, we use a VM_UNLIST flag.
1359+ * we add VM_UNLIST flag to avoid accessing uninitialized
1360+ * members of vm_struct such as pages and nr_pages fields.
1361+ * They will be set later.
13771362 */
13781363 if (flags & VM_UNLIST )
13791364 setup_vmalloc_vm (area , va , flags , caller );
@@ -1462,20 +1447,6 @@ struct vm_struct *remove_vm_area(const void *addr)
14621447 va -> flags &= ~VM_VM_AREA ;
14631448 spin_unlock (& vmap_area_lock );
14641449
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-
14791450 vmap_debug_free_range (va -> va_start , va -> va_end );
14801451 free_unmap_vmap_area (va );
14811452 vm -> size -= PAGE_SIZE ;
@@ -1695,10 +1666,11 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
16951666 return NULL ;
16961667
16971668 /*
1698- * In this function, newly allocated vm_struct is not added
1699- * to vmlist at __get_vm_area_node(). so, it is added here.
1669+ * In this function, newly allocated vm_struct has VM_UNLIST flag.
1670+ * It means that vm_struct is not fully initialized.
1671+ * Now, it is fully initialized, so remove this flag here.
17001672 */
1701- insert_vmalloc_vmlist (area );
1673+ clear_vm_unlist (area );
17021674
17031675 /*
17041676 * 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)
25942566 if (!counters )
25952567 return ;
25962568
2597- /* Pair with smp_wmb() in insert_vmalloc_vmlist () */
2569+ /* Pair with smp_wmb() in clear_vm_unlist () */
25982570 smp_rmb ();
25992571 if (v -> flags & VM_UNLIST )
26002572 return ;
0 commit comments