From e0a63baae4d0f04749ebcdb3014b1127ef8a6860 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 6 Aug 2015 21:27:50 +0000 Subject: [PATCH] Introduce a sysctl for reporting the number of fully populated reservations. --- sys/vm/vm_reserv.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 2cfc630026de..34e69e11b832 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, @@ -234,6 +239,33 @@ static boolean_t vm_reserv_has_pindex(vm_reserv_t rv, 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. */