IB/mthca: Use non-atomic bitmap functions when possible in 'mthca_allocator.c'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 24 Nov 2021 20:42:32 +0000 (21:42 +0100)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 25 Nov 2021 17:29:06 +0000 (13:29 -0400)
The accesses to the 'alloc->table' bitmap are protected by the
'alloc->lock' spinlock, so no concurrent accesses can happen.

So prefer the non-atomic '__[set|clear]_bit()' functions to save a few
cycles.

Link: https://lore.kernel.org/r/5f909ca1284fa4d2cf13952b08b9e303b656c968.1637785902.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mthca/mthca_allocator.c

index 57fa1cc202bc303ad28be252ada56770462b81db..9f0f79d02d3c903942c654d36927c4c115bad6c2 100644 (file)
@@ -51,7 +51,7 @@ u32 mthca_alloc(struct mthca_alloc *alloc)
        }
 
        if (obj < alloc->max) {
-               set_bit(obj, alloc->table);
+               __set_bit(obj, alloc->table);
                obj |= alloc->top;
        } else
                obj = -1;
@@ -69,7 +69,7 @@ void mthca_free(struct mthca_alloc *alloc, u32 obj)
 
        spin_lock_irqsave(&alloc->lock, flags);
 
-       clear_bit(obj, alloc->table);
+       __clear_bit(obj, alloc->table);
        alloc->last = min(alloc->last, obj);
        alloc->top = (alloc->top + alloc->max) & alloc->mask;