struct cls_match 'list' member was recently changed to an rculist. This allows classifier_find_rule_exactly() to be made lockless.
Since subtable's 'max_priority' member would still require a lock, we no longer check it before calling find_equal(). This adds a hash table lookup in cases where the subtable may already be known to not contain any rule of the target priority. If this is deemed a significant change, we could change the 'max_priority' member to be an atomic variable so that it could be safely accessed without a lock. Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- lib/classifier.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/classifier.c b/lib/classifier.c index 0c7d5c3..35d950c 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -755,33 +755,26 @@ classifier_lookup(const struct classifier *cls, const struct flow *flow, const struct cls_rule * classifier_find_rule_exactly(const struct classifier *cls, const struct cls_rule *target) - OVS_EXCLUDED(cls->mutex) { const struct cls_match *head, *rule; const struct cls_subtable *subtable; - ovs_mutex_lock(&cls->mutex); subtable = find_subtable(cls, &target->match.mask); if (!subtable) { - goto out; - } - - /* Skip if there is no hope. */ - if (target->priority > subtable->max_priority) { - goto out; + return NULL; } head = find_equal(subtable, &target->match.flow, miniflow_hash_in_minimask(&target->match.flow, &target->match.mask, 0)); + if (!head) { + return NULL; + } FOR_EACH_RULE_IN_LIST (rule, head) { if (target->priority >= rule->priority) { - ovs_mutex_unlock(&cls->mutex); return target->priority == rule->priority ? rule->cls_rule : NULL; } } -out: - ovs_mutex_unlock(&cls->mutex); return NULL; } -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev