Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jul 2017 16:55:07 +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-11@freebsd.org
Subject:   svn commit: r321562 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201707261655.v6QGt7ZZ081522@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Jul 26 16:55:07 2017
New Revision: 321562
URL: https://svnweb.freebsd.org/changeset/base/321562

Log:
  MFC r318924 (by avg):
  arc_init: make code closer to upstream by introducing 'allmem' variable
  
  All the differences in calculations are kept.
  A comment about arc_max being 1/2 of all memory is fixed to reflect the
  actual code that uses 5/8 as a factor.

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Wed Jul 26 16:53:39 2017	(r321561)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Wed Jul 26 16:55:07 2017	(r321562)
@@ -6315,6 +6315,20 @@ arc_init(void)
 {
 	int i, prefetch_tunable_set = 0;
 
+	/*
+	 * allmem is "all memory that we could possibly use".
+	 */
+#ifdef illumos
+#ifdef _KERNEL
+	uint64_t allmem = ptob(physmem - swapfs_minfree);
+#else
+	uint64_t allmem = (physmem * PAGESIZE) / 2;
+#endif
+#else
+	uint64_t allmem = kmem_size();
+#endif
+
+
 	mutex_init(&arc_reclaim_lock, NULL, MUTEX_DEFAULT, NULL);
 	cv_init(&arc_reclaim_thread_cv, NULL, CV_DEFAULT, NULL);
 	cv_init(&arc_reclaim_waiters_cv, NULL, CV_DEFAULT, NULL);
@@ -6326,7 +6340,7 @@ arc_init(void)
 	arc_min_prefetch_lifespan = 1 * hz;
 
 	/* Start out with 1/8 of all memory */
-	arc_c = kmem_size() / 8;
+	arc_c = allmem / 8;
 
 #ifdef illumos
 #ifdef _KERNEL
@@ -6339,13 +6353,13 @@ arc_init(void)
 #endif
 #endif	/* illumos */
 	/* set min cache to 1/32 of all memory, or arc_abs_min, whichever is more */
-	arc_c_min = MAX(arc_c / 4, arc_abs_min);
-	/* set max to 1/2 of all memory, or all but 1GB, whichever is more */
-	if (arc_c * 8 >= 1 << 30)
-		arc_c_max = (arc_c * 8) - (1 << 30);
+	arc_c_min = MAX(allmem / 32, arc_abs_min);
+	/* set max to 5/8 of all memory, or all but 1GB, whichever is more */
+	if (allmem >= 1 << 30)
+		arc_c_max = allmem - (1 << 30);
 	else
 		arc_c_max = arc_c_min;
-	arc_c_max = MAX(arc_c * 5, arc_c_max);
+	arc_c_max = MAX(allmem * 5 / 8, arc_c_max);
 
 	/*
 	 * In userland, there's only the memory pressure that we artificially
@@ -6362,7 +6376,7 @@ arc_init(void)
 	 * Allow the tunables to override our calculations if they are
 	 * reasonable.
 	 */
-	if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) {
+	if (zfs_arc_max > arc_abs_min && zfs_arc_max < allmem) {
 		arc_c_max = zfs_arc_max;
 		arc_c_min = MIN(arc_c_min, arc_c_max);
 	}
@@ -6485,7 +6499,7 @@ arc_init(void)
 		printf("ZFS WARNING: Recommended minimum RAM size is 512MB; "
 		    "expect unstable behavior.\n");
 	}
-	if (kmem_size() < 512 * (1 << 20)) {
+	if (allmem < 512 * (1 << 20)) {
 		printf("ZFS WARNING: Recommended minimum kmem_size is 512MB; "
 		    "expect unstable behavior.\n");
 		printf("             Consider tuning vm.kmem_size and "



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