]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use relaxed memory ordering for quota->max and quota->soft
authorAram Sargsyan <aram@isc.org>
Thu, 27 Feb 2025 16:14:55 +0000 (16:14 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Tue, 4 Mar 2025 09:57:34 +0000 (09:57 +0000)
These variables are not critical for memory ordering issues
and we can use the relaxed memory ordering, as done in the
main branch.

lib/isc/quota.c

index fa604419add2184d8178f62fe9a20d649b18ab0b..ccafd240ea0377e4104775012eda7ba0f648228e 100644 (file)
@@ -45,22 +45,22 @@ isc_quota_destroy(isc_quota_t *quota) {
        INSIST(atomic_load(&quota->used) == 0);
        INSIST(atomic_load(&quota->waiting) == 0);
        INSIST(ISC_LIST_EMPTY(quota->cbs));
-       atomic_store_release(&quota->max, 0);
+       atomic_store_relaxed(&quota->max, 0);
        atomic_store_release(&quota->used, 0);
-       atomic_store_release(&quota->soft, 0);
+       atomic_store_relaxed(&quota->soft, 0);
        isc_mutex_destroy(&quota->cblock);
 }
 
 void
 isc_quota_soft(isc_quota_t *quota, unsigned int soft) {
        REQUIRE(VALID_QUOTA(quota));
-       atomic_store_release(&quota->soft, soft);
+       atomic_store_relaxed(&quota->soft, soft);
 }
 
 void
 isc_quota_max(isc_quota_t *quota, unsigned int max) {
        REQUIRE(VALID_QUOTA(quota));
-       atomic_store_release(&quota->max, max);
+       atomic_store_relaxed(&quota->max, max);
 }
 
 unsigned int
@@ -84,8 +84,8 @@ isc_quota_getused(isc_quota_t *quota) {
 static isc_result_t
 quota_reserve(isc_quota_t *quota) {
        isc_result_t result;
-       uint_fast32_t max = atomic_load_acquire(&quota->max);
-       uint_fast32_t soft = atomic_load_acquire(&quota->soft);
+       uint_fast32_t max = atomic_load_relaxed(&quota->max);
+       uint_fast32_t soft = atomic_load_relaxed(&quota->soft);
        uint_fast32_t used = atomic_load_acquire(&quota->used);
        do {
                if (max != 0 && used >= max) {