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.h

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.h,v 1.35 2004/11/23 05:08:33 yamt 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.h,v 1.1.2.4 1998/02/07 01:16:56 chs Exp
   35  */
   36 
   37 #ifndef _UVM_UVM_STAT_H_
   38 #define _UVM_UVM_STAT_H_
   39 
   40 #if defined(_KERNEL_OPT)
   41 #include "opt_uvmhist.h"
   42 #endif
   43 
   44 #include <sys/queue.h>
   45 
   46 /*
   47  * uvm_stat: monitor what is going on with uvm (or whatever)
   48  */
   49 
   50 /*
   51  * history/tracing
   52  */
   53 
   54 struct uvm_history_ent {
   55         struct timeval tv;              /* time stamp */
   56         int cpunum;
   57         const char *fmt;                /* printf format */
   58         size_t fmtlen;                  /* length of printf format */
   59         const char *fn;                 /* function name */
   60         size_t fnlen;                   /* length of function name */
   61         u_long call;                    /* function call number */
   62         u_long v[4];                    /* values */
   63 };
   64 
   65 struct uvm_history {
   66         const char *name;               /* name of this history */
   67         size_t namelen;                 /* length of name, not including null */
   68         LIST_ENTRY(uvm_history) list;   /* link on list of all histories */
   69         int n;                          /* number of entries */
   70         int f;                          /* next free one */
   71         int unused;                     /* old location of struct simplelock */
   72         struct uvm_history_ent *e;      /* the malloc'd entries */
   73         struct simplelock l;            /* lock on this history */
   74 };
   75 
   76 LIST_HEAD(uvm_history_head, uvm_history);
   77 
   78 /*
   79  * grovelling lists all at once.  we currently do not allow more than
   80  * 32 histories to exist, as the way to dump a number of them at once
   81  * is by calling uvm_hist() with a bitmask.
   82  */
   83 
   84 /* this is used to set the size of some arrays */
   85 #define MAXHISTS                32      /* do not change this! */
   86 
   87 /* and these are the bit values of each history */
   88 #define UVMHIST_MAPHIST         0x00000001      /* maphist */
   89 #define UVMHIST_PDHIST          0x00000002      /* pdhist */
   90 #define UVMHIST_UBCHIST         0x00000004      /* ubchist */
   91 #define UVMHIST_LOANHIST        0x00000008      /* loanhist */
   92 
   93 #ifdef _KERNEL
   94 
   95 /*
   96  * macros to use the history/tracing code.  note that UVMHIST_LOG
   97  * must take 4 arguments (even if they are ignored by the format).
   98  */
   99 #ifndef UVMHIST
  100 #define UVMHIST_DECL(NAME)
  101 #define UVMHIST_INIT(NAME,N)
  102 #define UVMHIST_INIT_STATIC(NAME,BUF)
  103 #define UVMHIST_LOG(NAME,FMT,A,B,C,D)
  104 #define UVMHIST_CALLED(NAME)
  105 #define UVMHIST_FUNC(FNAME)
  106 #define uvmhist_dump(NAME)
  107 #else
  108 #include <sys/kernel.h>         /* for "cold" variable */
  109 
  110 extern  struct uvm_history_head uvm_histories;
  111 
  112 #define UVMHIST_DECL(NAME) struct uvm_history NAME
  113 
  114 #define UVMHIST_INIT(NAME,N) \
  115 do { \
  116         (NAME).name = __STRING(NAME); \
  117         (NAME).namelen = strlen(__STRING(NAME)); \
  118         (NAME).n = (N); \
  119         (NAME).f = 0; \
  120         simple_lock_init(&(NAME).l); \
  121         (NAME).e = (struct uvm_history_ent *) \
  122                 malloc(sizeof(struct uvm_history_ent) * (N), M_TEMP, \
  123                     M_WAITOK); \
  124         memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (N)); \
  125         LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
  126 } while (/*CONSTCOND*/ 0)
  127 
  128 #define UVMHIST_INIT_STATIC(NAME,BUF) \
  129 do { \
  130         (NAME).name = __STRING(NAME); \
  131         (NAME).namelen = strlen(__STRING(NAME)); \
  132         (NAME).n = sizeof(BUF) / sizeof(struct uvm_history_ent); \
  133         (NAME).f = 0; \
  134         simple_lock_init(&(NAME).l); \
  135         (NAME).e = (struct uvm_history_ent *) (BUF); \
  136         memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (NAME).n); \
  137         LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
  138 } while (/*CONSTCOND*/ 0)
  139 
  140 #if defined(UVMHIST_PRINT)
  141 extern int uvmhist_print_enabled;
  142 #define UVMHIST_PRINTNOW(E) \
  143 do { \
  144                 if (uvmhist_print_enabled) { \
  145                         uvmhist_print(E); \
  146                         DELAY(100000); \
  147                 } \
  148 } while (/*CONSTCOND*/ 0)
  149 #else
  150 #define UVMHIST_PRINTNOW(E) /* nothing */
  151 #endif
  152 
  153 #define UVMHIST_LOG(NAME,FMT,A,B,C,D) \
  154 do { \
  155         int _i_, _s_ = splhigh(); \
  156         simple_lock(&(NAME).l); \
  157         _i_ = (NAME).f; \
  158         (NAME).f = (_i_ + 1 < (NAME).n) ? _i_ + 1 : 0; \
  159         simple_unlock(&(NAME).l); \
  160         splx(_s_); \
  161         if (!cold) \
  162                 microtime(&(NAME).e[_i_].tv); \
  163         (NAME).e[_i_].cpunum = cpu_number(); \
  164         (NAME).e[_i_].fmt = (FMT); \
  165         (NAME).e[_i_].fmtlen = strlen(FMT); \
  166         (NAME).e[_i_].fn = _uvmhist_name; \
  167         (NAME).e[_i_].fnlen = strlen(_uvmhist_name); \
  168         (NAME).e[_i_].call = _uvmhist_call; \
  169         (NAME).e[_i_].v[0] = (u_long)(A); \
  170         (NAME).e[_i_].v[1] = (u_long)(B); \
  171         (NAME).e[_i_].v[2] = (u_long)(C); \
  172         (NAME).e[_i_].v[3] = (u_long)(D); \
  173         UVMHIST_PRINTNOW(&((NAME).e[_i_])); \
  174 } while (/*CONSTCOND*/ 0)
  175 
  176 #define UVMHIST_CALLED(NAME) \
  177 do { \
  178         { \
  179                 int s = splhigh(); \
  180                 simple_lock(&(NAME).l); \
  181                 _uvmhist_call = _uvmhist_cnt++; \
  182                 simple_unlock(&(NAME).l); \
  183                 splx(s); \
  184         } \
  185         UVMHIST_LOG(NAME,"called!", 0, 0, 0, 0); \
  186 } while (/*CONSTCOND*/ 0)
  187 
  188 #define UVMHIST_FUNC(FNAME) \
  189         static int _uvmhist_cnt = 0; \
  190         static const char *const _uvmhist_name = FNAME; \
  191         int _uvmhist_call;
  192 
  193 static __inline void uvmhist_print(struct uvm_history_ent *);
  194 
  195 static __inline void
  196 uvmhist_print(e)
  197         struct uvm_history_ent *e;
  198 {
  199         printf("%06ld.%06ld ", e->tv.tv_sec, e->tv.tv_usec);
  200         printf("%s#%ld@%d: ", e->fn, e->call, e->cpunum);
  201         printf(e->fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
  202         printf("\n");
  203 }
  204 #endif /* UVMHIST */
  205 
  206 #endif /* _KERNEL */
  207 
  208 #endif /* _UVM_UVM_STAT_H_ */

Cache object: 95e581acee69323c72a8497979f52a79


[ 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.