]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: try to skip atomical decrement in buffer::ptr::release().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 13 Nov 2018 23:47:06 +0000 (00:47 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 3 Feb 2019 18:49:06 +0000 (19:49 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer.cc

index f6a33e43b6806b8fc479c53d92aee08201741be5..45af914f98923dca3ac5070bfac9aa74b2be869f 100644 (file)
@@ -539,7 +539,8 @@ static ceph::spinlock debug_lock;
   {
     if (_raw) {
       bdout << "ptr " << this << " release " << _raw << bendl;
-      if (--_raw->nref == 0) {
+      const bool last_one = (1 == _raw->nref.load(std::memory_order_acquire));
+      if (likely(last_one) || --_raw->nref == 0) {
         // BE CAREFUL: this is called also for hypercombined ptr_node. After
         // freeing underlying raw, `*this` can become inaccessible as well!
         const auto* delete_raw = _raw;