Date: Fri, 21 Feb 2020 04:33:14 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r358204 - in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys Message-ID: <202002210433.01L4XELo068570@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Feb 21 04:33:14 2020 New Revision: 358204 URL: https://svnweb.freebsd.org/changeset/base/358204 Log: MFC r357657: Remove duplicate dbufs accounting. Since AVL already has embedded element counter, use dn_dbufs_count only for dbufs not counted there (bonus buffers) and just add them. This removes two atomics per dbuf life cycle. According to profiler it reduces time spent by dbuf_destroy() inside bottlenecked dbuf_evict_thread() from 13.36% to 9.20% of the core. This counter is used only on illumos, so for FreeBSD it was just a waste of time. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Feb 21 04:31:30 2020 (r358203) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Feb 21 04:33:14 2020 (r358204) @@ -2375,7 +2375,6 @@ dbuf_destroy(dmu_buf_impl_t *db) if (needlock) mutex_enter(&dn->dn_dbufs_mtx); avl_remove(&dn->dn_dbufs, db); - atomic_dec_32(&dn->dn_dbufs_count); membar_producer(); DB_DNODE_EXIT(db); if (needlock) @@ -2600,7 +2599,6 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || zfs_refcount_count(&dn->dn_holds) > 0); (void) zfs_refcount_add(&dn->dn_holds, db); - atomic_inc_32(&dn->dn_dbufs_count); dprintf_dbuf(db, "db=%p\n", db); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c Fri Feb 21 04:31:30 2020 (r358203) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c Fri Feb 21 04:33:14 2020 (r358204) @@ -998,7 +998,7 @@ dnode_move(void *buf, void *newbuf, size_t size, void */ refcount = zfs_refcount_count(&odn->dn_holds); ASSERT(refcount >= 0); - dbufs = odn->dn_dbufs_count; + dbufs = DN_DBUFS_COUNT(odn); /* We can't have more dbufs than dnode holds. */ ASSERT3U(dbufs, <=, refcount); @@ -1025,7 +1025,7 @@ dnode_move(void *buf, void *newbuf, size_t size, void list_link_replace(&odn->dn_link, &ndn->dn_link); /* If the dnode was safe to move, the refcount cannot have changed. */ ASSERT(refcount == zfs_refcount_count(&ndn->dn_holds)); - ASSERT(dbufs == ndn->dn_dbufs_count); + ASSERT(dbufs == DN_DBUFS_COUNT(ndn)); zrl_exit(&ndn->dn_handle->dnh_zrlock); /* handle has moved */ mutex_exit(&os->os_lock); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Feb 21 04:31:30 2020 (r358203) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Feb 21 04:33:14 2020 (r358204) @@ -346,6 +346,13 @@ struct dnode { }; /* + * Since AVL already has embedded element counter, use dn_dbufs_count + * only for dbufs not counted there (bonus buffers) and just add them. + */ +#define DN_DBUFS_COUNT(dn) ((dn)->dn_dbufs_count + \ + avl_numnodes(&(dn)->dn_dbufs)) + +/* * Adds a level of indirection between the dbuf and the dnode to avoid * iterating descendent dbufs in dnode_move(). Handles are not allocated * individually, but as an array of child dnodes in dnode_hold_impl().
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002210433.01L4XELo068570>