Skip to contentSkip to conversation

sbitmap: remove unnecessary code in __sbitmap_queue_get_batch

RFC PATCH Applied Liu Song 2 participants 2 messages Aug 26, 2022

Subsystems (2)
lore
Share & tools
lore

Liu Song

author
#0 lore raw

RFC PATCH 1/1 sbitmap: remove unnecessary code in __sbitmap_queue_get_batch

From: Liu Song <[email protected]>

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.

---
 lib/sbitmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/sbitmap.c +2 -3
index 29eb048..34c904b 100644
@@ -533,10 +533,9 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,
 		nr = find_first_zero_bit(&map->word, map_depth);
 		if (nr + nr_tags <= map_depth) {
 			atomic_long_t *ptr = (atomic_long_t *) &map->word;
-			int map_tags = min_t(int, nr_tags, map_depth);
 			unsigned long val, ret;
 
-			get_mask = ((1UL << map_tags) - 1) << nr;
+			get_mask = ((1UL << nr_tags) - 1) << nr;
 			do {
 				val = READ_ONCE(map->word);
 				if ((val & ~get_mask) != val)
@@ -547,7 +546,7 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags,
 			if (get_mask) {
 				*offset = nr + (index << sb->shift);
 				update_alloc_hint_after_get(sb, depth, hint,
-							*offset + map_tags - 1);
+							*offset + nr_tags - 1);
 				return get_mask;
 			}
 		}
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Liu Song

From: Liu Song <[email protected]>

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.

Applied, thanks!

[1/1] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch

      commit: ddbfc34fcf5d0bc33b006b90c580c56edeb31068

Best regards,

Signature · 1 line
Jens Axboe