Home | History | Annotate | Line # | Download | only in uvm
uvm_stat.c revision 1.5
      1  1.5  thorpej /*	$NetBSD: uvm_stat.c,v 1.5 1998/02/12 20:10:15 thorpej Exp $	*/
      2  1.1      mrg 
      3  1.1      mrg /*
      4  1.1      mrg  * XXXCDC: "ROUGH DRAFT" QUALITY UVM PRE-RELEASE FILE!
      5  1.1      mrg  *	   >>>USE AT YOUR OWN RISK, WORK IS NOT FINISHED<<<
      6  1.1      mrg  */
      7  1.1      mrg /*
      8  1.1      mrg  *
      9  1.1      mrg  * Copyright (c) 1997 Charles D. Cranor and Washington University.
     10  1.1      mrg  * All rights reserved.
     11  1.1      mrg  *
     12  1.1      mrg  * Redistribution and use in source and binary forms, with or without
     13  1.1      mrg  * modification, are permitted provided that the following conditions
     14  1.1      mrg  * are met:
     15  1.1      mrg  * 1. Redistributions of source code must retain the above copyright
     16  1.1      mrg  *    notice, this list of conditions and the following disclaimer.
     17  1.1      mrg  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1      mrg  *    notice, this list of conditions and the following disclaimer in the
     19  1.1      mrg  *    documentation and/or other materials provided with the distribution.
     20  1.1      mrg  * 3. All advertising materials mentioning features or use of this software
     21  1.1      mrg  *    must display the following acknowledgement:
     22  1.1      mrg  *      This product includes software developed by Charles D. Cranor and
     23  1.1      mrg  *      Washington University.
     24  1.1      mrg  * 4. The name of the author may not be used to endorse or promote products
     25  1.1      mrg  *    derived from this software without specific prior written permission.
     26  1.1      mrg  *
     27  1.1      mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     28  1.1      mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     29  1.1      mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30  1.1      mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     31  1.1      mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     32  1.1      mrg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     33  1.1      mrg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     34  1.1      mrg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     35  1.1      mrg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     36  1.1      mrg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     37  1.3      mrg  *
     38  1.3      mrg  * from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
     39  1.1      mrg  */
     40  1.4      mrg 
     41  1.4      mrg #include "opt_uvmhist.h"
     42  1.1      mrg 
     43  1.1      mrg /*
     44  1.1      mrg  * uvm_stat.c
     45  1.1      mrg  */
     46  1.1      mrg 
     47  1.1      mrg #include <sys/param.h>
     48  1.1      mrg #include <sys/systm.h>
     49  1.1      mrg 
     50  1.1      mrg #include <vm/vm.h>
     51  1.1      mrg 
     52  1.1      mrg #include <uvm/uvm.h>
     53  1.1      mrg 
     54  1.1      mrg struct uvm_cnt *uvm_cnt_head = NULL;
     55  1.5  thorpej 
     56  1.5  thorpej /*
     57  1.5  thorpej  * globals
     58  1.5  thorpej  */
     59  1.5  thorpej 
     60  1.5  thorpej #ifdef UVMHIST_PRINT
     61  1.5  thorpej int uvmhist_print_enabled = 1;
     62  1.5  thorpej #endif
     63  1.1      mrg 
     64  1.1      mrg /*
     65  1.1      mrg  * prototypes
     66  1.1      mrg  */
     67  1.1      mrg 
     68  1.1      mrg void uvmhist_dump __P((struct uvm_history *));
     69  1.1      mrg void uvmcnt_dump __P((void));
     70  1.1      mrg void uvmmap_dump __P((vm_map_t));
     71  1.1      mrg void uvm_dump __P((void));
     72  1.1      mrg 
     73  1.1      mrg #ifdef UVMHIST
     74  1.1      mrg /* call this from ddb */
     75  1.1      mrg void
     76  1.1      mrg uvmhist_dump(l)
     77  1.1      mrg 
     78  1.1      mrg struct uvm_history *l;
     79  1.1      mrg 
     80  1.1      mrg {
     81  1.1      mrg   int lcv, s = splhigh();
     82  1.1      mrg   lcv = l->f;
     83  1.1      mrg   do {
     84  1.1      mrg     if (l->e[lcv].fmt)
     85  1.1      mrg       uvmhist_print(&l->e[lcv]);
     86  1.1      mrg     lcv = (lcv + 1) % l->n;
     87  1.1      mrg   } while (lcv != l->f);
     88  1.1      mrg   splx(s);
     89  1.1      mrg }
     90  1.1      mrg #endif
     91  1.1      mrg 
     92  1.1      mrg void
     93  1.1      mrg uvmcnt_dump()
     94  1.1      mrg 
     95  1.1      mrg {
     96  1.1      mrg   struct uvm_cnt *uvc = uvm_cnt_head;
     97  1.1      mrg   while (uvc) {
     98  1.1      mrg     if ((uvc->t & UVMCNT_MASK) != UVMCNT_CNT) continue;
     99  1.1      mrg     printf("%s = %d\n", uvc->name, uvc->c);
    100  1.1      mrg     uvc = uvc->next;
    101  1.1      mrg   }
    102  1.1      mrg }
    103  1.1      mrg 
    104  1.1      mrg /*
    105  1.1      mrg  * uvm_dump: ddb hook to dump interesting uvm counters
    106  1.1      mrg  */
    107  1.1      mrg 
    108  1.1      mrg void uvm_dump()
    109  1.1      mrg 
    110  1.1      mrg {
    111  1.1      mrg   printf("Current UVM status:\n");
    112  1.1      mrg   printf("  pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n",
    113  1.1      mrg     uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask, uvmexp.pageshift);
    114  1.1      mrg   printf("  %d VM pages: %d active, %d inactive, %d wired, %d free\n",
    115  1.1      mrg     uvmexp.npages, uvmexp.active, uvmexp.inactive, uvmexp.wired, uvmexp.free);
    116  1.1      mrg   printf("  freemin=%d, free-target=%d, inactive-target=%d, wired-max=%d\n",
    117  1.1      mrg     uvmexp.freemin, uvmexp.freetarg, uvmexp.inactarg, uvmexp.wiredmax);
    118  1.1      mrg   printf("  faults=%d, traps=%d, intrs=%d, ctxswitch=%d\n",
    119  1.1      mrg     uvmexp.faults, uvmexp.traps, uvmexp.intrs, uvmexp.swtch);
    120  1.1      mrg   printf("  softint=%d, syscalls=%d, swapins=%d, swapouts=%d\n",
    121  1.1      mrg     uvmexp.softs, uvmexp.syscalls, uvmexp.swapins, uvmexp.swapouts);
    122  1.1      mrg   printf("  fault counts:\n");
    123  1.1      mrg   printf("    noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n",
    124  1.1      mrg     uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait, uvmexp.fltpgrele);
    125  1.1      mrg   printf("    ok relocks(total)=%d(%d), anget(retrys)=%d(%d), amapcopy=%d\n",
    126  1.1      mrg     uvmexp.fltrelckok, uvmexp.fltrelck, uvmexp.fltanget, uvmexp.fltanretry,
    127  1.1      mrg     uvmexp.fltamcopy);
    128  1.1      mrg   printf("    neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n",
    129  1.1      mrg     uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget);
    130  1.1      mrg   printf("    cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n",
    131  1.1      mrg     uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy,
    132  1.1      mrg     uvmexp.flt_przero);
    133  1.1      mrg   printf("  daemon and swap counts:\n");
    134  1.1      mrg   printf("    woke=%d, revs=%d, scans=%d, swout=%d\n", uvmexp.pdwoke,
    135  1.1      mrg     uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdswout);
    136  1.1      mrg   printf("    busy=%d, freed=%d, reactivate=%d, deactivate=%d\n", uvmexp.pdbusy,
    137  1.1      mrg         uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact);
    138  1.1      mrg   printf("    pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts,
    139  1.1      mrg 	uvmexp.pdpending, uvmexp.nswget);
    140  1.1      mrg   printf("    nswapdev=%d, nanon=%d, nfreeanon=%d\n", uvmexp.nswapdev,
    141  1.1      mrg 	uvmexp.nanon, uvmexp.nfreeanon);
    142  1.1      mrg }
    143