<div dir="ltr">Thanks for the review,<div><br></div><div>Tested again and applied to master, branch-2.2</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 1, 2014 at 8:36 AM, Ben Pfaff <span dir="ltr"><<a href="mailto:blp@nicira.com" target="_blank">blp@nicira.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Apr 29, 2014 at 11:06:29AM -0700, Alex Wang wrote:<br>
> Commit 6b59b543 (ovs-thread: Use fair (but nonrecursive)<br>
> rwlocks on glibc.) changed the rwlocks to nonrecursive,<br>
> writer-biased lock. It also made the following deadlock<br>
> possible.<br>
><br>
> Assume BFD is used on both end of a link. Consider the<br>
> following events:<br>
> 1. Handler at one end received the BFD control packet with<br>
> POLL flag set while holding the read lock of 'xlate_rwlock'.<br>
> Since a BFD control packet with FINAL flag set should be<br>
> sent back immediately, it calls the<br>
> ofproto_dpif_monitor_port_send_soon(), in which, it tries<br>
> to grab the 'monitor_mutex'.<br>
> 2. The main thread needs to configure the ofproto-dpif-xlate<br>
> module. It tries to grab the write lock of 'xlate_rwlock'<br>
> and is blocked by event 1.<br>
> 3. The monitor thread, after acquired the 'monitor_mutex',<br>
> wants to acquire the read lock of 'xlate_rwlock'.<br>
><br>
> Since the rwlock is now writer-biased, the attempt of acquiring<br>
> read lock in event 3 will be blocked by event 2. This will<br>
> subsequently cause the block of event 1, since monitor thread<br>
> is holding the 'monitor_mutex'. So the deadlock happens.<br>
><br>
> This commit resolves the above issue by removing the requirement of<br>
> acquiring 'monitor_mutex' in ofproto_dpif_monitor_port_send_soon().<br>
><br>
> Signed-off-by: Alex Wang <<a href="mailto:alexw@nicira.com">alexw@nicira.com</a>><br>
<br>
</div></div>Acked-by: Ben Pfaff <<a href="mailto:blp@nicira.com">blp@nicira.com</a>><br>
</blockquote></div><br></div>