linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sbitmap: Consider cleared bits in sbitmap_bitmap_show()
@ 2020-07-01  8:06 John Garry
  2020-07-01 16:53 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: John Garry @ 2020-07-01  8:06 UTC (permalink / raw)
  To: axboe; +Cc: bvanassche, osandov, linux-block, linux-kernel, hare, John Garry

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>

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);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sbitmap: Consider cleared bits in sbitmap_bitmap_show()
  2020-07-01  8:06 [PATCH] sbitmap: Consider cleared bits in sbitmap_bitmap_show() John Garry
@ 2020-07-01 16:53 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-07-01 16:53 UTC (permalink / raw)
  To: John Garry; +Cc: bvanassche, osandov, linux-block, linux-kernel, hare

On 7/1/20 2:06 AM, John Garry wrote:
> 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.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-01 16:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  8:06 [PATCH] sbitmap: Consider cleared bits in sbitmap_bitmap_show() John Garry
2020-07-01 16:53 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).