linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using nested locking for spin_lock_bh
@ 2012-03-28 16:36 Sven Eckelmann
  2012-03-29  3:11 ` Yong Zhang
  2012-04-15 11:18 ` Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Sven Eckelmann @ 2012-03-28 16:36 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, linux-kernel; +Cc: simon.wunderlich, Marek Lindner

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using nested locking for spin_lock_bh
  2012-03-28 16:36 Using nested locking for spin_lock_bh Sven Eckelmann
@ 2012-03-29  3:11 ` Yong Zhang
  2012-03-29 10:41   ` Sven Eckelmann
  2012-04-15 11:18 ` Peter Zijlstra
  1 sibling, 1 reply; 4+ messages in thread
From: Yong Zhang @ 2012-03-29  3:11 UTC (permalink / raw)
  To: Sven Eckelmann
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, simon.wunderlich,
	Marek Lindner

On Wed, Mar 28, 2012 at 06:36:39PM +0200, Sven Eckelmann wrote:
> 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

> 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



-- 
Only stand for myself

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using nested locking for spin_lock_bh
  2012-03-29  3:11 ` Yong Zhang
@ 2012-03-29 10:41   ` Sven Eckelmann
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2012-03-29 10:41 UTC (permalink / raw)
  To: Yong Zhang
  Cc: Peter Zijlstra, Ingo Molnar, linux-kernel, simon.wunderlich,
	Marek Lindner

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

On Thursday, March 29, 2012 11:11:37 AM Yong Zhang wrote:
> On Wed, Mar 28, 2012 at 06:36:39PM +0200, Sven Eckelmann wrote:
> > 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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using nested locking for spin_lock_bh
  2012-03-28 16:36 Using nested locking for spin_lock_bh Sven Eckelmann
  2012-03-29  3:11 ` Yong Zhang
@ 2012-04-15 11:18 ` Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2012-04-15 11:18 UTC (permalink / raw)
  To: Sven Eckelmann; +Cc: Ingo Molnar, linux-kernel, simon.wunderlich, Marek Lindner

On Wed, 2012-03-28 at 18:36 +0200, Sven Eckelmann wrote:
> 
> 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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-15 11:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28 16:36 Using nested locking for spin_lock_bh Sven Eckelmann
2012-03-29  3:11 ` Yong Zhang
2012-03-29 10:41   ` Sven Eckelmann
2012-04-15 11:18 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).