Skip to content

Commit 6f1201e

Browse files
committed
sbitmap: remove unnecessary calculation of alloc_hint in __sbitmap_get_shallow
jira LE-4034 Rebuild_History Non-Buildable kernel-4.18.0-553.72.1.el8_10 commit-author Kemeng Shi <shikemeng@huaweicloud.com> commit f1591a8 Updates to alloc_hint in the loop in __sbitmap_get_shallow() are mostly pointless and equivalent to setting alloc_hint to zero (because SB_NR_TO_BIT() considers only low sb->shift bits from alloc_hint). So simplify the logic. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Link: https://lore.kernel.org/r/20230116205059.3821738-2-shikemeng@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk> (cherry picked from commit f1591a8) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 5d412bc commit 6f1201e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/sbitmap.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,15 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
264264
int nr = -1;
265265

266266
index = SB_NR_TO_INDEX(sb, alloc_hint);
267+
alloc_hint = SB_NR_TO_BIT(sb, alloc_hint);
267268

268269
for (i = 0; i < sb->map_nr; i++) {
269270
again:
270271
nr = __sbitmap_get_word(&sb->map[index].word,
271272
min_t(unsigned int,
272273
__map_depth(sb, index),
273274
shallow_depth),
274-
SB_NR_TO_BIT(sb, alloc_hint), true);
275+
alloc_hint, true);
275276
if (nr != -1) {
276277
nr += index << sb->shift;
277278
break;
@@ -281,13 +282,9 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
281282
goto again;
282283

283284
/* Jump to next index. */
284-
index++;
285-
alloc_hint = index << sb->shift;
286-
287-
if (index >= sb->map_nr) {
285+
alloc_hint = 0;
286+
if (++index >= sb->map_nr)
288287
index = 0;
289-
alloc_hint = 0;
290-
}
291288
}
292289

293290
return nr;

0 commit comments

Comments
 (0)