Use atomic_or() for atomic bitmaps where several threads may set bits at
the same time.
This avoids the race condition between threads loading an element,
bitwise ORing, and then storing the element.
Most bitmap users don't need atomicity so introduce new functions.
Signed-off-by: Stefan Hajnocz
On 27/11/2014 13:29, Stefan Hajnoczi wrote:
> +void bitmap_set_atomic(unsigned long *map, long start, long nr)
> +{
> +unsigned long *p = map + BIT_WORD(start);
> +const long size = start + nr;
> +int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
> +unsigned long mask_to_
On Thu, Nov 27, 2014 at 05:42:41PM +0100, Paolo Bonzini wrote:
>
>
> On 27/11/2014 13:29, Stefan Hajnoczi wrote:
> > +void bitmap_set_atomic(unsigned long *map, long start, long nr)
> > +{
> > +unsigned long *p = map + BIT_WORD(start);
> > +const long size = start + nr;
> > +int bits_