svn commit: r318924 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Andriy Gapon
avg at FreeBSD.org
Fri May 26 11:05:58 UTC 2017
Author: avg
Date: Fri May 26 11:05:56 2017
New Revision: 318924
URL: https://svnweb.freebsd.org/changeset/base/318924
Log:
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.
MFC after: 1 week
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri May 26 10:37:55 2017 (r318923)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri May 26 11:05:56 2017 (r318924)
@@ -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 "
More information about the svn-src-head
mailing list