• Yury Norov's avatar
    lib/bitmap.c: make bitmap_parselist() thread-safe and much faster · 0a5ce083
    Yury Norov authored
    Current implementation of bitmap_parselist() uses a static variable to
    save local state while setting bits in the bitmap.  It is obviously wrong
    if we assume execution in multiprocessor environment.  Fortunately, it's
    possible to rewrite this portion of code to avoid using the static
    variable.
    
    It is also possible to set bits in the mask per-range with bitmap_set(),
    not per-bit, as it is implemented now, with set_bit(); which is way
    faster.
    
    The important side effect of this change is that setting bits in this
    function from now is not per-bit atomic and less memory-ordered.  This is
    because set_bit() guarantees the order of memory accesses, while
    bitmap_set() does not.  I think that it is the advantage of the new
    approach, because the bitmap_parselist() is intended to initialise bit
    arrays, and user should protect the whole bitmap during initialisation if
    needed.  So protecting individual bits looks expensive and useless.  Also,
    other range...
    0a5ce083
bitmap.c 36.4 KB