Commit 92ca922f0a19145f2dcc99d84fe656fa55b52c2e

Authored by Hong zhi guo
Committed by Linus Torvalds
1 parent c2cddf9919

vmalloc: walk vmap_areas by sorted list instead of rb_next()

There's a walk by repeating rb_next to find a suitable hole.  Could be
simply replaced by walk on the sorted vmap_area_list.  More simpler and
efficient.

Mutation of the list and tree only happens in pair within
__insert_vmap_area and __free_vmap_area, under protection of
vmap_area_lock.  The patch code is also under vmap_area_lock, so the list
walk is safe, and consistent with the tree walk.

Tested on SMP by repeating batch of vmalloc anf vfree for random sizes and
rounds for hours.

Signed-off-by: Hong Zhiguo <honkiko@gmail.com>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff

... ... @@ -413,11 +413,11 @@
413 413 if (addr + size - 1 < addr)
414 414 goto overflow;
415 415  
416   - n = rb_next(&first->rb_node);
417   - if (n)
418   - first = rb_entry(n, struct vmap_area, rb_node);
419   - else
  416 + if (list_is_last(&first->list, &vmap_area_list))
420 417 goto found;
  418 +
  419 + first = list_entry(first->list.next,
  420 + struct vmap_area, list);
421 421 }
422 422  
423 423 found: