mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
lib/classifier: Use internal mutex.
Add an internal mutex to struct cls_classifier, and reorganize classifier internal structures according to the user of each field, marking the fields that need to be protected by the mutex. This makes locking requirements easier to track, and may make lookup more memory efficient. After this patch there is some double locking, as callers are taking the fat-rwlock, and we take the mutex internally. A following patch will remove the classifier fat-rwlock, removing the (double) locking overhead. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
This commit is contained in:
@@ -529,6 +529,7 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules,
|
||||
}
|
||||
|
||||
found_rules++;
|
||||
ovs_mutex_lock(&cls->cls->mutex);
|
||||
LIST_FOR_EACH (rule, list, &head->list) {
|
||||
assert(rule->priority < prev_priority);
|
||||
assert(rule->priority <= table->max_priority);
|
||||
@@ -536,14 +537,17 @@ check_tables(const struct classifier *cls, int n_tables, int n_rules,
|
||||
prev_priority = rule->priority;
|
||||
found_rules++;
|
||||
found_dups++;
|
||||
fat_rwlock_rdlock(&cls->rwlock);
|
||||
ovs_mutex_unlock(&cls->cls->mutex);
|
||||
assert(classifier_find_rule_exactly(cls, rule->cls_rule)
|
||||
== rule->cls_rule);
|
||||
fat_rwlock_unlock(&cls->rwlock);
|
||||
ovs_mutex_lock(&cls->cls->mutex);
|
||||
}
|
||||
ovs_mutex_unlock(&cls->cls->mutex);
|
||||
}
|
||||
ovs_mutex_lock(&cls->cls->mutex);
|
||||
assert(table->max_priority == max_priority);
|
||||
assert(table->max_count == max_count);
|
||||
ovs_mutex_unlock(&cls->cls->mutex);
|
||||
}
|
||||
|
||||
assert(found_tables == cmap_count(&cls->cls->subtables_map));
|
||||
|
Reference in New Issue
Block a user