diff options
| author | Ming Lei <ming.lei@redhat.com> | 2024-09-19 10:17:09 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-10-04 16:29:38 +0200 |
| commit | 54fd87259c8520187e3b9b3d1f18bf6a91c0a993 (patch) | |
| tree | 3f74a3734fd297582be024d8357de1c54188ba07 /lib | |
| parent | 93773e4461978d30b8b90e4390e0fee2f397160b (diff) | |
| download | linux-54fd87259c8520187e3b9b3d1f18bf6a91c0a993.tar.gz linux-54fd87259c8520187e3b9b3d1f18bf6a91c0a993.tar.bz2 linux-54fd87259c8520187e3b9b3d1f18bf6a91c0a993.zip | |
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@vivo.com>
Fixes: 72d04bdcf3f7 ("sbitmap: fix io hung due to race on sbitmap_word::cleared")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Yang Yang <yang.yang@vivo.com>
Link: https://lore.kernel.org/r/20240919021709.511329-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbitmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 9307bf17a817..1d5e15748692 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; } |
