mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
classifier: Defer pvector publication.
This patch adds a new functions classifier_defer() and classifier_publish(), which control when the classifier modifications are made available to lookups. By default, all modifications are made available to lookups immediately. Modifications made after a classifier_defer() call MAY be 'deferred' for later 'publication'. A call to classifier_publish() will both publish any deferred modifications, and cause subsequent changes to to be published immediately. Currently any deferring is limited to the visibility of the subtable vector changes. pvector now processes modifications mostly in a working copy, which needs to be explicitly published with pvector_publish(). pvector_publish() sorts the working copy and removes gaps before publishing it. This change helps avoiding O(n**2) memory behavior in corner cases, where large number of rules with different masks are inserted or deleted. VMware-BZ: #1322017 Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -252,6 +252,7 @@ struct classifier {
|
||||
struct cmap partitions; /* Contains "struct cls_partition"s. */
|
||||
struct cls_trie tries[CLS_MAX_TRIES]; /* Prefix tries. */
|
||||
unsigned int n_tries;
|
||||
bool publish; /* Make changes visible to lookups? */
|
||||
};
|
||||
|
||||
/* A rule to be inserted to the classifier. */
|
||||
@@ -288,6 +289,8 @@ const struct cls_rule *classifier_replace(struct classifier *,
|
||||
const struct cls_rule *);
|
||||
const struct cls_rule *classifier_remove(struct classifier *,
|
||||
const struct cls_rule *);
|
||||
static inline void classifier_defer(struct classifier *);
|
||||
static inline void classifier_publish(struct classifier *);
|
||||
|
||||
/* Lookups. These are RCU protected and may run concurrently with modifiers
|
||||
* and each other. */
|
||||
@@ -343,4 +346,17 @@ void cls_cursor_advance(struct cls_cursor *);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static inline void
|
||||
classifier_defer(struct classifier *cls)
|
||||
{
|
||||
cls->publish = false;
|
||||
}
|
||||
|
||||
static inline void
|
||||
classifier_publish(struct classifier *cls)
|
||||
{
|
||||
cls->publish = true;
|
||||
pvector_publish(&cls->subtables);
|
||||
}
|
||||
#endif /* classifier.h */
|
||||
|
Reference in New Issue
Block a user