Neither 'miss_config', 'n_missed', nor 'n_matched' is used to synchronize the state of any other variable, so we can use relaxed atomic operations on them.
Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- ofproto/ofproto-dpif.c | 10 ++++++---- ofproto/ofproto.c | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 4e987bc..ff4479f 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1511,9 +1511,10 @@ query_tables(struct ofproto *ofproto, for (i = 0; i < ofproto->n_tables; i++) { unsigned long missed, matched; - atomic_read(&ofproto->tables[i].n_matched, &matched); + atomic_read_relaxed(&ofproto->tables[i].n_matched, &matched); + atomic_read_relaxed(&ofproto->tables[i].n_missed, &missed); + stats[i].matched_count = matched; - atomic_read(&ofproto->tables[i].n_missed, &missed); stats[i].lookup_count = matched + missed; } } @@ -3445,9 +3446,10 @@ rule_dpif_lookup_from_table(struct ofproto_dpif *ofproto, take_ref); if (stats) { struct oftable *tbl = &ofproto->up.tables[next_id]; - atomic_ulong *stat = *rule ? &tbl->n_matched : &tbl->n_missed; unsigned long orig; - atomic_add(stat, stats->n_packets, &orig); + + atomic_add_relaxed(*rule ? &tbl->n_matched : &tbl->n_missed, + stats->n_packets, &orig); } if (*rule) { return RULE_DPIF_LOOKUP_VERDICT_MATCH; diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 4db6fec..3e80b87 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -2812,7 +2812,7 @@ query_tables(struct ofproto *ofproto, sprintf(f->name, "table%d", i); f->metadata_match = OVS_BE64_MAX; f->metadata_write = OVS_BE64_MAX; - atomic_read(&ofproto->tables[i].miss_config, &f->miss_config); + atomic_read_relaxed(&ofproto->tables[i].miss_config, &f->miss_config); f->max_entries = 1000000; bitmap_set_multiple(f->nonmiss.next, i + 1, @@ -5817,7 +5817,8 @@ enum ofputil_table_miss ofproto_table_get_miss_config(const struct ofproto *ofproto, uint8_t table_id) { enum ofputil_table_miss value; - atomic_read(&ofproto->tables[table_id].miss_config, &value); + + atomic_read_relaxed(&ofproto->tables[table_id].miss_config, &value); return value; } @@ -5830,11 +5831,12 @@ table_mod(struct ofproto *ofproto, const struct ofputil_table_mod *tm) if (tm->table_id == OFPTT_ALL) { int i; for (i = 0; i < ofproto->n_tables; i++) { - atomic_store(&ofproto->tables[i].miss_config, tm->miss_config); + atomic_store_relaxed(&ofproto->tables[i].miss_config, + tm->miss_config); } } else { - atomic_store(&ofproto->tables[tm->table_id].miss_config, - tm->miss_config); + atomic_store_relaxed(&ofproto->tables[tm->table_id].miss_config, + tm->miss_config); } } return 0; -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev