Skip to content

Commit ddbfc34

Browse files
ifishlandaxboe
authored andcommitted
sbitmap: remove unnecessary code in __sbitmap_queue_get_batch
If "nr + nr_tags <= map_depth", then the value of nr_tags will not be greater than map_depth, so no additional comparison is required. Signed-off-by: Liu Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f2cc648 commit ddbfc34

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/sbitmap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,9 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,
533533
nr = find_first_zero_bit(&map->word, map_depth);
534534
if (nr + nr_tags <= map_depth) {
535535
atomic_long_t *ptr = (atomic_long_t *) &map->word;
536-
int map_tags = min_t(int, nr_tags, map_depth);
537536
unsigned long val, ret;
538537

539-
get_mask = ((1UL << map_tags) - 1) << nr;
538+
get_mask = ((1UL << nr_tags) - 1) << nr;
540539
do {
541540
val = READ_ONCE(map->word);
542541
if ((val & ~get_mask) != val)
@@ -547,7 +546,7 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,
547546
if (get_mask) {
548547
*offset = nr + (index << sb->shift);
549548
update_alloc_hint_after_get(sb, depth, hint,
550-
*offset + map_tags - 1);
549+
*offset + nr_tags - 1);
551550
return get_mask;
552551
}
553552
}

0 commit comments

Comments
 (0)