mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-10 18:40:00 -04:00
Fix the memory ordering for the isc stats to be acquire-release
This commit is contained in:
parent
663047ac8b
commit
4ffd4cd4f6
1 changed files with 8 additions and 14 deletions
|
|
@ -108,17 +108,14 @@ isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) {
|
|||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
atomic_fetch_add_explicit(&stats->counters[counter], 1,
|
||||
memory_order_relaxed);
|
||||
atomic_fetch_add_relaxed(&stats->counters[counter], 1);
|
||||
}
|
||||
|
||||
void
|
||||
isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) {
|
||||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
atomic_fetch_sub_explicit(&stats->counters[counter], 1,
|
||||
memory_order_relaxed);
|
||||
atomic_fetch_sub_release(&stats->counters[counter], 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -129,8 +126,7 @@ isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg,
|
|||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
|
||||
for (i = 0; i < stats->ncounters; i++) {
|
||||
uint32_t counter = atomic_load_explicit(&stats->counters[i],
|
||||
memory_order_relaxed);
|
||||
uint32_t counter = atomic_load_acquire(&stats->counters[i]);
|
||||
if ((options & ISC_STATSDUMP_VERBOSE) == 0 && counter == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -143,8 +139,7 @@ isc_stats_set(isc_stats_t *stats, uint64_t val, isc_statscounter_t counter) {
|
|||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
atomic_store_explicit(&stats->counters[counter], val,
|
||||
memory_order_relaxed);
|
||||
atomic_store_release(&stats->counters[counter], val);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -154,13 +149,13 @@ isc_stats_update_if_greater(isc_stats_t *stats, isc_statscounter_t counter,
|
|||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
isc_statscounter_t curr_value =
|
||||
atomic_load_relaxed(&stats->counters[counter]);
|
||||
atomic_load_acquire(&stats->counters[counter]);
|
||||
do {
|
||||
if (curr_value >= value) {
|
||||
break;
|
||||
}
|
||||
} while (!atomic_compare_exchange_strong(&stats->counters[counter],
|
||||
&curr_value, value));
|
||||
} while (!atomic_compare_exchange_weak_acq_rel(
|
||||
&stats->counters[counter], &curr_value, value));
|
||||
}
|
||||
|
||||
isc_statscounter_t
|
||||
|
|
@ -168,6 +163,5 @@ isc_stats_get_counter(isc_stats_t *stats, isc_statscounter_t counter) {
|
|||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
return (atomic_load_explicit(&stats->counters[counter],
|
||||
memory_order_relaxed));
|
||||
return (atomic_load_acquire(&stats->counters[counter]));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue