From 107b6594505b09552b3731d5e30af7cbd510da69 Mon Sep 17 00:00:00 2001 From: Kip Macy Date: Wed, 10 Jun 2009 01:21:32 +0000 Subject: [PATCH] As far as I can tell systems that have less than 4GB are more often hurt by prefetched than helped. On i386 systems and systems with less than 4GB, prefetch is now disabled by default. I've added a prefetch enable tunable, to enable prefetching for those systems. The prefetch disable tunable will continue to unconditionally disable prefetching. --- .../contrib/opensolaris/uts/common/fs/zfs/arc.c | 15 +++++++++++++++ .../opensolaris/uts/common/fs/zfs/dmu_zfetch.c | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index a3e25803933f..75cc6b1f1fb5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -158,6 +158,8 @@ static int arc_grow_retry = 60; */ static int arc_min_prefetch_lifespan; +extern int zfs_prefetch_disable; +extern int zfs_prefetch_enable; static int arc_dead; /* @@ -3549,6 +3551,19 @@ arc_init(void) mutex_init(&zfs_write_limit_lock, NULL, MUTEX_DEFAULT, NULL); #ifdef _KERNEL +#ifdef __i386__ + if (zfs_prefetch_enable != 1) { + printf("ZFS NOTICE: prefetch is disabled by default on i386" + " - add enable to tunable to change.\n" ); + zfs_prefetch_disable=1; + } +#endif + if ((((uint64_t)physmem * PAGESIZE) < (1ULL << 32)) && + (zfs_prefetch_enable != 1) && (zfs_prefetch_disable != 1)) { + printf("ZFS NOTICE: system has less than 4GB and prefetch enable is not set" + "... disabling.\n"); + zfs_prefetch_disable=1; + } /* Warn about ZFS memory and address space requirements. */ if (((uint64_t)physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) { printf("ZFS WARNING: Recommended minimum RAM size is 512MB; " diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c index 8dba38176527..3ff6f5ec35ed 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c @@ -38,6 +38,7 @@ */ int zfs_prefetch_disable = 0; +int zfs_prefetch_enable = 0; /* max # of streams per zfetch */ uint32_t zfetch_max_streams = 8; @@ -52,6 +53,9 @@ SYSCTL_DECL(_vfs_zfs); TUNABLE_INT("vfs.zfs.prefetch_disable", &zfs_prefetch_disable); SYSCTL_INT(_vfs_zfs, OID_AUTO, prefetch_disable, CTLFLAG_RDTUN, &zfs_prefetch_disable, 0, "Disable prefetch"); +TUNABLE_INT("vfs.zfs.prefetch_enable", &zfs_prefetch_enable); +SYSCTL_INT(_vfs_zfs, OID_AUTO, prefetch_enable, CTLFLAG_RDTUN, + &zfs_prefetch_enable, 0, "Enable prefetch for systems with less than 4GB"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH"); TUNABLE_INT("vfs.zfs.zfetch.max_streams", &zfetch_max_streams); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RDTUN,