Commit b136be5e0b6e8e3e4dcb6722b51bb35199b06810

Authored by Joonsoo Kim
Committed by Linus Torvalds
1 parent 6b70f7dff8

mm, vmalloc: use well-defined find_last_bit() func

Our intention in here is to find last_bit within the region to flush.
There is well-defined function, find_last_bit() for this purpose and its
performance may be slightly better than current implementation.  So change
it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

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

... ... @@ -1016,16 +1016,17 @@
1016 1016  
1017 1017 rcu_read_lock();
1018 1018 list_for_each_entry_rcu(vb, &vbq->free, free_list) {
1019   - int i;
  1019 + int i, j;
1020 1020  
1021 1021 spin_lock(&vb->lock);
1022 1022 i = find_first_bit(vb->dirty_map, VMAP_BBMAP_BITS);
1023   - while (i < VMAP_BBMAP_BITS) {
  1023 + if (i < VMAP_BBMAP_BITS) {
1024 1024 unsigned long s, e;
1025   - int j;
1026   - j = find_next_zero_bit(vb->dirty_map,
1027   - VMAP_BBMAP_BITS, i);
1028 1025  
  1026 + j = find_last_bit(vb->dirty_map,
  1027 + VMAP_BBMAP_BITS);
  1028 + j = j + 1; /* need exclusive index */
  1029 +
1029 1030 s = vb->va->va_start + (i << PAGE_SHIFT);
1030 1031 e = vb->va->va_start + (j << PAGE_SHIFT);
1031 1032 flush = 1;
... ... @@ -1034,10 +1035,6 @@
1034 1035 start = s;
1035 1036 if (e > end)
1036 1037 end = e;
1037   -
1038   - i = j;
1039   - i = find_next_bit(vb->dirty_map,
1040   - VMAP_BBMAP_BITS, i);
1041 1038 }
1042 1039 spin_unlock(&vb->lock);
1043 1040 }