On 12/9/18 11:01 AM, Guenter Roeck wrote: > On 12/9/18 9:50 AM, Jens Axboe wrote: >> On 12/9/18 9:58 AM, Guenter Roeck wrote: >>> On Sun, Dec 09, 2018 at 07:26:47AM -0700, Jens Axboe wrote: >>>> >>>> Ming that lockdep spews the following trace. What this essentially says >>>> is that the sbitmap swap_lock was used inconsistently in IRQ enabled >>>> and disabled context, and that is usually indicative of a bug that will >>>> cause a deadlock. >>>> >>>> For this case, it's a false positive. The swap_lock is used from process >>>> context only, when we swap the bits in the word and cleared mask. We >>>> also end up doing that when we are getting a driver tag, from the >>>> blk_mq_mark_tag_wait(), and from there we hold the waitqueue lock with >>>> IRQs disabled. However, this isn't from an actual IRQ, it's still >>>> process context. >>>> >>>> Mark the swap_lock as not needing validation to silence this warning. >>>> >>> >>> checkpatch says: >>> >>> $ scripts/checkpatch.pl jens2 >>> ERROR: lockdep_no_validate class is reserved for device->mutex. >>> #357: FILE: lib/sbitmap.c:68: >>> + lockdep_set_novalidate_class(&sb->map[i].swap_lock); >>> >>> ... which I think explains the warning I am seeing with this patch applied. >> >> Try the other patch I sent out earlier, that should work. >> > > Ok, I am lost. No idea which patch you refer to. I'll just wait for the problem > to disappear from -next, or report it again if it shows up in mainline. This one, sent out this morning in this thread: diff --git a/lib/sbitmap.c b/lib/sbitmap.c index a89fbe7cf6ca..23da156f7a17 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -118,8 +118,13 @@ static int __sbitmap_get_word(unsigned long *word, unsigned long depth, static inline bool sbitmap_deferred_clear(struct sbitmap *sb, int index) { unsigned long mask, val; + unsigned long flags; bool ret = false; + /* Silence bogus lockdep warning */ +#if defined(CONFIG_LOCKDEP) + local_irq_save(flags); +#endif spin_lock(&sb->map[index].swap_lock); if (!sb->map[index].cleared) @@ -142,6 +147,9 @@ 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 return ret; } -- Jens Axboe