summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-07-07 13:18:46 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-07-07 13:22:57 -0700
commit24f8381214966e90819bf4a9ecabf076cbfc1b08 (patch)
tree21563e7ce162f4769d191c08d1e78cafd3a83759
parent6969766b7557b33e7588abe5956c21c23450110c (diff)
downloadopenvswitch-24f8381214966e90819bf4a9ecabf076cbfc1b08.tar.gz
Use ovs_refcount_unref_relaxed.
After a quick analysis, in most cases the access to refcounted objects is clearly protected either with an explicit lock/mutex, or RCU. there are only a few places where I left a call to ovs_refcount_unref(). Upon closer analysis it may well be that those could also use the relaxed form. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--lib/bfd.c2
-rw-r--r--lib/cfm.c2
-rw-r--r--lib/dpif-netdev.c6
-rw-r--r--lib/lacp.c2
-rw-r--r--lib/mcast-snooping.c2
-rw-r--r--lib/stp.c2
-rw-r--r--ofproto/bond.c2
-rw-r--r--ofproto/netflow.c2
-rw-r--r--ofproto/ofproto-dpif-ipfix.c2
-rw-r--r--ofproto/ofproto-dpif-sflow.c2
-rw-r--r--ofproto/ofproto.c2
11 files changed, 13 insertions, 13 deletions
diff --git a/lib/bfd.c b/lib/bfd.c
index 4cbe99969..892dfe877 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -493,7 +493,7 @@ bfd_ref(const struct bfd *bfd_)
void
bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex)
{
- if (bfd && ovs_refcount_unref(&bfd->ref_cnt) == 1) {
+ if (bfd && ovs_refcount_unref_relaxed(&bfd->ref_cnt) == 1) {
ovs_mutex_lock(&mutex);
bfd_status_changed(bfd);
hmap_remove(all_bfds, &bfd->node);
diff --git a/lib/cfm.c b/lib/cfm.c
index 447a0954d..77843697e 100644
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -374,7 +374,7 @@ cfm_unref(struct cfm *cfm) OVS_EXCLUDED(mutex)
return;
}
- if (ovs_refcount_unref(&cfm->ref_cnt) != 1) {
+ if (ovs_refcount_unref_relaxed(&cfm->ref_cnt) != 1) {
return;
}
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 0b5a80811..b6d6b2e1b 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -605,7 +605,7 @@ dp_netdev_unref(struct dp_netdev *dp)
/* Take dp_netdev_mutex so that, if dp->ref_cnt falls to zero, we can't
* get a new reference to 'dp' through the 'dp_netdevs' shash. */
ovs_mutex_lock(&dp_netdev_mutex);
- if (ovs_refcount_unref(&dp->ref_cnt) == 1) {
+ if (ovs_refcount_unref_relaxed(&dp->ref_cnt) == 1) {
dp_netdev_free(dp);
}
ovs_mutex_unlock(&dp_netdev_mutex);
@@ -627,7 +627,7 @@ dpif_netdev_destroy(struct dpif *dpif)
struct dp_netdev *dp = get_dp_netdev(dpif);
if (!atomic_flag_test_and_set(&dp->destroyed)) {
- if (ovs_refcount_unref(&dp->ref_cnt) == 1) {
+ if (ovs_refcount_unref_relaxed(&dp->ref_cnt) == 1) {
/* Can't happen: 'dpif' still owns a reference to 'dp'. */
OVS_NOT_REACHED();
}
@@ -859,7 +859,7 @@ port_destroy__(struct dp_netdev_port *port)
static void
port_unref(struct dp_netdev_port *port)
{
- if (port && ovs_refcount_unref(&port->ref_cnt) == 1) {
+ if (port && ovs_refcount_unref_relaxed(&port->ref_cnt) == 1) {
ovsrcu_postpone(port_destroy__, port);
}
}
diff --git a/lib/lacp.c b/lib/lacp.c
index 0d30e518b..3b50d46fe 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -251,7 +251,7 @@ lacp_ref(const struct lacp *lacp_)
void
lacp_unref(struct lacp *lacp) OVS_EXCLUDED(mutex)
{
- if (lacp && ovs_refcount_unref(&lacp->ref_cnt) == 1) {
+ if (lacp && ovs_refcount_unref_relaxed(&lacp->ref_cnt) == 1) {
struct slave *slave, *next;
lacp_lock();
diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c
index 96639fe26..865144599 100644
--- a/lib/mcast-snooping.c
+++ b/lib/mcast-snooping.c
@@ -186,7 +186,7 @@ mcast_snooping_unref(struct mcast_snooping *ms)
return;
}
- if (ovs_refcount_unref(&ms->ref_cnt) == 1) {
+ if (ovs_refcount_unref_relaxed(&ms->ref_cnt) == 1) {
mcast_snooping_flush(ms);
hmap_destroy(&ms->table);
ovs_rwlock_destroy(&ms->rwlock);
diff --git a/lib/stp.c b/lib/stp.c
index dbe48e823..218eb9ab6 100644
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -327,7 +327,7 @@ stp_ref(const struct stp *stp_)
void
stp_unref(struct stp *stp)
{
- if (stp && ovs_refcount_unref(&stp->ref_cnt) == 1) {
+ if (stp && ovs_refcount_unref_relaxed(&stp->ref_cnt) == 1) {
ovs_mutex_lock(&mutex);
list_remove(&stp->node);
ovs_mutex_unlock(&mutex);
diff --git a/ofproto/bond.c b/ofproto/bond.c
index d2b0e732b..2d04b4392 100644
--- a/ofproto/bond.c
+++ b/ofproto/bond.c
@@ -256,7 +256,7 @@ bond_unref(struct bond *bond)
struct bond_slave *slave, *next_slave;
struct bond_pr_rule_op *pr_op, *next_op;
- if (!bond || ovs_refcount_unref(&bond->ref_cnt) != 1) {
+ if (!bond || ovs_refcount_unref_relaxed(&bond->ref_cnt) != 1) {
return;
}
diff --git a/ofproto/netflow.c b/ofproto/netflow.c
index c0859ea7b..b3678ca8d 100644
--- a/ofproto/netflow.c
+++ b/ofproto/netflow.c
@@ -409,7 +409,7 @@ netflow_ref(const struct netflow *nf_)
void
netflow_unref(struct netflow *nf)
{
- if (nf && ovs_refcount_unref(&nf->ref_cnt) == 1) {
+ if (nf && ovs_refcount_unref_relaxed(&nf->ref_cnt) == 1) {
int orig;
atomic_sub(&netflow_count, 1, &orig);
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index 08a3fca4c..1584c2594 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -694,7 +694,7 @@ dpif_ipfix_clear(struct dpif_ipfix *di) OVS_REQUIRES(mutex)
void
dpif_ipfix_unref(struct dpif_ipfix *di) OVS_EXCLUDED(mutex)
{
- if (di && ovs_refcount_unref(&di->ref_cnt) == 1) {
+ if (di && ovs_refcount_unref_relaxed(&di->ref_cnt) == 1) {
ovs_mutex_lock(&mutex);
dpif_ipfix_clear(di);
dpif_ipfix_bridge_exporter_destroy(&di->bridge_exporter);
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index cb1f83085..c7e092a96 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -361,7 +361,7 @@ dpif_sflow_get_probability(const struct dpif_sflow *ds) OVS_EXCLUDED(mutex)
void
dpif_sflow_unref(struct dpif_sflow *ds) OVS_EXCLUDED(mutex)
{
- if (ds && ovs_refcount_unref(&ds->ref_cnt) == 1) {
+ if (ds && ovs_refcount_unref_relaxed(&ds->ref_cnt) == 1) {
struct dpif_sflow_port *dsp, *next;
route_table_unregister();
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 5399c9f9b..d18f73993 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2545,7 +2545,7 @@ ofproto_rule_ref(struct rule *rule)
void
ofproto_rule_unref(struct rule *rule)
{
- if (rule && ovs_refcount_unref(&rule->ref_count) == 1) {
+ if (rule && ovs_refcount_unref_relaxed(&rule->ref_count) == 1) {
ovsrcu_postpone(rule_destroy_cb, rule);
}
}