]> git.baikalelectronics.ru Git - kernel.git/commit
sbitmap: ammortize cost of clearing bits
authorJens Axboe <axboe@kernel.dk>
Fri, 30 Nov 2018 20:18:06 +0000 (13:18 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 30 Nov 2018 21:47:45 +0000 (14:47 -0700)
commitadc0132cb100567bece1d2a60d9f9781fb05d2bf
tree08926009b00df1229668f131d41d2b467a78cc87
parent2291bd03ca05dca56b6d0c93c5559e424b082876
sbitmap: ammortize cost of clearing bits

sbitmap maintains a set of words that we use to set and clear bits, with
each bit representing a tag for blk-mq. Even though we spread the bits
out and maintain a hint cache, one particular bit allocated will end up
being cleared in the exact same spot.

This introduces batched clearing of bits. Instead of clearing a given
bit, the same bit is set in a cleared/free mask instead. If we fail
allocating a bit from a given word, then we check the free mask, and
batch move those cleared bits at that time. This trades 64 atomic bitops
for 2 cmpxchg().

In a threaded poll test case, half the overhead of getting and clearing
tags is removed with this change. On another poll test case with a
single thread, performance is unchanged.

Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/sbitmap.h
lib/sbitmap.c