[ovs-dev] [PATCH 3/3] Locking for groups.

Ben Pfaff blp at nicira.com
Mon Sep 2 01:30:23 UTC 2013


On Fri, Aug 30, 2013 at 01:40:18PM -0700, Jarno Rajahalme wrote:
> The "groups" container is protected with a rwlock, and each group is
> protected with their own rwlock.  Whenever groups are looked up, the
> container's lock is taken.  If a group is found, the group is locked
> before the container is released, as otherwise the group might be
> deleted while the lock is being acquired.  The group's hmap_node is
> considered part of the container, and is governed by the container's
> lock.  This means that while a reader is still accessing the group,
> the hmap itself may be rebalanced, or the group may be removed from
> the container for deletion, but the group itself is not deleted as
> long as there are any readers left.
> 
> A groups lock is only locked for writing when the container's write
> lock is already held.  This prevents deadlocks where one thread is
> holding a write lock on the group, and is waiting for a write lock
> on the container, while another (reading) thread is holding a lock
> on the container and is waiting for a lock for the group.
> 
> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>

The design seems well thought out.  Thanks.  I folded this in.



More information about the dev mailing list