From owner-svn-src-head@freebsd.org Sun Oct 16 10:43:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11D45BED2E8; Sun, 16 Oct 2016 10:43:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C15AA1623; Sun, 16 Oct 2016 10:43:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9GAhCi5033323; Sun, 16 Oct 2016 10:43:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9GAhCiM033322; Sun, 16 Oct 2016 10:43:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610161043.u9GAhCiM033322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 16 Oct 2016 10:43:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307392 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Oct 2016 10:43:14 -0000 Author: mav Date: Sun Oct 16 10:43:12 2016 New Revision: 307392 URL: https://svnweb.freebsd.org/changeset/base/307392 Log: Optimize ZIL itx memory allocation on FreeBSD. These allocations can reach up to 128KB, while FreeBSD kernel allocator can cache allocations only up to 64KB. To avoid expensive allocations for each large ZIL write use caching zio_buf_alloc() allocator instead. To make it possible de-inline few instances of zil_itx_destroy(). Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Sun Oct 16 06:07:43 2016 (r307391) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Sun Oct 16 10:43:12 2016 (r307392) @@ -1142,6 +1142,11 @@ zil_itx_create(uint64_t txtype, size_t l lrsize = P2ROUNDUP_TYPED(lrsize, sizeof (uint64_t), size_t); +#ifdef __FreeBSD__ + if (offsetof(itx_t, itx_lr) + lrsize > PAGE_SIZE) + itx = zio_buf_alloc(offsetof(itx_t, itx_lr) + lrsize); + else +#endif itx = kmem_alloc(offsetof(itx_t, itx_lr) + lrsize, KM_SLEEP); itx->itx_lr.lrc_txtype = txtype; itx->itx_lr.lrc_reclen = lrsize; @@ -1155,6 +1160,11 @@ zil_itx_create(uint64_t txtype, size_t l void zil_itx_destroy(itx_t *itx) { +#ifdef __FreeBSD__ + if (offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen > PAGE_SIZE) + zio_buf_free(itx, offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen); + else +#endif kmem_free(itx, offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen); } @@ -1174,8 +1184,7 @@ zil_itxg_clean(itxs_t *itxs) list = &itxs->i_sync_list; while ((itx = list_head(list)) != NULL) { list_remove(list, itx); - kmem_free(itx, offsetof(itx_t, itx_lr) + - itx->itx_lr.lrc_reclen); + zil_itx_destroy(itx); } cookie = NULL; @@ -1184,8 +1193,7 @@ zil_itxg_clean(itxs_t *itxs) list = &ian->ia_list; while ((itx = list_head(list)) != NULL) { list_remove(list, itx); - kmem_free(itx, offsetof(itx_t, itx_lr) + - itx->itx_lr.lrc_reclen); + zil_itx_destroy(itx); } list_destroy(list); kmem_free(ian, sizeof (itx_async_node_t)); @@ -1250,8 +1258,7 @@ zil_remove_async(zilog_t *zilog, uint64_ } while ((itx = list_head(&clean_list)) != NULL) { list_remove(&clean_list, itx); - kmem_free(itx, offsetof(itx_t, itx_lr) + - itx->itx_lr.lrc_reclen); + zil_itx_destroy(itx); } list_destroy(&clean_list); } @@ -1501,8 +1508,7 @@ zil_commit_writer(zilog_t *zilog) if (txg > spa_last_synced_txg(spa) || txg > spa_freeze_txg(spa)) lwb = zil_lwb_commit(zilog, itx, lwb); list_remove(&zilog->zl_itx_commit_list, itx); - kmem_free(itx, offsetof(itx_t, itx_lr) - + itx->itx_lr.lrc_reclen); + zil_itx_destroy(itx); } DTRACE_PROBE1(zil__cw2, zilog_t *, zilog);