Skip to contentSkip to conversation

LOCKDEP warning due to ext_devt_lock

PATCH NeilBrown 2 participants 4 messages May 28, 2015 Block layer

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

Hi Keith,
I'm getting lockdep warning around use of ext_devt_lock.

[11428.266019] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As you say in
2da78092dda1 ("block: Fix dev_t minor allocation lifetime")
ext_devt_lock can be taken from call_rcu's soft-irq.
I think that means it should always use the _irq verion of spinlock.

I've been using the following patch and the LOCKDEP message are gone.

If you agree, could you forward it or something similar upstream? Thanks,
NeilBrown

block/genhd.c +6 -6
index 666e11b83983..d1338934562e 100644
@@ -422,9 +422,9 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
 	/* allocate ext devt */
 	idr_preload(GFP_KERNEL);
 
-	spin_lock(&ext_devt_lock);
+	spin_lock_irq(&ext_devt_lock);
 	idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_NOWAIT);
-	spin_unlock(&ext_devt_lock);
+	spin_unlock_irq(&ext_devt_lock);
 
 	idr_preload_end();
 	if (idx < 0)
@@ -449,9 +449,9 @@ void blk_free_devt(dev_t devt)
 		return;
 
 	if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
-		spin_lock(&ext_devt_lock);
+		spin_lock_irq(&ext_devt_lock);
 		idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
-		spin_unlock(&ext_devt_lock);
+		spin_unlock_irq(&ext_devt_lock);
 	}
 }
 
@@ -690,13 +690,13 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
 	} else {
 		struct hd_struct *part;
 
-		spin_lock(&ext_devt_lock);
+		spin_lock_irq(&ext_devt_lock);
 		part = idr_find(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
 		if (part && get_disk(part_to_disk(part))) {
 			*partno = part->partno;
 			disk = part_to_disk(part);
 		}
-		spin_unlock(&ext_devt_lock);
+		spin_unlock_irq(&ext_devt_lock);
 	}
 
 	return disk;
#1 lore raw
Quoted 10 lines · NeilBrown

Hi Keith,
I'm getting lockdep warning around use of ext_devt_lock.

[11428.266019] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As you say in
2da78092dda1 ("block: Fix dev_t minor allocation lifetime")
ext_devt_lock can be taken from call_rcu's soft-irq.
I think that means it should always use the _irq verion of spinlock.

Wouldn't spin_lock_bh() and friends suffice then?

Signature · 1 line
Jens Axboe
author
#2 lore raw
Quoted 5 lines · On Wed, 27 May 2015 21:32:21 -0600 Jens Axboe <[email protected]> wrote:
Quoted 4 lines · NeilBrown

Hi Keith,
I'm getting lockdep warning around use of ext_devt_lock.

Quoted 9 lines
Quoted 6 lines
[11428.266019] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As you say in
2da78092dda1 ("block: Fix dev_t minor allocation lifetime")
ext_devt_lock can be taken from call_rcu's soft-irq.
I think that means it should always use the _irq verion of spinlock.

Wouldn't spin_lock_bh() and friends suffice then?

Quite possibly. I've never actually used those so I don't tend to think about them. But only reflection I think they would be exactly right. I'll modify my patch for future testing.

BTW, did you get my:

[PATCH v2] block: discard bdi_unregister() in favour of bdi_destroy()

?? I haven't seen it appear in your 'block' tree.

Thanks,
NeilBrown

#3 lore raw
Quoted 21 lines · NeilBrown
Quoted 5 lines · On Wed, 27 May 2015 21:32:21 -0600 Jens Axboe <[email protected]> wrote:
Quoted 4 lines · NeilBrown

Hi Keith,
I'm getting lockdep warning around use of ext_devt_lock.

Quoted 9 lines
Quoted 6 lines
[11428.266019] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.

As you say in
2da78092dda1 ("block: Fix dev_t minor allocation lifetime")
ext_devt_lock can be taken from call_rcu's soft-irq.
I think that means it should always use the _irq verion of spinlock.

Wouldn't spin_lock_bh() and friends suffice then?

Quite possibly. I've never actually used those so I don't tend to think about them. But only reflection I think they would be exactly right. I'll modify my patch for future testing.

Quoted 5 lines

BTW, did you get my:

[PATCH v2] block: discard bdi_unregister() in favour of bdi_destroy()

?? I haven't seen it appear in your 'block' tree.

I missed that, thanks for the reminder. I've queued it up for this series.

Signature · 1 line
Jens Axboe