* [PATCH] sbitmap: fix sbitmap_for_each_set()
@ 2018-12-03 22:45 Omar Sandoval
2018-12-04 0:14 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Omar Sandoval @ 2018-12-03 22:45 UTC (permalink / raw)
To: linux-block; +Cc: Jens Axboe, kernel-team
From: Omar Sandoval <osandov@fb.com>
We need to ignore bits in the cleared mask when iterating over all set
bits.
Fixes: ea86ea2cdced ("sbitmap: ammortize cost of clearing bits")
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
include/linux/sbitmap.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index 92806a2dbab7..03f50fcedc79 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -265,12 +265,14 @@ static inline void __sbitmap_for_each_set(struct sbitmap *sb,
nr = SB_NR_TO_BIT(sb, start);
while (scanned < sb->depth) {
- struct sbitmap_word *word = &sb->map[index];
- unsigned int depth = min_t(unsigned int, word->depth - nr,
+ unsigned long word;
+ unsigned int depth = min_t(unsigned int,
+ sb->map[index].depth - nr,
sb->depth - scanned);
scanned += depth;
- if (!word->word)
+ word = sb->map[index].word & ~sb->map[index].cleared;
+ if (!word)
goto next;
/*
@@ -280,7 +282,7 @@ static inline void __sbitmap_for_each_set(struct sbitmap *sb,
*/
depth += nr;
while (1) {
- nr = find_next_bit(&word->word, depth, nr);
+ nr = find_next_bit(&word, depth, nr);
if (nr >= depth)
break;
if (!fn(sb, (index << sb->shift) + nr, data))
--
2.19.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sbitmap: fix sbitmap_for_each_set()
2018-12-03 22:45 [PATCH] sbitmap: fix sbitmap_for_each_set() Omar Sandoval
@ 2018-12-04 0:14 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2018-12-04 0:14 UTC (permalink / raw)
To: Omar Sandoval, linux-block; +Cc: kernel-team
On 12/3/18 3:45 PM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> We need to ignore bits in the cleared mask when iterating over all set
> bits.
Thanks Omar, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-04 0:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 22:45 [PATCH] sbitmap: fix sbitmap_for_each_set() Omar Sandoval
2018-12-04 0:14 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.