linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch
@ 2022-08-26  3:14 Liu Song
  2022-08-26 13:32 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Song @ 2022-08-26  3:14 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel

From: Liu Song <liusong@linux.alibaba.com>

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 <liusong@linux.alibaba.com>
---
 lib/sbitmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 29eb048..34c904b 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -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;
 			}
 		}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch
  2022-08-26  3:14 [RFC PATCH] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch Liu Song
@ 2022-08-26 13:32 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-08-26 13:32 UTC (permalink / raw)
  To: Liu Song; +Cc: linux-kernel, linux-block

On Fri, 26 Aug 2022 11:14:13 +0800, Liu Song wrote:
> From: Liu Song <liusong@linux.alibaba.com>
> 
> 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,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-26 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26  3:14 [RFC PATCH] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch Liu Song
2022-08-26 13:32 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).