Patch "sbitmap: remove unnecessary calculation of alloc_hint in __sbitmap_get_shallow" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sbitmap: remove unnecessary calculation of alloc_hint in __sbitmap_get_shallow

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sbitmap-remove-unnecessary-calculation-of-alloc_hint.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6538f7505eb85f6a39127f3decc66b3b072058a3
Author: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Date:   Tue Jan 17 04:50:55 2023 +0800

    sbitmap: remove unnecessary calculation of alloc_hint in __sbitmap_get_shallow
    
    [ Upstream commit f1591a8bb3e02713f4ee2efe20df0d84ed80da48 ]
    
    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@xxxxxxx>
    Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230116205059.3821738-2-shikemeng@xxxxxxxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Stable-dep-of: 72d04bdcf3f7 ("sbitmap: fix io hung due to race on sbitmap_word::cleared")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index c515072eca296..b9dd0a0a28f89 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -243,6 +243,7 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
 	int nr = -1;
 
 	index = SB_NR_TO_INDEX(sb, alloc_hint);
+	alloc_hint = SB_NR_TO_BIT(sb, alloc_hint);
 
 	for (i = 0; i < sb->map_nr; i++) {
 again:
@@ -250,7 +251,7 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
 					min_t(unsigned int,
 					      __map_depth(sb, index),
 					      shallow_depth),
-					SB_NR_TO_BIT(sb, alloc_hint), true);
+					alloc_hint, true);
 		if (nr != -1) {
 			nr += index << sb->shift;
 			break;
@@ -260,13 +261,9 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
 			goto again;
 
 		/* Jump to next index. */
-		index++;
-		alloc_hint = index << sb->shift;
-
-		if (index >= sb->map_nr) {
+		alloc_hint = 0;
+		if (++index >= sb->map_nr)
 			index = 0;
-			alloc_hint = 0;
-		}
 	}
 
 	return nr;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux