diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c b/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c index 10377cd29b7f..fd8798d2e16a 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c @@ -152,7 +152,7 @@ u_int kmem_free_count(void) { - return (vm_cnt.v_free_count); + return (vm_cnt.v_free_count + vm_cnt.v_cache_count); } u_int @@ -169,6 +169,13 @@ kmem_size(void) return (kmem_size_val); } +uint64_t +kmem_used(void) +{ + + return (vmem_size(kmem_arena, VMEM_ALLOC)); +} + static int kmem_std_constructor(void *mem, int size __unused, void *private, int flags) { diff --git a/sys/cddl/compat/opensolaris/sys/kmem.h b/sys/cddl/compat/opensolaris/sys/kmem.h index af6cec52cf91..1879ba44a4b3 100644 --- a/sys/cddl/compat/opensolaris/sys/kmem.h +++ b/sys/cddl/compat/opensolaris/sys/kmem.h @@ -66,6 +66,7 @@ typedef struct kmem_cache { void *zfs_kmem_alloc(size_t size, int kmflags); void zfs_kmem_free(void *buf, size_t size); uint64_t kmem_size(void); +uint64_t kmem_used(void); u_int kmem_page_count(void); /* 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 1d97718c70bf..f4bc936e074d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -2563,6 +2563,14 @@ arc_reclaim_needed(void) #endif /* sun */ #else +#ifdef __i386__ + /* i386 has KVA limits that the raw page counts above don't consider */ + if (kmem_used() > (kmem_size() * 3) / 4) { + DTRACE_PROBE2(arc__reclaim_used, uint64_t, + kmem_used(), uint64_t, (kmem_size() * 3) / 4); + return (1); + } +#endif if (spa_get_random(100) == 0) return (1); #endif