Skip to contentSkip to conversation

sbitmap: Consider cleared bits in sbitmap_bitmap_show()

PATCH Applied John Garry 2 participants 2 messages Jul 1, 2020

Subsystems (2)
lore
Share & tools
lore

John Garry

author
#0 lore raw

PATCH 1/1 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")
lib/sbitmap.c +3 -0
index af88d1346dd7..267aa7709416 100644
@@ -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);
 
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 6 lines · 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.

Applied, thanks.

Signature · 1 line
Jens Axboe