From owner-svn-src-all@freebsd.org Thu Dec 15 08:03:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0052C81958; Thu, 15 Dec 2016 08:03:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA9F6168; Thu, 15 Dec 2016 08:03:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBF83Hih084574; Thu, 15 Dec 2016 08:03:17 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBF83GmO084572; Thu, 15 Dec 2016 08:03:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201612150803.uBF83GmO084572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 15 Dec 2016 08:03:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310104 - in head/sys/cddl: compat/opensolaris/sys contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 08:03:18 -0000 Author: mav Date: Thu Dec 15 08:03:16 2016 New Revision: 310104 URL: https://svnweb.freebsd.org/changeset/base/310104 Log: Revert r310023 for now. After another look my new variable mapping was not exactly right. Modified: head/sys/cddl/compat/opensolaris/sys/kmem.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: head/sys/cddl/compat/opensolaris/sys/kmem.h ============================================================================== --- head/sys/cddl/compat/opensolaris/sys/kmem.h Thu Dec 15 05:36:48 2016 (r310103) +++ head/sys/cddl/compat/opensolaris/sys/kmem.h Thu Dec 15 08:03:16 2016 (r310104) @@ -37,7 +37,6 @@ #include #include #include -#include MALLOC_DECLARE(M_SOLARIS); @@ -78,10 +77,8 @@ void kmem_reap(void); int kmem_debugging(void); void *calloc(size_t n, size_t s); -#define freemem (long)vm_cnt.v_free_count -#define desfree (long)vm_cnt.v_free_target -#define minfree (long)vm_cnt.v_free_min -#define needfree (long)vm_pageout_deficit +#define freemem vm_cnt.v_free_count +#define minfree vm_cnt.v_free_min #define heap_arena kmem_arena #define kmem_alloc(size, kmflags) zfs_kmem_alloc((size), (kmflags)) #define kmem_zalloc(size, kmflags) zfs_kmem_alloc((size), (kmflags) | M_ZERO) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Dec 15 05:36:48 2016 (r310103) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Dec 15 08:03:16 2016 (r310104) @@ -357,7 +357,6 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; -#define lotsfree zfs_arc_free_target /* Absolute min for arc min / max is 16MB. */ static uint64_t arc_abs_min = 16 << 20; @@ -3828,6 +3827,8 @@ arc_shrink(int64_t to_free) } } +static long needfree = 0; + typedef enum free_memory_reason_t { FMR_UNKNOWN, FMR_NEEDFREE, @@ -3874,6 +3875,17 @@ arc_available_memory(void) } /* + * Cooperate with pagedaemon when it's time for it to scan + * and reclaim some pages. + */ + n = PAGESIZE * ((int64_t)freemem - zfs_arc_free_target); + if (n < lowest) { + lowest = n; + r = FMR_LOTSFREE; + } + +#ifdef illumos + /* * check that we're out of range of the pageout scanner. It starts to * schedule paging if freemem is less than lotsfree and needfree. * lotsfree is the high-water mark for pageout, and needfree is the @@ -3886,7 +3898,6 @@ arc_available_memory(void) r = FMR_LOTSFREE; } -#ifdef illumos /* * check to make sure that swapfs has enough space so that anon * reservations can still succeed. anon_resvmem() checks that the @@ -4143,6 +4154,9 @@ arc_reclaim_thread(void *dummy __unused) * infinite loop. */ if (arc_size <= arc_c || evicted == 0) { +#ifdef _KERNEL + needfree = 0; +#endif /* * We're either no longer overflowing, or we * can't evict anything more, so we should wake @@ -5869,6 +5883,8 @@ arc_lowmem(void *arg __unused, int howto { mutex_enter(&arc_reclaim_lock); + /* XXX: Memory deficit should be passed as argument. */ + needfree = btoc(arc_c >> arc_shrink_shift); DTRACE_PROBE(arc__needfree); cv_signal(&arc_reclaim_thread_cv);