aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_vmem.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2015-04-03 14:45:48 +0000
committerAlexander Motin <mav@FreeBSD.org>2015-04-03 14:45:48 +0000
commit2e9ccb32a1641da8dc99d90cfd8275c27c2fa906 (patch)
treeb7f8a97c288f434a2d4a88b5e6e78891583f5036 /sys/kern/subr_vmem.c
parent7ab169a322d435d2e83e3200686472b4533ddf79 (diff)
downloadsrc-2e9ccb32a1641da8dc99d90cfd8275c27c2fa906.tar.gz
src-2e9ccb32a1641da8dc99d90cfd8275c27c2fa906.zip
Make ZFS ARC track both KVA usage and fragmentation.
Even on Illumos, with its much larger KVA, ZFS ARC steps back if KVA usage reaches certain threshold (3/4 on i386 or 16/17 otherwise). FreeBSD has even less KVA, but had no such limit on archs with direct map as amd64. As result, on machines with a lot of RAM, during load with very small user- space memory pressure, such as `zfs send`, it was possible to reach state, when there is enough both physical RAM and KVA (I've seen up to 25-30%), but no continuous KVA range to allocate even single 128KB I/O request. Address this situation from two sides: - restore KVA usage limitations in a way the most close to Illumos; - introduce new requirement for KVA fragmentation, specifying that we should have at least one sequential KVA range of zfs_max_recordsize bytes. Experiments show that first limitation done alone is not sufficient. On machine with 64GB of RAM it is sometimes needed to drop up to half of ARC size to get at leats one 1MB KVA chunk. Statically limiting ARC to half of KVA/RAM is too strict, so second limitation makes it to work in cycles: accumulate trash up to certain critical mass, do massive spring-cleaning, and then start littering again. :) MFC after: 1 month
Notes
Notes: svn path=/head/; revision=281026
Diffstat (limited to 'sys/kern/subr_vmem.c')
-rw-r--r--sys/kern/subr_vmem.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/kern/subr_vmem.c b/sys/kern/subr_vmem.c
index f88627f5bab1..47e583b25342 100644
--- a/sys/kern/subr_vmem.c
+++ b/sys/kern/subr_vmem.c
@@ -1320,6 +1320,7 @@ vmem_add(vmem_t *vm, vmem_addr_t addr, vmem_size_t size, int flags)
vmem_size_t
vmem_size(vmem_t *vm, int typemask)
{
+ int i;
switch (typemask) {
case VMEM_ALLOC:
@@ -1328,6 +1329,14 @@ vmem_size(vmem_t *vm, int typemask)
return vm->vm_size - vm->vm_inuse;
case VMEM_FREE|VMEM_ALLOC:
return vm->vm_size;
+ case VMEM_MAXFREE:
+ for (i = VMEM_MAXORDER - 1; i >= 0; i--) {
+ if (LIST_EMPTY(&vm->vm_freelist[i]))
+ continue;
+ return ((vmem_size_t)ORDER2SIZE(i) <<
+ vm->vm_quantum_shift);
+ }
+ return (0);
default:
panic("vmem_size");
}