On Sep 4, 2013, at 12:37 PM, Ethan Jackson <et...@nicira.com> wrote: … > @@ -240,15 +242,18 @@ struct rule { > struct heap_node evg_node; /* In eviction_group's "rules" heap. */ > struct eviction_group *eviction_group; /* NULL if not in any group. */ > > - /* The evict lock is used to prevent rules from being evicted while child > - * threads are using them to xlate flows. A read lock means the rule is > - * currently being used. A write lock means the rule is in the process > of > - * being evicted and should be considered gone. A rule will not be > evicted > - * unless both its own and its classifiers write locks are held. > - * Therefore, while holding a classifier readlock, one can be assured > that > - * even write locked rules are safe. */ > - struct ovs_rwlock evict; > + /* The rwlock is used to protect those elements in struct rule which are > + * accessed by multiple threads. While maintaing a pointer to struct > rule, > + * threads are requires to hold a readlock. The main ofproto code is > + * guarnated not to evict the rule, or change any of the elements > "Guarded
/s/guarnated/guaranteed/ > + * by rwlock" without holding the writelock. > + * > + * A rule will not be evicted unless both its own and its classifier's > + * write locks are held. Therefore, while holding a classifier readlock, > + * one can be assured that ewrite locked rules are safe to reference. */ /s/ewrite/write/ > + struct ovs_rwlock rwlock; > > + /* Guarded by rwlock. */ > struct ofpact *ofpacts; /* Sequence of "struct ofpacts". */ > unsigned int ofpacts_len; /* Size of 'ofpacts', in bytes. */ > ... > @@ -2847,7 +2847,9 @@ ofproto_rule_change_cookie(struct ofproto *ofproto, > struct rule *rule, > if (new_cookie != rule->flow_cookie) { > cookies_remove(ofproto, rule); > > + ovs_rwlock_wrlock(&rule->rwlock); > rule->flow_cookie = new_cookie; > + ovs_rwlock_unlock(&rule->rwlock); > Is this necessary on 64-bit systems? > cookies_insert(ofproto, rule); > } > Jarno _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev