Skip to content

Commit

Permalink
dpif-netdev: Group statistics updates in the slow path.
Browse files Browse the repository at this point in the history
Since statistics updates might require locking (in future commits)
grouping them will reduce the locking overhead.

Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Ethan Jackson <[email protected]>
  • Loading branch information
ddiproietto authored and ejj committed Apr 9, 2015
1 parent b13c944 commit 60fc3b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2701,10 +2701,6 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_,
{
struct dp_netdev *dp = pmd->dp;

if (type == DPIF_UC_MISS) {
dp_netdev_count_packet(pmd, DP_STAT_MISS, 1);
}

if (OVS_UNLIKELY(!dp->upcall_cb)) {
return ENODEV;
}
Expand Down Expand Up @@ -2916,6 +2912,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
if (OVS_UNLIKELY(any_miss) && !fat_rwlock_tryrdlock(&dp->upcall_rwlock)) {
uint64_t actions_stub[512 / 8], slow_stub[512 / 8];
struct ofpbuf actions, put_actions;
int miss_cnt = 0, lost_cnt = 0;
ovs_u128 ufid;

ofpbuf_use_stub(&actions, actions_stub, sizeof actions_stub);
Expand All @@ -2940,6 +2937,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
continue;
}

miss_cnt++;

miniflow_expand(&keys[i].mf, &match.flow);

ofpbuf_clear(&actions);
Expand All @@ -2951,7 +2950,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
&put_actions);
if (OVS_UNLIKELY(error && error != ENOSPC)) {
dp_packet_delete(packets[i]);
dp_netdev_count_packet(pmd, DP_STAT_LOST, 1);
lost_cnt++;
continue;
}

Expand Down Expand Up @@ -2985,6 +2984,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
ofpbuf_uninit(&actions);
ofpbuf_uninit(&put_actions);
fat_rwlock_unlock(&dp->upcall_rwlock);
dp_netdev_count_packet(pmd, DP_STAT_MISS, miss_cnt);
dp_netdev_count_packet(pmd, DP_STAT_LOST, lost_cnt);
} else if (OVS_UNLIKELY(any_miss)) {
int dropped_cnt = 0;

Expand Down

0 comments on commit 60fc3b7

Please sign in to comment.