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
This commit is contained in:
Andriy Gapon 2017-02-25 16:39:21 +00:00
parent 253495d764
commit 9b43bc27c4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314272
4 changed files with 16 additions and 4 deletions

View File

@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bitset.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/types.h>
#include <sys/queue.h>
@ -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);
}
}

View File

@ -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

View File

@ -1332,7 +1332,7 @@ vm_pageout_scan(struct vm_domain *vmd, int pass)
* 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.

View File

@ -86,6 +86,12 @@ extern bool vm_pages_needed;
#define VM_OOM_MEM 1
#define VM_OOM_SWAPZ 2
/*
* vm_lowmem flags.
*/
#define VM_LOW_KMEM 0x01
#define VM_LOW_PAGES 0x02
/*
* Exported routines.
*/