From owner-svn-src-head@freebsd.org Sat Feb 25 16:39:22 2017 Return-Path: Delivered-To: svn-src-head@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 DE40BCED49D; Sat, 25 Feb 2017 16:39:22 +0000 (UTC) (envelope-from avg@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 B8D25C50; Sat, 25 Feb 2017 16:39:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1PGdLca032898; Sat, 25 Feb 2017 16:39:21 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1PGdL9s032894; Sat, 25 Feb 2017 16:39:21 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201702251639.v1PGdL9s032894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sat, 25 Feb 2017 16:39:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314272 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 16:39:23 -0000 Author: avg Date: Sat Feb 25 16:39:21 2017 New Revision: 314272 URL: https://svnweb.freebsd.org/changeset/base/314272 Log: call vm_lowmem hook in uma_reclaim_worker A comment near kmem_reclaim() implies that we already did that. Calling the hook is useful, because some handlers, e.g. ARC, might be able to release significant amounts of KVA. Now that we have more than one place where vm_lowmem hook is called, use this change as an opportunity to introduce flags that describe a reason for calling the hook. No handler makes use of the flags yet. Reviewed by: markj, kib MFC after: 1 week Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D9764 Modified: head/sys/vm/uma_core.c head/sys/vm/vm_kern.c head/sys/vm/vm_pageout.c head/sys/vm/vm_pageout.h Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Sat Feb 25 15:55:46 2017 (r314271) +++ head/sys/vm/uma_core.c Sat Feb 25 16:39:21 2017 (r314272) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3199,6 +3200,9 @@ uma_reclaim_worker(void *arg __unused) "umarcl", 0); if (uma_reclaim_needed) { uma_reclaim_needed = 0; + sx_xunlock(&uma_drain_lock); + EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_KMEM); + sx_xlock(&uma_drain_lock); uma_reclaim_locked(true); } } Modified: head/sys/vm/vm_kern.c ============================================================================== --- head/sys/vm/vm_kern.c Sat Feb 25 15:55:46 2017 (r314271) +++ head/sys/vm/vm_kern.c Sat Feb 25 16:39:21 2017 (r314272) @@ -552,11 +552,13 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, &i, 0, req); if (error) return (error); - if (i) - EVENTHANDLER_INVOKE(vm_lowmem, 0); + if ((i & ~(VM_LOW_KMEM | VM_LOW_PAGES)) != 0) + return (EINVAL); + if (i != 0) + EVENTHANDLER_INVOKE(vm_lowmem, i); return (0); } SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_RW, 0, 0, - debug_vm_lowmem, "I", "set to trigger vm_lowmem event"); + debug_vm_lowmem, "I", "set to trigger vm_lowmem event with given flags"); #endif Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Sat Feb 25 15:55:46 2017 (r314271) +++ head/sys/vm/vm_pageout.c Sat Feb 25 16:39:21 2017 (r314272) @@ -1332,7 +1332,7 @@ vm_pageout_scan(struct vm_domain *vmd, i * Decrease registered cache sizes. */ SDT_PROBE0(vm, , , vm__lowmem_scan); - EVENTHANDLER_INVOKE(vm_lowmem, 0); + EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_PAGES); /* * We do this explicitly after the caches have been * drained above. Modified: head/sys/vm/vm_pageout.h ============================================================================== --- head/sys/vm/vm_pageout.h Sat Feb 25 15:55:46 2017 (r314271) +++ head/sys/vm/vm_pageout.h Sat Feb 25 16:39:21 2017 (r314272) @@ -87,6 +87,12 @@ extern bool vm_pages_needed; #define VM_OOM_SWAPZ 2 /* + * vm_lowmem flags. + */ +#define VM_LOW_KMEM 0x01 +#define VM_LOW_PAGES 0x02 + +/* * Exported routines. */