ofproto: Replace rwlock in struct rule by a mutex.
authorBen Pfaff <blp@nicira.com>
Thu, 12 Sep 2013 07:28:49 +0000 (00:28 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 13 Sep 2013 04:25:20 +0000 (21:25 -0700)
commit5edfae025eccc1cff77e0729a63cddc3541e2fff
treebd698039940916da6c2390c62eedc063c3d8901c
parent2fe1428e36036e0f02348fc84618da300a2ab436
ofproto: Replace rwlock in struct rule by a mutex.

A rwlock is suitable when one expects long hold times so there is a need
for some parallelism for readers.  But when the lock is held briefly, it
makes more sense to use a mutex for two reasons.  First, a rwlock is more
complex than a mutex so one would expect it to be more expensive to
acquire.  Second, a rwlock is less fair than a mutex: as long as there are
any readers this blocks out writers.

At least, that's the behavior I intuitively expect, and a few looks around
the web suggest that I'm not the only one.

Previously, struct rule's rwlock was held for long periods, so using a
rwlock made sense.  Now it is held only briefly, so this commit replaces it
by a mutex.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif.c
ofproto/ofproto-provider.h
ofproto/ofproto.c