Skip to contentSkip to conversation

Using nested locking for spin_lock_bh

DISCUSSION Sven Eckelmann 3 participants 4 messages Mar 28, 2012 – Apr 15, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I started to run some experimental batman-adv code inside some virtual machines with different debugging functions enabled. One of them was lockdep. There we noticed a false positive for a lock class that is actually used in two different data structures. Therefore, lockdep noticed that there could be a deadlock for this class in a function that locks the two different data structures.

To resolve this problem, I wanted to define two different subclasses and replace the spin_lock_bh with its nested version. The only problem now is the absence of spin_lock_bh_nested. I could only find spin_lock_bh and spin_lock_irqsave_nested.

Is there another way how this should be done or is there a general problem why there is no nested support for this incarnation of spin_lock?

Kind regards,
Sven

#1 lore raw
Quoted 6 lines · Sven Eckelmann

Hi,

I started to run some experimental batman-adv code inside some virtual machines with different debugging functions enabled. One of them was lockdep. There we noticed a false positive for a lock class that is actually used in two different data structures.

Hmm, I think you can initialize the lock class in the two differnent data structures with differnt lock_class_key.

Thanks,
Yong

Quoted 14 lines

Therefore, lockdep noticed that there could be
a deadlock for this class in a function that locks the two different data structures.

To resolve this problem, I wanted to define two different subclasses and replace the spin_lock_bh with its nested version. The only problem now is the absence of spin_lock_bh_nested. I could only find spin_lock_bh and spin_lock_irqsave_nested.

Is there another way how this should be done or is there a general problem why there is no nested support for this incarnation of spin_lock?

Kind regards,
Sven

Signature · 1 line
Only stand for myself
#2 lore raw
Quoted 10 lines · Yong Zhang
Quoted 6 lines · Sven Eckelmann

Hi,

I started to run some experimental batman-adv code inside some virtual machines with different debugging functions enabled. One of them was lockdep. There we noticed a false positive for a lock class that is actually used in two different data structures.

Hmm, I think you can initialize the lock class in the two differnent data structures with differnt lock_class_key.

Thanks. I think I understand the problem now a little bit better and could resolve it using lockdep_set_class.

Kind regards,
Sven

#3 lore raw
In reply to Sven Eckelmann
Quoted 3 lines · Sven Eckelmann

Is there another way how this should be done or is there a general problem why there is no nested support for this incarnation of spin_lock?

No reason other than that it wasn't needed before now, but I see you've resolved things with a lockdep_set_class() which works too.