[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190114122540.7a54e6f3@gandalf.local.home>
Date: Mon, 14 Jan 2019 12:25:40 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: LKML <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Clark Williams <williams@...hat.com>,
Bart Van Assche <bvanassche@....org>,
Ming Lei <ming.lei@...hat.com>
Subject: [PATCH] sbitmap: Protect swap_lock from softirqs
From: Steven Rostedt (VMware) <rostedt@...dmis.org>
The swap_lock used by sbitmap has a chain with locks taken from
softirq, but the swap_lock is not protected from being preempted by
softirqs.
A chain exists of:
sbq->ws[i].wait -> dispatch_wait_lock -> swap_lock
Where the sbq->ws[i].wait lock can be taken from softirq context, which
means all locks below it in the chain must also be protected from
softirqs.
Cc: stable@...r.kernel.org
Reported-by: Clark Williams <williams@...hat.com>
Fixes: 58ab5e32e6fd ("sbitmap: silence bogus lockdep IRQ warning")
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 65c2d06250a6..864354000e04 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -26,14 +26,9 @@
static inline bool sbitmap_deferred_clear(struct sbitmap *sb, int index)
{
unsigned long mask, val;
- unsigned long __maybe_unused flags;
bool ret = false;
- /* Silence bogus lockdep warning */
-#if defined(CONFIG_LOCKDEP)
- local_irq_save(flags);
-#endif
- spin_lock(&sb->map[index].swap_lock);
+ spin_lock_bh(&sb->map[index].swap_lock);
if (!sb->map[index].cleared)
goto out_unlock;
@@ -54,10 +49,7 @@ static inline bool sbitmap_deferred_clear(struct sbitmap *sb, int index)
ret = true;
out_unlock:
- spin_unlock(&sb->map[index].swap_lock);
-#if defined(CONFIG_LOCKDEP)
- local_irq_restore(flags);
-#endif
+ spin_unlock_bh(&sb->map[index].swap_lock);
return ret;
}
Powered by blists - more mailing lists