Re: Need lockdep help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 3 Dec 2007, Jarek Poplawski wrote:

> > System sleep start:
> > 		down_read(notifier-chain rwsem);
> > 		call the notifier routine
> > 			down_write(&system_sleep_in_progress_rwsem);
> > 		up_read(notifier-chain rwsem);
> > 
> > System sleep end:
> > 		down_read(notifier-chain rwsem);
> > 		call the notifier routine
> > 			up_write(&system_sleep_in_progress_rwsem);
> > 		up_read(notifier-chain rwsem);
> > 
> > This creates a lockdep violation; each rwsem in turn is locked while 
> > the other is being held.  However the only way this could lead to 
> > deadlock would be if there was already a bug in the system Power 
> > Management code (overlapping notifications).
> 
> Actually, IMHO, there is no reason for any lockdep violation:
> 
> thread #1: has down_read(A); waits for #2 to down_write(B)
> thread #2: has down_write(B); never waits for #1 to down_read(A)
> 
> So, deadlock isn't possible here. If lockdep reports something else it
> should be fixed (and you'd be right to omit lockdep until this is
> done).

I think the reasoning goes the way Arjan described.  Suppose in between
#1 and #2 there is thread #3 trying to do down_write(A) and waiting for
#1.  Then thread #2 doesn't have to wait for #1 directly, but it would
have to wait for #3.

In my case the simplest answer appears to be the replace the rwsem
with something slightly more complicated (a mutex plus a boolean flag 
-- the loss of concurrency won't matter much since it isn't on a hot 
path).

Thanks for the comment.

Alan Stern

_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux