]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: freq_ctr: Use the new _HA_ATOMIC_* macros.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 8 Mar 2019 17:47:59 +0000 (18:47 +0100)
committerOlivier Houchard <cognet@ci0.org>
Mon, 11 Mar 2019 16:02:37 +0000 (17:02 +0100)
Use the new _HA_ATOMIC_* macros and add barriers where needed.

include/proto/freq_ctr.h

index 277bfda5afcba569fbee075fdf3da2c5b49bcf44..953e21b100b290059351f68f506ea565a645d216 100644 (file)
@@ -42,7 +42,8 @@ static inline unsigned int update_freq_ctr(struct freq_ctr *ctr, unsigned int in
                /* remove the bit, used for the lock */
                curr_sec = ctr->curr_sec & 0x7fffffff;
        }
-       while (!HA_ATOMIC_CAS(&ctr->curr_sec, &curr_sec, curr_sec | 0x80000000));
+       while (!_HA_ATOMIC_CAS(&ctr->curr_sec, &curr_sec, curr_sec | 0x80000000));
+       __ha_barrier_atomic_store();
 
        elapsed = (now.tv_sec & 0x7fffffff)- curr_sec;
        if (unlikely(elapsed > 0)) {
@@ -59,7 +60,7 @@ static inline unsigned int update_freq_ctr(struct freq_ctr *ctr, unsigned int in
        tot_inc = ctr->curr_ctr;
 
        /* release the lock and update the time in case of rotate. */
-       HA_ATOMIC_STORE(&ctr->curr_sec, curr_sec & 0x7fffffff);
+       _HA_ATOMIC_STORE(&ctr->curr_sec, curr_sec & 0x7fffffff);
        return tot_inc;
        /* Note: later we may want to propagate the update to other counters */
 }
@@ -79,7 +80,8 @@ static inline unsigned int update_freq_ctr_period(struct freq_ctr_period *ctr,
                /* remove the bit, used for the lock */
                curr_tick = (ctr->curr_tick >> 1) << 1;
        }
-       while (!HA_ATOMIC_CAS(&ctr->curr_tick, &curr_tick, curr_tick | 0x1));
+       while (!_HA_ATOMIC_CAS(&ctr->curr_tick, &curr_tick, curr_tick | 0x1));
+       __ha_barrier_atomic_store();
 
        if (now_ms - curr_tick >= period) {
                ctr->prev_ctr = ctr->curr_ctr;
@@ -95,7 +97,7 @@ static inline unsigned int update_freq_ctr_period(struct freq_ctr_period *ctr,
        ctr->curr_ctr += inc;
        tot_inc = ctr->curr_ctr;
        /* release the lock and update the time in case of rotate. */
-       HA_ATOMIC_STORE(&ctr->curr_tick, (curr_tick >> 1) << 1);
+       _HA_ATOMIC_STORE(&ctr->curr_tick, (curr_tick >> 1) << 1);
        return tot_inc;
        /* Note: later we may want to propagate the update to other counters */
 }