[ovs-dev] [threaded-learning v2 22/25] ofproto: Refactor eviction cases to use common code.

Ben Pfaff blp at nicira.com
Fri Sep 13 03:31:48 UTC 2013


On Thu, Sep 12, 2013 at 04:50:07PM -0700, Ethan Jackson wrote:
> Why don't we need to take the readlock on the classifier when we do
> classifier_count()?  Perhaps a comment would be appropriate.
> 
> Acked-by: Ethan Jackson <ethan at nicira.com>

Rebasing error.  Later on we don't need any lock here because
ofproto_mutex prevents the classifier from changing, but here we do.

I folded in the following, and I'll update the later patch that adopts
ofproto_mutex everywhere to reverse it and add
OVS_REQUIRES(ofproto_mutex) if it isn't already there.

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 5e0a487..e86f598 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3618,9 +3618,14 @@ is_flow_deletion_pending(const struct ofproto *ofproto,
 
 static bool
 should_evict_a_rule(struct oftable *table, unsigned int extra_space)
-    OVS_NO_THREAD_SAFETY_ANALYSIS
 {
-    return classifier_count(&table->cls) + extra_space > table->max_flows;
+    size_t count;
+
+    ovs_rwlock_rdlock(&table->cls.rwlock);
+    count = classifier_count(&table->cls);
+    ovs_rwlock_unlock(&table->cls.rwlock);
+
+    return count + extra_space > table->max_flows;
 }
 
 static enum ofperr




More information about the dev mailing list