mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Lockdep violation in pcmcia
@ 2009-11-02 21:21 Alan Stern
  2009-11-02 21:38 ` Dominik Brodowski
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2009-11-02 21:21 UTC (permalink / raw)
  To: linux-pcmcia; +Cc: Kernel development list

I've been getting these warnings for a long, long time, and finally 
decided to report them:

[ 1893.033051] =============================================
[ 1893.036023] [ INFO: possible recursive locking detected ]
[ 1893.036023] 2.6.31 #2
[ 1893.036023] ---------------------------------------------
[ 1893.036023] cardmgr/1457 is trying to acquire lock:
[ 1893.036023]  (pcmcia_socket_list_rwsem){++++.+}, at: [<c8874867>] adjust_memory+0x71/0xbd [rsrc_nonstatic]
[ 1893.036023]
[ 1893.036023] but task is already holding lock:
[ 1893.036023]  (pcmcia_socket_list_rwsem){++++.+}, at: [<c8972e5b>] ds_ioctl+0x282/0xa6b [pcmcia]
[ 1893.036023]
[ 1893.036023] other info that might help us debug this:
[ 1893.036023] 2 locks held by cardmgr/1457:
[ 1893.036023]  #0:  (pcmcia_socket_list_rwsem){++++.+}, at: [<c8972e5b>] ds_ioctl+0x282/0xa6b [pcmcia]
[ 1893.036023]  #1:  (rsrc_mutex){+.+.+.}, at: [<c887482f>] adjust_memory+0x39/0xbd [rsrc_nonstatic]
[ 1893.036023]
[ 1893.036023] stack backtrace:
[ 1893.036023] Pid: 1457, comm: cardmgr Not tainted 2.6.31 #2
[ 1893.036023] Call Trace:
[ 1893.036023]  [<c1040143>] __lock_acquire+0x741/0xa61
[ 1893.036023]  [<c103ed06>] ? mark_held_locks+0x3b/0x56
[ 1893.036023]  [<c10404bb>] lock_acquire+0x58/0x7a
[ 1893.036023]  [<c8874867>] ? adjust_memory+0x71/0xbd [rsrc_nonstatic]
[ 1893.036023]  [<c11c1f28>] down_read+0x2a/0x3e
[ 1893.036023]  [<c8874867>] ? adjust_memory+0x71/0xbd [rsrc_nonstatic]
[ 1893.036023]  [<c8874867>] adjust_memory+0x71/0xbd [rsrc_nonstatic]
[ 1893.036023]  [<c88747f6>] ? adjust_memory+0x0/0xbd [rsrc_nonstatic]
[ 1893.036023]  [<c8972f05>] ds_ioctl+0x32c/0xa6b [pcmcia]
[ 1893.036023]  [<c10efa65>] ? _raw_spin_trylock+0x2b/0x30
[ 1893.036023]  [<c107c077>] vfs_ioctl+0x4c/0x65
[ 1893.036023]  [<c107c58a>] do_vfs_ioctl+0x451/0x478
[ 1893.036023]  [<c1040987>] ? lock_release+0x12c/0x133
[ 1893.036023]  [<c107c5db>] sys_ioctl+0x2a/0x43
[ 1893.036023]  [<c1002a48>] sysenter_do_call+0x12/0x36

Is this problem already well known?

The cause is easy enough to track down.  In pcmcia_ioctl.c,
pcmcia_adjust_resource_info() does a down_read() on
pcmcia_socket_list_rwsem.  While holding the rwsem, one of the pathways
calls the s->resource_ops->add_mem method.  On my system this method is
realized by adjust_memory() in rsrc_nonstatic.c, which does its own
down_read() on the same rwsem -- i.e., a recursive locking attempt.

The reason lockdep warns about this behavior is that it can lead to
deadlock in the wrong circumstances, namely, if another thread were to
do a down_write() in between the two down_read() calls.

Would it be correct simply to omit the down_read() in adjust_memory()?

Alan Stern


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

* Re: Lockdep violation in pcmcia
  2009-11-02 21:21 Lockdep violation in pcmcia Alan Stern
@ 2009-11-02 21:38 ` Dominik Brodowski
  2009-11-03 15:22   ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Brodowski @ 2009-11-02 21:38 UTC (permalink / raw)
  To: Alan Stern; +Cc: linux-pcmcia, Kernel development list

Hey,

On Mon, Nov 02, 2009 at 04:21:23PM -0500, Alan Stern wrote:
> I've been getting these warnings for a long, long time, and finally 
> decided to report them:

Thanks!

> [ 1893.036023] other info that might help us debug this:
> [ 1893.036023] 2 locks held by cardmgr/1457:

Wow, cardmgr still in use... I had hoped it had already disappeared on
non-embedded systems...

> The cause is easy enough to track down.  In pcmcia_ioctl.c,
> pcmcia_adjust_resource_info() does a down_read() on
> pcmcia_socket_list_rwsem.  While holding the rwsem, one of the pathways
> calls the s->resource_ops->add_mem method.  On my system this method is
> realized by adjust_memory() in rsrc_nonstatic.c, which does its own
> down_read() on the same rwsem -- i.e., a recursive locking attempt.
> 
> The reason lockdep warns about this behavior is that it can lead to
> deadlock in the wrong circumstances, namely, if another thread were to
> do a down_write() in between the two down_read() calls.
> 
> Would it be correct simply to omit the down_read() in adjust_memory()?

No, for there are other code paths reaching adjust_memory() not holding a
(read) lock on this semaphore. As pcmcia_ioctl.c is on its way out anyways:
would you mind keeping it as it is, for a down_write() call is quite
unlikely during the only time cardmgr actually does this call (system
startup)?

Best,
	Dominik

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

* Re: Lockdep violation in pcmcia
  2009-11-02 21:38 ` Dominik Brodowski
@ 2009-11-03 15:22   ` Alan Stern
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Stern @ 2009-11-03 15:22 UTC (permalink / raw)
  To: Dominik Brodowski; +Cc: linux-pcmcia, Kernel development list

On Mon, 2 Nov 2009, Dominik Brodowski wrote:

> Hey,
> 
> On Mon, Nov 02, 2009 at 04:21:23PM -0500, Alan Stern wrote:
> > I've been getting these warnings for a long, long time, and finally 
> > decided to report them:
> 
> Thanks!
> 
> > [ 1893.036023] other info that might help us debug this:
> > [ 1893.036023] 2 locks held by cardmgr/1457:
> 
> Wow, cardmgr still in use... I had hoped it had already disappeared on
> non-embedded systems...

Yeah; this is on a very old laptop running an FC4 distribution.  I
haven't bothered to upgrade it because there's no point; the CPU speed,
the amount of RAM, and the size of the hard disk are all very limited.

But of course this doesn't affect the main point.  Lockdep violations 
shouldn't occur, no matter what userspace does.

> > The cause is easy enough to track down.  In pcmcia_ioctl.c,
> > pcmcia_adjust_resource_info() does a down_read() on
> > pcmcia_socket_list_rwsem.  While holding the rwsem, one of the pathways
> > calls the s->resource_ops->add_mem method.  On my system this method is
> > realized by adjust_memory() in rsrc_nonstatic.c, which does its own
> > down_read() on the same rwsem -- i.e., a recursive locking attempt.
> > 
> > The reason lockdep warns about this behavior is that it can lead to
> > deadlock in the wrong circumstances, namely, if another thread were to
> > do a down_write() in between the two down_read() calls.
> > 
> > Would it be correct simply to omit the down_read() in adjust_memory()?
> 
> No, for there are other code paths reaching adjust_memory() not holding a
> (read) lock on this semaphore. As pcmcia_ioctl.c is on its way out anyways:
> would you mind keeping it as it is, for a down_write() call is quite
> unlikely during the only time cardmgr actually does this call (system
> startup)?

(Actually the violation occurs during system shutdown.)

I don't mind.  It hasn't caused any problems.  I just wanted to make 
sure that it was recognized as a real issue and was being dealt with 
appropriately.

Alan Stern


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

end of thread, other threads:[~2009-11-03 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-02 21:21 Lockdep violation in pcmcia Alan Stern
2009-11-02 21:38 ` Dominik Brodowski
2009-11-03 15:22   ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®