Skip to content

Commit

Permalink
dpif-netdev: Take the classifier rdlock once per batch.
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Jackson <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
ejj committed Jun 30, 2014
1 parent 567bbb2 commit 06861de
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,15 +1073,13 @@ dp_netdev_flow_cast(const struct cls_rule *cr)

static struct dp_netdev_flow *
dp_netdev_lookup_flow(const struct dp_netdev *dp, const struct miniflow *key)
OVS_EXCLUDED(dp->cls.rwlock)
OVS_REQ_RDLOCK(dp->cls.rwlock)
{
struct dp_netdev_flow *netdev_flow;
struct cls_rule *rule;

fat_rwlock_rdlock(&dp->cls.rwlock);
rule = classifier_lookup_miniflow_first(&dp->cls, key);
netdev_flow = dp_netdev_flow_cast(rule);
fat_rwlock_unlock(&dp->cls.rwlock);

return netdev_flow;
}
Expand Down Expand Up @@ -1320,7 +1318,9 @@ dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
miniflow_init(&miniflow, &flow);

ovs_mutex_lock(&dp->flow_mutex);
fat_rwlock_rdlock(&dp->cls.rwlock);
netdev_flow = dp_netdev_lookup_flow(dp, &miniflow);
fat_rwlock_unlock(&dp->cls.rwlock);
if (!netdev_flow) {
if (put->flags & DPIF_FP_CREATE) {
if (hmap_count(&dp->flow_table) < MAX_FLOWS) {
Expand Down Expand Up @@ -2080,6 +2080,7 @@ dp_netdev_input(struct dp_netdev *dp, struct dpif_packet **packets, int cnt,

miniflow_initialize(&key.flow, key.buf);

fat_rwlock_rdlock(&dp->cls.rwlock);
for (i = 0; i < cnt; i++) {
struct dp_netdev_flow *netdev_flow;
struct ofpbuf *buf = &packets[i]->ofpbuf;
Expand Down Expand Up @@ -2120,6 +2121,7 @@ dp_netdev_input(struct dp_netdev *dp, struct dpif_packet **packets, int cnt,
}
}
}
fat_rwlock_unlock(&dp->cls.rwlock);

if (batch.flow) {
packet_batch_execute(&batch, dp);
Expand Down

0 comments on commit 06861de

Please sign in to comment.