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.29.2.1 2004/05/09 08:55:42 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.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         char *fmt;                      /* printf format */
   58         size_t fmtlen;                  /* length of printf format */
   59         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 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 
   92 #ifdef _KERNEL
   93 
   94 /*
   95  * macros to use the history/tracing code.  note that UVMHIST_LOG
   96  * must take 4 arguments (even if they are ignored by the format).
   97  */
   98 #ifndef UVMHIST
   99 #define UVMHIST_DECL(NAME)
  100 #define UVMHIST_INIT(NAME,N)
  101 #define UVMHIST_INIT_STATIC(NAME,BUF)
  102 #define UVMHIST_LOG(NAME,FMT,A,B,C,D)
  103 #define UVMHIST_CALLED(NAME)
  104 #define UVMHIST_FUNC(FNAME)
  105 #define uvmhist_dump(NAME)
  106 #else
  107 #include <sys/kernel.h>         /* for "cold" variable */
  108 
  109 extern  struct uvm_history_head uvm_histories;
  110 
  111 #define UVMHIST_DECL(NAME) struct uvm_history NAME
  112 
  113 #define UVMHIST_INIT(NAME,N) \
  114 do { \
  115         (NAME).name = __STRING(NAME); \
  116         (NAME).namelen = strlen((NAME).name); \
  117         (NAME).n = (N); \
  118         (NAME).f = 0; \
  119         simple_lock_init(&(NAME).l); \
  120         (NAME).e = (struct uvm_history_ent *) \
  121                 malloc(sizeof(struct uvm_history_ent) * (N), M_TEMP, \
  122                     M_WAITOK); \
  123         memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (N)); \
  124         LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
  125 } while (/*CONSTCOND*/ 0)
  126 
  127 #define UVMHIST_INIT_STATIC(NAME,BUF) \
  128 do { \
  129         (NAME).name = __STRING(NAME); \
  130         (NAME).namelen = strlen((NAME).name); \
  131         (NAME).n = sizeof(BUF) / sizeof(struct uvm_history_ent); \
  132         (NAME).f = 0; \
  133         simple_lock_init(&(NAME).l); \
  134         (NAME).e = (struct uvm_history_ent *) (BUF); \
  135         memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (NAME).n); \
  136         LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
  137 } while (/*CONSTCOND*/ 0)
  138 
  139 #if defined(UVMHIST_PRINT)
  140 extern int uvmhist_print_enabled;
  141 #define UVMHIST_PRINTNOW(E) \
  142 do { \
  143                 if (uvmhist_print_enabled) { \
  144                         uvmhist_print(E); \
  145                         DELAY(100000); \
  146                 } \
  147 } while (/*CONSTCOND*/ 0)
  148 #else
  149 #define UVMHIST_PRINTNOW(E) /* nothing */
  150 #endif
  151 
  152 #define UVMHIST_LOG(NAME,FMT,A,B,C,D) \
  153 do { \
  154         int _i_, _s_ = splhigh(); \
  155         simple_lock(&(NAME).l); \
  156         _i_ = (NAME).f; \
  157         (NAME).f = (_i_ + 1) % (NAME).n; \
  158         simple_unlock(&(NAME).l); \
  159         splx(_s_); \
  160         if (!cold) \
  161                 microtime(&(NAME).e[_i_].tv); \
  162         (NAME).e[_i_].cpunum = cpu_number(); \
  163         (NAME).e[_i_].fmt = (FMT); \
  164         (NAME).e[_i_].fmtlen = strlen((NAME).e[_i_].fmt); \
  165         (NAME).e[_i_].fn = _uvmhist_name; \
  166         (NAME).e[_i_].fnlen = strlen((NAME).e[_i_].fn); \
  167         (NAME).e[_i_].call = _uvmhist_call; \
  168         (NAME).e[_i_].v[0] = (u_long)(A); \
  169         (NAME).e[_i_].v[1] = (u_long)(B); \
  170         (NAME).e[_i_].v[2] = (u_long)(C); \
  171         (NAME).e[_i_].v[3] = (u_long)(D); \
  172         UVMHIST_PRINTNOW(&((NAME).e[_i_])); \
  173 } while (/*CONSTCOND*/ 0)
  174 
  175 #define UVMHIST_CALLED(NAME) \
  176 do { \
  177         { \
  178                 int s = splhigh(); \
  179                 simple_lock(&(NAME).l); \
  180                 _uvmhist_call = _uvmhist_cnt++; \
  181                 simple_unlock(&(NAME).l); \
  182                 splx(s); \
  183         } \
  184         UVMHIST_LOG(NAME,"called!", 0, 0, 0, 0); \
  185 } while (/*CONSTCOND*/ 0)
  186 
  187 #define UVMHIST_FUNC(FNAME) \
  188         static int _uvmhist_cnt = 0; \
  189         static char *_uvmhist_name = FNAME; \
  190         int _uvmhist_call;
  191 
  192 static __inline void uvmhist_print(struct uvm_history_ent *);
  193 
  194 static __inline void
  195 uvmhist_print(e)
  196         struct uvm_history_ent *e;
  197 {
  198         printf("%06ld.%06ld ", e->tv.tv_sec, e->tv.tv_usec);
  199         printf("%s#%ld@%d: ", e->fn, e->call, e->cpunum);
  200         printf(e->fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
  201         printf("\n");
  202 }
  203 #endif /* UVMHIST */
  204 
  205 #endif /* _KERNEL */
  206 
  207 #endif /* _UVM_UVM_STAT_H_ */

Cache object: 17df67d0137ef2bf8fd3fa1fed64abb5


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