mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
lib/sbitmap: define swap_lock as raw_spinlock_t
[ Upstream commit65f666c620
] 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:72d04bdcf3
("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>
This commit is contained in:
parent
4b7d16f46e
commit
61bc8a4d1f
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user