2001-12-09 06:07:19 +03:00
|
|
|
/* $NetBSD: uvm_stat.c,v 1.22 2001/12/09 03:07:20 chs Exp $ */
|
1998-02-05 09:25:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Charles D. Cranor and
|
|
|
|
* Washington University.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1998-02-07 14:07:38 +03:00
|
|
|
*
|
1998-02-13 08:33:55 +03:00
|
|
|
* from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
|
1998-02-05 09:25:08 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* uvm_stat.c
|
|
|
|
*/
|
|
|
|
|
2001-11-10 10:36:59 +03:00
|
|
|
#include <sys/cdefs.h>
|
2001-12-09 06:07:19 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.22 2001/12/09 03:07:20 chs Exp $");
|
2001-11-10 10:36:59 +03:00
|
|
|
|
|
|
|
#include "opt_uvmhist.h"
|
|
|
|
#include "opt_ddb.h"
|
|
|
|
|
1998-02-05 09:25:08 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <uvm/uvm.h>
|
2000-11-24 10:25:50 +03:00
|
|
|
#include <uvm/uvm_ddb.h>
|
1998-02-05 09:25:08 +03:00
|
|
|
|
1998-02-12 23:10:15 +03:00
|
|
|
/*
|
|
|
|
* globals
|
|
|
|
*/
|
|
|
|
|
1998-02-13 07:52:00 +03:00
|
|
|
struct uvm_cnt *uvm_cnt_head = NULL;
|
|
|
|
|
|
|
|
#ifdef UVMHIST
|
|
|
|
struct uvm_history_head uvm_histories;
|
|
|
|
#endif
|
|
|
|
|
1998-02-12 23:10:15 +03:00
|
|
|
#ifdef UVMHIST_PRINT
|
|
|
|
int uvmhist_print_enabled = 1;
|
|
|
|
#endif
|
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
#ifdef DDB
|
|
|
|
|
1998-02-05 09:25:08 +03:00
|
|
|
/*
|
|
|
|
* prototypes
|
|
|
|
*/
|
|
|
|
|
1998-02-13 07:52:00 +03:00
|
|
|
#ifdef UVMHIST
|
1998-02-05 09:25:08 +03:00
|
|
|
void uvmhist_dump __P((struct uvm_history *));
|
1998-06-20 17:19:00 +04:00
|
|
|
void uvm_hist __P((u_int32_t));
|
|
|
|
static void uvmhist_dump_histories __P((struct uvm_history *[]));
|
1998-02-13 07:52:00 +03:00
|
|
|
#endif
|
1998-02-05 09:25:08 +03:00
|
|
|
void uvmcnt_dump __P((void));
|
|
|
|
|
1998-06-20 17:19:00 +04:00
|
|
|
|
1998-02-05 09:25:08 +03:00
|
|
|
#ifdef UVMHIST
|
|
|
|
/* call this from ddb */
|
|
|
|
void
|
|
|
|
uvmhist_dump(l)
|
1998-02-13 08:33:55 +03:00
|
|
|
struct uvm_history *l;
|
1998-02-05 09:25:08 +03:00
|
|
|
{
|
1998-02-13 08:33:55 +03:00
|
|
|
int lcv, s;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
lcv = l->f;
|
|
|
|
do {
|
|
|
|
if (l->e[lcv].fmt)
|
|
|
|
uvmhist_print(&l->e[lcv]);
|
|
|
|
lcv = (lcv + 1) % l->n;
|
|
|
|
} while (lcv != l->f);
|
|
|
|
splx(s);
|
1998-02-05 09:25:08 +03:00
|
|
|
}
|
1998-06-20 17:19:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* print a merged list of uvm_history structures
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
uvmhist_dump_histories(hists)
|
|
|
|
struct uvm_history *hists[];
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
int cur[MAXHISTS];
|
|
|
|
int s, lcv, hi;
|
|
|
|
|
|
|
|
/* so we don't get corrupted lists! */
|
|
|
|
s = splhigh();
|
|
|
|
|
|
|
|
/* find the first of each list */
|
|
|
|
for (lcv = 0; hists[lcv]; lcv++)
|
|
|
|
cur[lcv] = hists[lcv]->f;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* here we loop "forever", finding the next earliest
|
|
|
|
* history entry and printing it. cur[X] is the current
|
|
|
|
* entry to test for the history in hists[X]. if it is
|
|
|
|
* -1, then this history is finished.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
hi = -1;
|
|
|
|
tv.tv_sec = tv.tv_usec = 0;
|
|
|
|
|
|
|
|
/* loop over each history */
|
|
|
|
for (lcv = 0; hists[lcv]; lcv++) {
|
|
|
|
restart:
|
|
|
|
if (cur[lcv] == -1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the format is empty, go to the next entry
|
|
|
|
* and retry.
|
|
|
|
*/
|
|
|
|
if (hists[lcv]->e[cur[lcv]].fmt == NULL) {
|
|
|
|
cur[lcv] = (cur[lcv] + 1) % (hists[lcv]->n);
|
|
|
|
if (cur[lcv] == hists[lcv]->f)
|
|
|
|
cur[lcv] = -1;
|
|
|
|
goto restart;
|
|
|
|
}
|
2001-05-25 08:06:11 +04:00
|
|
|
|
1998-06-20 17:19:00 +04:00
|
|
|
/*
|
|
|
|
* if the time hasn't been set yet, or this entry is
|
|
|
|
* earlier than the current tv, set the time and history
|
|
|
|
* index.
|
|
|
|
*/
|
|
|
|
if (tv.tv_sec == 0 ||
|
|
|
|
timercmp(&hists[lcv]->e[cur[lcv]].tv, &tv, <)) {
|
|
|
|
tv = hists[lcv]->e[cur[lcv]].tv;
|
|
|
|
hi = lcv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we didn't find any entries, we must be done */
|
|
|
|
if (hi == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* print and move to the next entry */
|
|
|
|
uvmhist_print(&hists[hi]->e[cur[hi]]);
|
|
|
|
cur[hi] = (cur[hi] + 1) % (hists[hi]->n);
|
|
|
|
if (cur[hi] == hists[hi]->f)
|
|
|
|
cur[hi] = -1;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* call this from ddb. `bitmask' is from <uvm/uvm_stat.h>. it
|
|
|
|
* merges the named histories.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
uvm_hist(bitmask)
|
|
|
|
u_int32_t bitmask; /* XXX only support 32 hists */
|
|
|
|
{
|
|
|
|
struct uvm_history *hists[MAXHISTS + 1];
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if ((bitmask & UVMHIST_MAPHIST) || bitmask == 0)
|
|
|
|
hists[i++] = &maphist;
|
|
|
|
|
|
|
|
if ((bitmask & UVMHIST_PDHIST) || bitmask == 0)
|
|
|
|
hists[i++] = &pdhist;
|
|
|
|
|
2001-02-04 13:55:58 +03:00
|
|
|
if ((bitmask & UVMHIST_UBCHIST) || bitmask == 0)
|
|
|
|
hists[i++] = &ubchist;
|
|
|
|
|
1998-06-20 17:19:00 +04:00
|
|
|
hists[i] = NULL;
|
|
|
|
|
|
|
|
uvmhist_dump_histories(hists);
|
|
|
|
}
|
1998-02-13 08:33:55 +03:00
|
|
|
#endif /* UVMHIST */
|
1998-02-05 09:25:08 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
uvmcnt_dump()
|
|
|
|
{
|
1998-02-13 08:33:55 +03:00
|
|
|
struct uvm_cnt *uvc = uvm_cnt_head;
|
|
|
|
|
|
|
|
while (uvc) {
|
|
|
|
if ((uvc->t & UVMCNT_MASK) != UVMCNT_CNT)
|
|
|
|
continue;
|
|
|
|
printf("%s = %d\n", uvc->name, uvc->c);
|
|
|
|
uvc = uvc->next;
|
|
|
|
}
|
1998-02-05 09:25:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-11-24 10:25:50 +03:00
|
|
|
* uvmexp_print: ddb hook to print interesting uvm counters
|
1998-02-05 09:25:08 +03:00
|
|
|
*/
|
2000-11-24 10:25:50 +03:00
|
|
|
void
|
|
|
|
uvmexp_print(void (*pr)(const char *, ...))
|
1998-02-05 09:25:08 +03:00
|
|
|
{
|
1998-02-13 08:33:55 +03:00
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)("Current UVM status:\n");
|
|
|
|
(*pr)(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask,
|
|
|
|
uvmexp.pageshift);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" %d VM pages: %d active, %d inactive, %d wired, %d free\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.npages, uvmexp.active, uvmexp.inactive, uvmexp.wired,
|
|
|
|
uvmexp.free);
|
2001-12-09 06:07:19 +03:00
|
|
|
(*pr)(" min %d%% (%d) anon, %d%% (%d) file, %d%% (%d) exec\n",
|
|
|
|
uvmexp.anonminpct, uvmexp.anonmin, uvmexp.fileminpct,
|
|
|
|
uvmexp.filemin, uvmexp.execminpct, uvmexp.execmin);
|
|
|
|
(*pr)(" max %d%% (%d) anon, %d%% (%d) file, %d%% (%d) exec\n",
|
|
|
|
uvmexp.anonmaxpct, uvmexp.anonmax, uvmexp.filemaxpct,
|
|
|
|
uvmexp.filemax, uvmexp.execmaxpct, uvmexp.execmax);
|
|
|
|
(*pr)(" pages %d anon, %d file, %d exec\n",
|
|
|
|
uvmexp.anonpages, uvmexp.filepages, uvmexp.execpages);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" freemin=%d, free-target=%d, inactive-target=%d, "
|
1998-02-13 08:33:55 +03:00
|
|
|
"wired-max=%d\n", uvmexp.freemin, uvmexp.freetarg, uvmexp.inactarg,
|
|
|
|
uvmexp.wiredmax);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" faults=%d, traps=%d, intrs=%d, ctxswitch=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.faults, uvmexp.traps, uvmexp.intrs, uvmexp.swtch);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" softint=%d, syscalls=%d, swapins=%d, swapouts=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.softs, uvmexp.syscalls, uvmexp.swapins, uvmexp.swapouts);
|
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" fault counts:\n");
|
|
|
|
(*pr)(" noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait,
|
|
|
|
uvmexp.fltpgrele);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" ok relocks(total)=%d(%d), anget(retrys)=%d(%d), "
|
1998-02-13 08:33:55 +03:00
|
|
|
"amapcopy=%d\n", uvmexp.fltrelckok, uvmexp.fltrelck,
|
|
|
|
uvmexp.fltanget, uvmexp.fltanretry, uvmexp.fltamcopy);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy,
|
|
|
|
uvmexp.flt_przero);
|
|
|
|
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" daemon and swap counts:\n");
|
|
|
|
(*pr)(" woke=%d, revs=%d, scans=%d, obscans=%d, anscans=%d\n",
|
|
|
|
uvmexp.pdwoke, uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdobscan,
|
|
|
|
uvmexp.pdanscan);
|
|
|
|
(*pr)(" busy=%d, freed=%d, reactivate=%d, deactivate=%d\n",
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.pdbusy, uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts,
|
1998-02-13 08:33:55 +03:00
|
|
|
uvmexp.pdpending, uvmexp.nswget);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" nswapdev=%d, nanon=%d, nanonneeded=%d nfreeanon=%d\n",
|
2000-01-11 09:57:49 +03:00
|
|
|
uvmexp.nswapdev, uvmexp.nanon, uvmexp.nanonneeded,
|
|
|
|
uvmexp.nfreeanon);
|
2000-11-24 10:25:50 +03:00
|
|
|
(*pr)(" swpages=%d, swpginuse=%d, swpgonly=%d paging=%d\n",
|
1999-03-26 20:34:15 +03:00
|
|
|
uvmexp.swpages, uvmexp.swpginuse, uvmexp.swpgonly, uvmexp.paging);
|
1998-02-05 09:25:08 +03:00
|
|
|
}
|
2000-11-24 10:25:50 +03:00
|
|
|
#endif
|