mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
Merge pull request #14227 from ivancich/wip-perf-counter-race
common/perf_counters: fix race condition with atomic variables Reviewed-by: Sage Weil <sage@redhat.com> Reviewed-by: Josh Durgin <jdurgin@redhat.com>
This commit is contained in:
commit
bcb17aa093
@ -120,13 +120,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/// read <sum, count> safely
|
||||
// read <sum, count> safely by making sure the post- and pre-count
|
||||
// are identical; in other words the whole loop needs to be run
|
||||
// without any intervening calls to inc, set, or tinc.
|
||||
pair<uint64_t,uint64_t> read_avg() const {
|
||||
uint64_t sum, count;
|
||||
do {
|
||||
count = avgcount.read();
|
||||
count = avgcount2.read();
|
||||
sum = u64.read();
|
||||
} while (avgcount2.read() != count);
|
||||
} while (avgcount.read() != count);
|
||||
return make_pair(sum, count);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user