Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Oct 2016 10:43:12 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
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
Message-ID:  <201610161043.u9GAhCiM033322@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610161043.u9GAhCiM033322>