Home | History | Annotate | Line # | Download | only in uvm
uvm_stat.c revision 1.40
      1 /*	$NetBSD: uvm_stat.c,v 1.40 2019/05/09 08:16:15 skrll Exp $	 */
      2 
      3 /*
      4  * Copyright (c) 1997 Charles D. Cranor and Washington University.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  *
     27  * from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
     28  */
     29 
     30 /*
     31  * uvm_stat.c
     32  */
     33 
     34 #include <sys/cdefs.h>
     35 __KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.40 2019/05/09 08:16:15 skrll Exp $");
     36 
     37 #include "opt_readahead.h"
     38 #include "opt_ddb.h"
     39 
     40 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/cpu.h>
     43 
     44 #include <uvm/uvm.h>
     45 #include <uvm/uvm_ddb.h>
     46 
     47 #ifdef DDB
     48 
     49 #include <sys/pool.h>
     50 
     51 /*
     52  * uvmexp_print: ddb hook to print interesting uvm counters
     53  */
     54 void
     55 uvmexp_print(void (*pr)(const char *, ...)
     56     __attribute__((__format__(__printf__,1,2))))
     57 {
     58 	int active, inactive;
     59 	int poolpages;
     60 	CPU_INFO_ITERATOR cii;
     61 	struct cpu_info *ci;
     62 
     63 	uvm_estimatepageable(&active, &inactive);
     64 	poolpages = pool_totalpages_locked();
     65 
     66 	(*pr)("Current UVM status:\n");
     67 	(*pr)("  pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d, ncolors=%d\n",
     68 	    uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask,
     69 	    uvmexp.pageshift, uvmexp.ncolors);
     70 	(*pr)("  %d VM pages: %d active, %d inactive, %d wired, %d free\n",
     71 	    uvmexp.npages, active, inactive, uvmexp.wired,
     72 	    uvmexp.free);
     73 	(*pr)("  pages  %d anon, %d file, %d exec\n",
     74 	    uvmexp.anonpages, uvmexp.filepages, uvmexp.execpages);
     75 	(*pr)("  freemin=%d, free-target=%d, wired-max=%d\n",
     76 	    uvmexp.freemin, uvmexp.freetarg, uvmexp.wiredmax);
     77 	(*pr)("  resv-pg=%d, resv-kernel=%d, zeropages=%d\n",
     78 	    uvmexp.reserve_pagedaemon, uvmexp.reserve_kernel, uvmexp.zeropages);
     79 	(*pr)("  bootpages=%d, poolpages=%d\n",
     80 	    uvmexp.bootpages, poolpages);
     81 
     82 	for (CPU_INFO_FOREACH(cii, ci)) {
     83 		(*pr)("  cpu%u:\n", cpu_index(ci));
     84 		(*pr)("    faults=%" PRIu64 ", traps=%" PRIu64 ", "
     85 		    "intrs=%" PRIu64 ", ctxswitch=%" PRIu64 "\n",
     86 		    ci->ci_data.cpu_nfault, ci->ci_data.cpu_ntrap,
     87 		    ci->ci_data.cpu_nintr, ci->ci_data.cpu_nswtch);
     88 		(*pr)("    softint=%" PRIu64 ", syscalls=%" PRIu64 "\n",
     89 		    ci->ci_data.cpu_nsoft, ci->ci_data.cpu_nsyscall);
     90 	}
     91 
     92 	(*pr)("  fault counts:\n");
     93 	(*pr)("    noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n",
     94 	    uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait,
     95 	    uvmexp.fltpgrele);
     96 	(*pr)("    ok relocks(total)=%d(%d), anget(retrys)=%d(%d), "
     97 	    "amapcopy=%d\n", uvmexp.fltrelckok, uvmexp.fltrelck,
     98 	    uvmexp.fltanget, uvmexp.fltanretry, uvmexp.fltamcopy);
     99 	(*pr)("    neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n",
    100 	    uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget);
    101 	(*pr)("    cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n",
    102 	    uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy,
    103 	    uvmexp.flt_przero);
    104 
    105 	(*pr)("  daemon and swap counts:\n");
    106 	(*pr)("    woke=%d, revs=%d, scans=%d, obscans=%d, anscans=%d\n",
    107 	    uvmexp.pdwoke, uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdobscan,
    108 	    uvmexp.pdanscan);
    109 	(*pr)("    busy=%d, freed=%d, reactivate=%d, deactivate=%d\n",
    110 	    uvmexp.pdbusy, uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact);
    111 	(*pr)("    pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts,
    112 	    uvmexp.pdpending, uvmexp.nswget);
    113 	(*pr)("    nswapdev=%d, swpgavail=%d\n",
    114 	    uvmexp.nswapdev, uvmexp.swpgavail);
    115 	(*pr)("    swpages=%d, swpginuse=%d, swpgonly=%d, paging=%d\n",
    116 	    uvmexp.swpages, uvmexp.swpginuse, uvmexp.swpgonly, uvmexp.paging);
    117 }
    118 #endif
    119 
    120 #if defined(READAHEAD_STATS)
    121 
    122 #define	UVM_RA_EVCNT_DEFINE(name) \
    123 struct evcnt uvm_ra_##name = \
    124 EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "readahead", #name); \
    125 EVCNT_ATTACH_STATIC(uvm_ra_##name);
    126 
    127 UVM_RA_EVCNT_DEFINE(total);
    128 UVM_RA_EVCNT_DEFINE(hit);
    129 UVM_RA_EVCNT_DEFINE(miss);
    130 
    131 #endif /* defined(READAHEAD_STATS) */
    132