The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/uvm/uvm_stat.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: uvm_stat.c,v 1.23.2.1 2004/05/09 08:55:12 jdc Exp $     */
    2 
    3 /*
    4  *
    5  * Copyright (c) 1997 Charles D. Cranor and Washington University.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by Charles D. Cranor and
   19  *      Washington University.
   20  * 4. The name of the author may not be used to endorse or promote products
   21  *    derived from this software without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   33  *
   34  * from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
   35  */
   36 
   37 /*
   38  * uvm_stat.c
   39  */
   40 
   41 #include <sys/cdefs.h>
   42 __KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.23.2.1 2004/05/09 08:55:12 jdc Exp $");
   43 
   44 #include "opt_uvmhist.h"
   45 #include "opt_ddb.h"
   46 
   47 #include <sys/param.h>
   48 #include <sys/systm.h>
   49 
   50 #include <uvm/uvm.h>
   51 #include <uvm/uvm_ddb.h>
   52 
   53 /*
   54  * globals
   55  */
   56 
   57 #ifdef UVMHIST
   58 struct uvm_history_head uvm_histories;
   59 #endif
   60 
   61 #ifdef UVMHIST_PRINT
   62 int uvmhist_print_enabled = 1;
   63 #endif
   64 
   65 #ifdef DDB
   66 
   67 /*
   68  * prototypes
   69  */
   70 
   71 #ifdef UVMHIST
   72 void uvmhist_dump(struct uvm_history *);
   73 void uvm_hist(u_int32_t);
   74 static void uvmhist_dump_histories(struct uvm_history *[]);
   75 #endif
   76 void uvmcnt_dump(void);
   77 
   78 
   79 #ifdef UVMHIST
   80 /* call this from ddb */
   81 void
   82 uvmhist_dump(l)
   83         struct uvm_history *l;
   84 {
   85         int lcv, s;
   86 
   87         s = splhigh();
   88         lcv = l->f;
   89         do {
   90                 if (l->e[lcv].fmt)
   91                         uvmhist_print(&l->e[lcv]);
   92                 lcv = (lcv + 1) % l->n;
   93         } while (lcv != l->f);
   94         splx(s);
   95 }
   96 
   97 /*
   98  * print a merged list of uvm_history structures
   99  */
  100 static void
  101 uvmhist_dump_histories(hists)
  102         struct uvm_history *hists[];
  103 {
  104         struct timeval  tv;
  105         int     cur[MAXHISTS];
  106         int     s, lcv, hi;
  107 
  108         /* so we don't get corrupted lists! */
  109         s = splhigh();
  110 
  111         /* find the first of each list */
  112         for (lcv = 0; hists[lcv]; lcv++)
  113                  cur[lcv] = hists[lcv]->f;
  114 
  115         /*
  116          * here we loop "forever", finding the next earliest
  117          * history entry and printing it.  cur[X] is the current
  118          * entry to test for the history in hists[X].  if it is
  119          * -1, then this history is finished.
  120          */
  121         for (;;) {
  122                 hi = -1;
  123                 tv.tv_sec = tv.tv_usec = 0;
  124 
  125                 /* loop over each history */
  126                 for (lcv = 0; hists[lcv]; lcv++) {
  127 restart:
  128                         if (cur[lcv] == -1)
  129                                 continue;
  130 
  131                         /*
  132                          * if the format is empty, go to the next entry
  133                          * and retry.
  134                          */
  135                         if (hists[lcv]->e[cur[lcv]].fmt == NULL) {
  136                                 cur[lcv] = (cur[lcv] + 1) % (hists[lcv]->n);
  137                                 if (cur[lcv] == hists[lcv]->f)
  138                                         cur[lcv] = -1;
  139                                 goto restart;
  140                         }
  141 
  142                         /*
  143                          * if the time hasn't been set yet, or this entry is
  144                          * earlier than the current tv, set the time and history
  145                          * index.
  146                          */
  147                         if (tv.tv_sec == 0 ||
  148                             timercmp(&hists[lcv]->e[cur[lcv]].tv, &tv, <)) {
  149                                 tv = hists[lcv]->e[cur[lcv]].tv;
  150                                 hi = lcv;
  151                         }
  152                 }
  153 
  154                 /* if we didn't find any entries, we must be done */
  155                 if (hi == -1)
  156                         break;
  157 
  158                 /* print and move to the next entry */
  159                 uvmhist_print(&hists[hi]->e[cur[hi]]);
  160                 cur[hi] = (cur[hi] + 1) % (hists[hi]->n);
  161                 if (cur[hi] == hists[hi]->f)
  162                         cur[hi] = -1;
  163         }
  164         splx(s);
  165 }
  166 
  167 /*
  168  * call this from ddb.  `bitmask' is from <uvm/uvm_stat.h>.  it
  169  * merges the named histories.
  170  */
  171 void
  172 uvm_hist(bitmask)
  173         u_int32_t       bitmask;        /* XXX only support 32 hists */
  174 {
  175         struct uvm_history *hists[MAXHISTS + 1];
  176         int i = 0;
  177 
  178         if ((bitmask & UVMHIST_MAPHIST) || bitmask == 0)
  179                 hists[i++] = &maphist;
  180 
  181         if ((bitmask & UVMHIST_PDHIST) || bitmask == 0)
  182                 hists[i++] = &pdhist;
  183 
  184         if ((bitmask & UVMHIST_UBCHIST) || bitmask == 0)
  185                 hists[i++] = &ubchist;
  186 
  187         hists[i] = NULL;
  188 
  189         uvmhist_dump_histories(hists);
  190 }
  191 #endif /* UVMHIST */
  192 
  193 /*
  194  * uvmexp_print: ddb hook to print interesting uvm counters
  195  */
  196 void
  197 uvmexp_print(void (*pr)(const char *, ...))
  198 {
  199 
  200         (*pr)("Current UVM status:\n");
  201         (*pr)("  pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n",
  202             uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask,
  203             uvmexp.pageshift);
  204         (*pr)("  %d VM pages: %d active, %d inactive, %d wired, %d free\n",
  205             uvmexp.npages, uvmexp.active, uvmexp.inactive, uvmexp.wired,
  206             uvmexp.free);
  207         (*pr)("  min  %d%% (%d) anon, %d%% (%d) file, %d%% (%d) exec\n",
  208             uvmexp.anonminpct, uvmexp.anonmin, uvmexp.fileminpct,
  209             uvmexp.filemin, uvmexp.execminpct, uvmexp.execmin);
  210         (*pr)("  max  %d%% (%d) anon, %d%% (%d) file, %d%% (%d) exec\n",
  211             uvmexp.anonmaxpct, uvmexp.anonmax, uvmexp.filemaxpct,
  212             uvmexp.filemax, uvmexp.execmaxpct, uvmexp.execmax);
  213         (*pr)("  pages  %d anon, %d file, %d exec\n",
  214             uvmexp.anonpages, uvmexp.filepages, uvmexp.execpages);
  215         (*pr)("  freemin=%d, free-target=%d, inactive-target=%d, "
  216             "wired-max=%d\n", uvmexp.freemin, uvmexp.freetarg, uvmexp.inactarg,
  217             uvmexp.wiredmax);
  218         (*pr)("  faults=%d, traps=%d, intrs=%d, ctxswitch=%d\n",
  219             uvmexp.faults, uvmexp.traps, uvmexp.intrs, uvmexp.swtch);
  220         (*pr)("  softint=%d, syscalls=%d, swapins=%d, swapouts=%d\n",
  221             uvmexp.softs, uvmexp.syscalls, uvmexp.swapins, uvmexp.swapouts);
  222 
  223         (*pr)("  fault counts:\n");
  224         (*pr)("    noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n",
  225             uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait,
  226             uvmexp.fltpgrele);
  227         (*pr)("    ok relocks(total)=%d(%d), anget(retrys)=%d(%d), "
  228             "amapcopy=%d\n", uvmexp.fltrelckok, uvmexp.fltrelck,
  229             uvmexp.fltanget, uvmexp.fltanretry, uvmexp.fltamcopy);
  230         (*pr)("    neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n",
  231             uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget);
  232         (*pr)("    cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n",
  233             uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy,
  234             uvmexp.flt_przero);
  235 
  236         (*pr)("  daemon and swap counts:\n");
  237         (*pr)("    woke=%d, revs=%d, scans=%d, obscans=%d, anscans=%d\n",
  238             uvmexp.pdwoke, uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdobscan,
  239             uvmexp.pdanscan);
  240         (*pr)("    busy=%d, freed=%d, reactivate=%d, deactivate=%d\n",
  241             uvmexp.pdbusy, uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact);
  242         (*pr)("    pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts,
  243             uvmexp.pdpending, uvmexp.nswget);
  244         (*pr)("    nswapdev=%d, nanon=%d, nanonneeded=%d nfreeanon=%d\n",
  245             uvmexp.nswapdev, uvmexp.nanon, uvmexp.nanonneeded,
  246             uvmexp.nfreeanon);
  247         (*pr)("    swpages=%d, swpginuse=%d, swpgonly=%d paging=%d\n",
  248             uvmexp.swpages, uvmexp.swpginuse, uvmexp.swpgonly, uvmexp.paging);
  249 }
  250 #endif

Cache object: 21930b9e7ec251bcb0f5e778aac59bba


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.