[ovs-dev] [rwlock 0/5] Do not take rwlocks recursively for read

Ben Pfaff blp at nicira.com
Thu Jan 16 18:07:28 UTC 2014


POSIX allows taking a rwlock recursively for read to deadlock if there
are threads waiting for the write lock.  NetBSD does this.  glibc gives one
a nasty tradeoff: either deadlock on recursive read lock attempts in the
presence of a writer, or lose fairness.  Since we know that we can't avoid
deadlocks for readers in the general case anyway, this series fixes code
that tried to take recursive read locks and then switches glibc so that we
get fairness for writers.

Ben Pfaff (5):
  ofproto-dpif-monitor: Change global rwlock into mutex.
  netdev: Change netdev_class_rwlock to recursive mutex, for POSIX
    safety.
  ofproto-dpif-xlate: Avoid recursively taking read side of ofgroup
    rwlock.
  ovs-thread: Get rid of obsolete sparse wrappers.
  ovs-thread: Use fair (but nonrecursive) rwlocks on glibc.

 lib/netdev.c                   |   63 ++++++++++++++++++++--------------------
 lib/ovs-thread.c               |   14 +++++++++
 lib/ovs-thread.h               |   36 +++++++++++++++--------
 ofproto/ofproto-dpif-monitor.c |   34 +++++++++++-----------
 ofproto/ofproto-dpif-xlate.c   |   32 +++++++++++++++++++-
 5 files changed, 118 insertions(+), 61 deletions(-)

-- 
1.7.10.4




More information about the dev mailing list