]> Git Repo - linux.git/commitdiff
sbitmap: Protect swap_lock from hardirq
authorMing Lei <[email protected]>
Tue, 15 Jan 2019 03:59:52 +0000 (11:59 +0800)
committerLinus Torvalds <[email protected]>
Tue, 15 Jan 2019 04:29:57 +0000 (16:29 +1200)
Because we may call blk_mq_get_driver_tag() directly from
blk_mq_dispatch_rq_list() without holding any lock, then HARDIRQ may
come and the above DEADLOCK is triggered.

Commit ab53dcfb3e7b ("sbitmap: Protect swap_lock from hardirq") tries to
fix this issue by using 'spin_lock_bh', which isn't enough because we
complete request from hardirq context direclty in case of multiqueue.

Cc: Clark Williams <[email protected]>
Fixes: ab53dcfb3e7b ("sbitmap: Protect swap_lock from hardirq")
Cc: Jens Axboe <[email protected]>
Cc: Ming Lei <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
lib/sbitmap.c

index 864354000e04d65f12e9586a6cf80cad463a7117..5b382c1244ede33c14016142ac2d7fec4d0608da 100644 (file)
@@ -27,8 +27,9 @@ static inline bool sbitmap_deferred_clear(struct sbitmap *sb, int index)
 {
        unsigned long mask, val;
        bool ret = false;
+       unsigned long flags;
 
-       spin_lock_bh(&sb->map[index].swap_lock);
+       spin_lock_irqsave(&sb->map[index].swap_lock, flags);
 
        if (!sb->map[index].cleared)
                goto out_unlock;
@@ -49,7 +50,7 @@ static inline bool sbitmap_deferred_clear(struct sbitmap *sb, int index)
 
        ret = true;
 out_unlock:
-       spin_unlock_bh(&sb->map[index].swap_lock);
+       spin_unlock_irqrestore(&sb->map[index].swap_lock, flags);
        return ret;
 }
 
This page took 0.095486 seconds and 4 git commands to generate.