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 00:43:56 +0000 (17:43 -0700)
commitc7c9a7c8ba4bb5b77d1e2f60975317aa8b3d252e
treefc651aa8db35691a6bac2baf48435e77838f2eee
parent2c91602834c1955a0c0acfc5103ba1d6127cc3f1
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