diff options
author | Li RongQing <roy.qing.li@gmail.com> | 2014-09-20 05:10:03 -0700 |
---|---|---|
committer | Pravin B Shelar <pshelar@nicira.com> | 2014-09-20 19:36:33 -0700 |
commit | f3e54aa79279898834f1ac3c5fc45cd1286a18d3 (patch) | |
tree | 13bef5eb250a441ad58c2df5f0c0a0b2367b1997 /datapath | |
parent | c981665a3d6cd0a2e60cf08f6a34691ba9e8f314 (diff) | |
download | openvswitch-f3e54aa79279898834f1ac3c5fc45cd1286a18d3.tar.gz |
datapath: change the data type of error status to atomic_long_t
Change the date type of error status from u64 to atomic_long_t, and use atomic
operation, then remove the lock which is used to protect the error status.
The operation of atomic maybe faster than spin lock.
Cc: Pravin Shelar <pshelar@nicira.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'datapath')
-rw-r--r-- | datapath/vport.c | 26 | ||||
-rw-r--r-- | datapath/vport.h | 13 |
2 files changed, 13 insertions, 26 deletions
diff --git a/datapath/vport.c b/datapath/vport.c index 0709c33aa..67fff6317 100644 --- a/datapath/vport.c +++ b/datapath/vport.c @@ -151,8 +151,6 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, return ERR_PTR(-ENOMEM); } - spin_lock_init(&vport->stats_lock); - return vport; } @@ -266,14 +264,10 @@ void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) * netdev-stats can be directly read over netlink-ioctl. */ - spin_lock_bh(&vport->stats_lock); - - stats->rx_errors = vport->err_stats.rx_errors; - stats->tx_errors = vport->err_stats.tx_errors; - stats->tx_dropped = vport->err_stats.tx_dropped; - stats->rx_dropped = vport->err_stats.rx_dropped; - - spin_unlock_bh(&vport->stats_lock); + stats->rx_errors = atomic_long_read(&vport->err_stats.rx_errors); + stats->tx_errors = atomic_long_read(&vport->err_stats.tx_errors); + stats->tx_dropped = atomic_long_read(&vport->err_stats.tx_dropped); + stats->rx_dropped = atomic_long_read(&vport->err_stats.rx_dropped); stats->rx_bytes = 0; stats->rx_packets = 0; @@ -516,27 +510,23 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) static void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type) { - spin_lock(&vport->stats_lock); - switch (err_type) { case VPORT_E_RX_DROPPED: - vport->err_stats.rx_dropped++; + atomic_long_inc(&vport->err_stats.rx_dropped); break; case VPORT_E_RX_ERROR: - vport->err_stats.rx_errors++; + atomic_long_inc(&vport->err_stats.rx_errors); break; case VPORT_E_TX_DROPPED: - vport->err_stats.tx_dropped++; + atomic_long_inc(&vport->err_stats.tx_dropped); break; case VPORT_E_TX_ERROR: - vport->err_stats.tx_errors++; + atomic_long_inc(&vport->err_stats.tx_errors); break; } - - spin_unlock(&vport->stats_lock); } static void free_vport_rcu(struct rcu_head *rcu) diff --git a/datapath/vport.h b/datapath/vport.h index 07a9d5d8c..a0cf3dd0f 100644 --- a/datapath/vport.h +++ b/datapath/vport.h @@ -67,13 +67,13 @@ int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, struct ovs_tunnel_info *info); /* The following definitions are for implementers of vport devices: */ - struct vport_err_stats { - u64 rx_dropped; - u64 rx_errors; - u64 tx_dropped; - u64 tx_errors; + atomic_long_t rx_dropped; + atomic_long_t rx_errors; + atomic_long_t tx_dropped; + atomic_long_t tx_errors; }; + /** * struct vport_portids - array of netlink portids of a vport. * must be protected by rcu. @@ -100,7 +100,6 @@ struct vport_portids { * @dp_hash_node: Element in @datapath->ports hash table in datapath.c. * @ops: Class structure. * @percpu_stats: Points to per-CPU statistics used and maintained by vport - * @stats_lock: Protects @err_stats. * @err_stats: Points to error statistics used and maintained by vport */ struct vport { @@ -114,8 +113,6 @@ struct vport { const struct vport_ops *ops; struct pcpu_sw_netstats __percpu *percpu_stats; - - spinlock_t stats_lock; struct vport_err_stats err_stats; }; |