From: Jens Axboe <axboe@kernel.dk>
To: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Cc: Omar Sandoval <osandov@osandov.com>
Subject: sbitmap: check cleared bits when iterating busy bits
Date: Mon, 3 Dec 2018 14:56:17 -0700 [thread overview]
Message-ID: <8bde3953-56d8-32cb-2c34-582d632f4a3f@kernel.dk> (raw)
When we are iterating the set bits in a word, we also need to factor in
the cleared bits. Don't call fn() unless the bit is also not set in
the cleared word.
Fixes: ea86ea2cdced ("sbitmap: ammortize cost of clearing bits")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index 92806a2dbab7..9f374fbcdba6 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -283,6 +283,11 @@ static inline void __sbitmap_for_each_set(struct sbitmap *sb,
nr = find_next_bit(&word->word, depth, nr);
if (nr >= depth)
break;
+ /* if set in cleared, it's actually free */
+ if (test_bit(nr, &word->cleared)) {
+ nr++;
+ continue;
+ }
if (!fn(sb, (index << sb->shift) + nr, data))
return;
--
Jens Axboe
next reply other threads:[~2018-12-03 21:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 21:56 Jens Axboe [this message]
2018-12-03 22:05 ` sbitmap: check cleared bits when iterating busy bits Omar Sandoval
2018-12-03 22:20 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8bde3953-56d8-32cb-2c34-582d632f4a3f@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=osandov@osandov.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox