Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Oct 2010 09:03:17 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r213651 - head/sys/kern
Message-ID:  <201010090903.o9993H7Z032535@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sat Oct  9 09:03:17 2010
New Revision: 213651
URL: http://svn.freebsd.org/changeset/base/213651

Log:
  add kmem_map_free sysctl: query largest contiguous free range in kmem_map
  
  Suggested by:	alc
  Reviewed by:	alc
  MFC after:	1 week

Modified:
  head/sys/kern/kern_malloc.c

Modified: head/sys/kern/kern_malloc.c
==============================================================================
--- head/sys/kern/kern_malloc.c	Sat Oct  9 08:52:09 2010	(r213650)
+++ head/sys/kern/kern_malloc.c	Sat Oct  9 09:03:17 2010	(r213651)
@@ -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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010090903.o9993H7Z032535>