summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2010-10-09 09:03:17 +0000
committeravg <avg@FreeBSD.org>2010-10-09 09:03:17 +0000
commit2e7319683712e8a9c3471dbff271bd72171f2c9d (patch)
tree4a5290c6331f0a272a0a91ed2b3229fde9d87a62 /sys/kern
parent3373ecde5ca05e50431b3c471dc2273cd4aa0684 (diff)
downloadFreeBSD-src-2e7319683712e8a9c3471dbff271bd72171f2c9d.zip
FreeBSD-src-2e7319683712e8a9c3471dbff271bd72171f2c9d.tar.gz
add kmem_map_free sysctl: query largest contiguous free range in kmem_map
Suggested by: alc Reviewed by: alc MFC after: 1 week
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_malloc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index ee45e3a..9c7ff40 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -207,6 +207,11 @@ SYSCTL_PROC(_vm, OID_AUTO, kmem_map_size,
CTLFLAG_RD | CTLTYPE_ULONG | CTLFLAG_MPSAFE, NULL, 0,
sysctl_kmem_map_size, "LU", "Current kmem_map allocation size");
+static int sysctl_kmem_map_free(SYSCTL_HANDLER_ARGS);
+SYSCTL_PROC(_vm, OID_AUTO, kmem_map_free,
+ CTLFLAG_RD | CTLTYPE_ULONG | CTLFLAG_MPSAFE, NULL, 0,
+ sysctl_kmem_map_free, "LU", "Largest contiguous free range in kmem_map");
+
/*
* The malloc_mtx protects the kmemstatistics linked list.
*/
@@ -254,6 +259,18 @@ sysctl_kmem_map_size(SYSCTL_HANDLER_ARGS)
return (sysctl_handle_long(oidp, &size, 0, req));
}
+static int
+sysctl_kmem_map_free(SYSCTL_HANDLER_ARGS)
+{
+ u_long size;
+
+ vm_map_lock_read(kmem_map);
+ size = kmem_map->root != NULL ?
+ kmem_map->root->max_free : kmem_map->size;
+ vm_map_unlock_read(kmem_map);
+ return (sysctl_handle_long(oidp, &size, 0, req));
+}
+
/*
* malloc(9) uma zone separation -- sub-page buffer overruns in one
* malloc type will affect only a subset of other malloc types.
OpenPOWER on IntegriCloud