Patch "lib/sbitmap: define swap_lock as raw_spinlock_t" has been added to the 6.6-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

    lib/sbitmap: define swap_lock as raw_spinlock_t

to the 6.6-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:
     lib-sbitmap-define-swap_lock-as-raw_spinlock_t.patch
and it can be found in the queue-6.6 subdirectory.

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



commit af56b40e9b65a8e41b5b79a7306c3b8b5d7243c4
Author: Ming Lei <ming.lei@xxxxxxxxxx>
Date:   Thu Sep 19 10:17:09 2024 +0800

    lib/sbitmap: define swap_lock as raw_spinlock_t
    
    [ Upstream commit 65f666c6203600053478ce8e34a1db269a8701c9 ]
    
    When called from sbitmap_queue_get(), sbitmap_deferred_clear() may be run
    with preempt disabled. In RT kernel, spin_lock() can sleep, then warning
    of "BUG: sleeping function called from invalid context" can be triggered.
    
    Fix it by replacing it with raw_spin_lock.
    
    Cc: Yang Yang <yang.yang@xxxxxxxx>
    Fixes: 72d04bdcf3f7 ("sbitmap: fix io hung due to race on sbitmap_word::cleared")
    Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
    Reviewed-by: Yang Yang <yang.yang@xxxxxxxx>
    Link: https://lore.kernel.org/r/20240919021709.511329-1-ming.lei@xxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index c09cdcc99471e..189140bf11fc4 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -40,7 +40,7 @@ struct sbitmap_word {
 	/**
 	 * @swap_lock: serializes simultaneous updates of ->word and ->cleared
 	 */
-	spinlock_t swap_lock;
+	raw_spinlock_t swap_lock;
 } ____cacheline_aligned_in_smp;
 
 /**
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 9307bf17a8175..1d5e157486922 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -65,7 +65,7 @@ static inline bool sbitmap_deferred_clear(struct sbitmap_word *map,
 {
 	unsigned long mask, word_mask;
 
-	guard(spinlock_irqsave)(&map->swap_lock);
+	guard(raw_spinlock_irqsave)(&map->swap_lock);
 
 	if (!map->cleared) {
 		if (depth == 0)
@@ -136,7 +136,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
 	}
 
 	for (i = 0; i < sb->map_nr; i++)
-		spin_lock_init(&sb->map[i].swap_lock);
+		raw_spin_lock_init(&sb->map[i].swap_lock);
 
 	return 0;
 }




[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