]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Micro-optimize zrl_remove()
authorAlexander Motin <mav@FreeBSD.org>
Tue, 29 Nov 2022 17:26:03 +0000 (12:26 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 2 Mar 2023 22:37:07 +0000 (14:37 -0800)
atomic_dec_32() should be a bit lighter than atomic_dec_32_nv().

Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Closes #14200

module/zfs/zrlock.c

index a4def60536227a11a89d10fa55580585c247a0e8..8b6755bc936050cd261ed6fe9d6519b80faa3250 100644 (file)
@@ -106,16 +106,16 @@ zrl_add_impl(zrlock_t *zrl, const char *zc)
 void
 zrl_remove(zrlock_t *zrl)
 {
-       uint32_t n;
-
 #ifdef ZFS_DEBUG
        if (zrl->zr_owner == curthread) {
                zrl->zr_owner = NULL;
                zrl->zr_caller = NULL;
        }
+       int32_t n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
+       ASSERT3S(n, >=, 0);
+#else
+       atomic_dec_32((uint32_t *)&zrl->zr_refcount);
 #endif
-       n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
-       ASSERT3S((int32_t)n, >=, 0);
 }
 
 int