diff options
author | John Garry <john.garry@huawei.com> | 2020-07-01 16:06:25 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-07-01 10:53:00 -0600 |
commit | 6bf0eb5504529cdf50a24135e4c4442a093c06d6 (patch) | |
tree | 4205235a563d9b9558ddde2963ffce95e5f7aafc /lib/sbitmap.c | |
parent | 1008fe6dc36dd87dfd02d4307f49162f0b4f1665 (diff) | |
download | linux-6bf0eb5504529cdf50a24135e4c4442a093c06d6.tar.gz linux-6bf0eb5504529cdf50a24135e4c4442a093c06d6.tar.bz2 linux-6bf0eb5504529cdf50a24135e4c4442a093c06d6.zip |
sbitmap: Consider cleared bits in sbitmap_bitmap_show()
sbitmap works by maintaining separate bitmaps of set and cleared bits.
The set bits are cleared in a batch, to save the burden of continuously
locking the "word" map to unset.
sbitmap_bitmap_show() only shows the set bits (in "word"), which is not
too much use, so mask out the cleared bits.
Fixes: ea86ea2cdced ("sbitmap: ammortize cost of clearing bits")
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib/sbitmap.c')
-rw-r--r-- | lib/sbitmap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index af88d1346dd7..267aa7709416 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -292,8 +292,11 @@ void sbitmap_bitmap_show(struct sbitmap *sb, struct seq_file *m) for (i = 0; i < sb->map_nr; i++) { unsigned long word = READ_ONCE(sb->map[i].word); + unsigned long cleared = READ_ONCE(sb->map[i].cleared); unsigned int word_bits = READ_ONCE(sb->map[i].depth); + word &= ~cleared; + while (word_bits > 0) { unsigned int bits = min(8 - byte_bits, word_bits); |