summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2015-08-06 21:27:50 +0000
committeralc <alc@FreeBSD.org>2015-08-06 21:27:50 +0000
commit51df0b58b1e4fd9fa211f69362670cff2287aae9 (patch)
tree32274634e0fa65254e9e1a6ecef1522f075ba9fd
parent411beb22622372196cf0885f42f303feeff3a860 (diff)
downloadFreeBSD-src-51df0b58b1e4fd9fa211f69362670cff2287aae9.zip
FreeBSD-src-51df0b58b1e4fd9fa211f69362670cff2287aae9.tar.gz
Introduce a sysctl for reporting the number of fully populated reservations.
-rw-r--r--sys/vm/vm_reserv.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
index 2cfc630..34e69e1 100644
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -217,6 +217,11 @@ static long vm_reserv_freed;
SYSCTL_LONG(_vm_reserv, OID_AUTO, freed, CTLFLAG_RD,
&vm_reserv_freed, 0, "Cumulative number of freed reservations");
+static int sysctl_vm_reserv_fullpop(SYSCTL_HANDLER_ARGS);
+
+SYSCTL_PROC(_vm_reserv, OID_AUTO, fullpop, CTLTYPE_INT | CTLFLAG_RD, NULL, 0,
+ sysctl_vm_reserv_fullpop, "I", "Current number of full reservations");
+
static int sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS);
SYSCTL_OID(_vm_reserv, OID_AUTO, partpopq, CTLTYPE_STRING | CTLFLAG_RD, NULL, 0,
@@ -235,6 +240,33 @@ static void vm_reserv_populate(vm_reserv_t rv, int index);
static void vm_reserv_reclaim(vm_reserv_t rv);
/*
+ * Returns the current number of full reservations.
+ *
+ * Since the number of full reservations is computed without acquiring the
+ * free page queue lock, the returned value may be inexact.
+ */
+static int
+sysctl_vm_reserv_fullpop(SYSCTL_HANDLER_ARGS)
+{
+ vm_paddr_t paddr;
+ struct vm_phys_seg *seg;
+ vm_reserv_t rv;
+ int fullpop, segind;
+
+ fullpop = 0;
+ for (segind = 0; segind < vm_phys_nsegs; segind++) {
+ seg = &vm_phys_segs[segind];
+ paddr = roundup2(seg->start, VM_LEVEL_0_SIZE);
+ while (paddr + VM_LEVEL_0_SIZE <= seg->end) {
+ rv = &vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT];
+ fullpop += rv->popcnt == VM_LEVEL_0_NPAGES;
+ paddr += VM_LEVEL_0_SIZE;
+ }
+ }
+ return (sysctl_handle_int(oidp, &fullpop, 0, req));
+}
+
+/*
* Describes the current state of the partially-populated reservation queue.
*/
static int
OpenPOWER on IntegriCloud