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/sys/vmmeter.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 /*-
    2  * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 4. Neither the name of the University nor the names of its contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  *      @(#)vmmeter.h   8.2 (Berkeley) 7/10/94
   30  * $FreeBSD: releng/6.3/sys/sys/vmmeter.h 173886 2007-11-24 19:45:58Z cvs2svn $
   31  */
   32 
   33 #ifndef _SYS_VMMETER_H_
   34 #define _SYS_VMMETER_H_
   35 
   36 /*
   37  * System wide statistics counters.
   38  */
   39 struct vmmeter {
   40         /*
   41          * General system activity.
   42          */
   43         u_int v_swtch;          /* context switches */
   44         u_int v_trap;           /* calls to trap */
   45         u_int v_syscall;        /* calls to syscall() */
   46         u_int v_intr;           /* device interrupts */
   47         u_int v_soft;           /* software interrupts */
   48         /*
   49          * Virtual memory activity.
   50          */
   51         u_int v_vm_faults;      /* number of address memory faults */
   52         u_int v_cow_faults;     /* number of copy-on-writes */
   53         u_int v_cow_optim;      /* number of optimized copy-on-writes */
   54         u_int v_zfod;           /* pages zero filled on demand */
   55         u_int v_ozfod;          /* optimized zero fill pages */
   56         u_int v_swapin;         /* swap pager pageins */
   57         u_int v_swapout;        /* swap pager pageouts */
   58         u_int v_swappgsin;      /* swap pager pages paged in */
   59         u_int v_swappgsout;     /* swap pager pages paged out */
   60         u_int v_vnodein;        /* vnode pager pageins */
   61         u_int v_vnodeout;       /* vnode pager pageouts */
   62         u_int v_vnodepgsin;     /* vnode_pager pages paged in */
   63         u_int v_vnodepgsout;    /* vnode pager pages paged out */
   64         u_int v_intrans;        /* intransit blocking page faults */
   65         u_int v_reactivated;    /* number of pages reactivated from free list */
   66         u_int v_pdwakeups;      /* number of times daemon has awaken from sleep */
   67         u_int v_pdpages;        /* number of pages analyzed by daemon */
   68 
   69         u_int v_dfree;          /* pages freed by daemon */
   70         u_int v_pfree;          /* pages freed by exiting processes */
   71         u_int v_tfree;          /* total pages freed */
   72         /*
   73          * Distribution of page usages.
   74          */
   75         u_int v_page_size;      /* page size in bytes */
   76         u_int v_page_count;     /* total number of pages in system */
   77         u_int v_free_reserved;  /* number of pages reserved for deadlock */
   78         u_int v_free_target;    /* number of pages desired free */
   79         u_int v_free_min;       /* minimum number of pages desired free */
   80         u_int v_free_count;     /* number of pages free */
   81         u_int v_wire_count;     /* number of pages wired down */
   82         u_int v_active_count;   /* number of pages active */
   83         u_int v_inactive_target; /* number of pages desired inactive */
   84         u_int v_inactive_count; /* number of pages inactive */
   85         u_int v_cache_count;    /* number of pages on buffer cache queue */
   86         u_int v_cache_min;      /* min number of pages desired on cache queue */
   87         u_int v_cache_max;      /* max number of pages in cached obj */
   88         u_int v_pageout_free_min;   /* min number pages reserved for kernel */
   89         u_int v_interrupt_free_min; /* reserved number of pages for int code */
   90         u_int v_free_severe;    /* severe depletion of pages below this pt */
   91         /*
   92          * Fork/vfork/rfork activity.
   93          */
   94         u_int v_forks;          /* number of fork() calls */
   95         u_int v_vforks;         /* number of vfork() calls */
   96         u_int v_rforks;         /* number of rfork() calls */
   97         u_int v_kthreads;       /* number of fork() calls by kernel */
   98         u_int v_forkpages;      /* number of VM pages affected by fork() */
   99         u_int v_vforkpages;     /* number of VM pages affected by vfork() */
  100         u_int v_rforkpages;     /* number of VM pages affected by rfork() */
  101         u_int v_kthreadpages;   /* number of VM pages affected by fork() by kernel */
  102 };
  103 #ifdef _KERNEL
  104 
  105 extern struct vmmeter cnt;
  106 
  107 /*
  108  * Return TRUE if we are under our reserved low-free-pages threshold
  109  */
  110 
  111 static __inline 
  112 int
  113 vm_page_count_reserved(void)
  114 {
  115     return (cnt.v_free_reserved > (cnt.v_free_count + cnt.v_cache_count));
  116 }
  117 
  118 /*
  119  * Return TRUE if we are under our severe low-free-pages threshold
  120  *
  121  * This routine is typically used at the user<->system interface to determine
  122  * whether we need to block in order to avoid a low memory deadlock.
  123  */
  124 
  125 static __inline 
  126 int
  127 vm_page_count_severe(void)
  128 {
  129     return (cnt.v_free_severe > (cnt.v_free_count + cnt.v_cache_count));
  130 }
  131 
  132 /*
  133  * Return TRUE if we are under our minimum low-free-pages threshold.
  134  *
  135  * This routine is typically used within the system to determine whether
  136  * we can execute potentially very expensive code in terms of memory.  It
  137  * is also used by the pageout daemon to calculate when to sleep, when
  138  * to wake waiters up, and when (after making a pass) to become more
  139  * desparate.
  140  */
  141 
  142 static __inline 
  143 int
  144 vm_page_count_min(void)
  145 {
  146     return (cnt.v_free_min > (cnt.v_free_count + cnt.v_cache_count));
  147 }
  148 
  149 /*
  150  * Return TRUE if we have not reached our free page target during
  151  * free page recovery operations.
  152  */
  153 
  154 static __inline 
  155 int
  156 vm_page_count_target(void)
  157 {
  158     return (cnt.v_free_target > (cnt.v_free_count + cnt.v_cache_count));
  159 }
  160 
  161 /*
  162  * Return the number of pages we need to free-up or cache
  163  * A positive number indicates that we do not have enough free pages.
  164  */
  165 
  166 static __inline 
  167 int
  168 vm_paging_target(void)
  169 {
  170     return (
  171         (cnt.v_free_target + cnt.v_cache_min) - 
  172         (cnt.v_free_count + cnt.v_cache_count)
  173     );
  174 }
  175 
  176 /*
  177  * Returns TRUE if the pagedaemon needs to be woken up.
  178  */
  179 
  180 static __inline 
  181 int
  182 vm_paging_needed(void)
  183 {
  184     return (
  185         (cnt.v_free_reserved + cnt.v_cache_min) >
  186         (cnt.v_free_count + cnt.v_cache_count)
  187     );
  188 }
  189 
  190 #endif
  191 
  192 /* systemwide totals computed every five seconds */
  193 struct vmtotal {
  194         int16_t t_rq;           /* length of the run queue */
  195         int16_t t_dw;           /* jobs in ``disk wait'' (neg priority) */
  196         int16_t t_pw;           /* jobs in page wait */
  197         int16_t t_sl;           /* jobs sleeping in core */
  198         int16_t t_sw;           /* swapped out runnable/short block jobs */
  199         int32_t t_vm;           /* total virtual memory */
  200         int32_t t_avm;          /* active virtual memory */
  201         int32_t t_rm;           /* total real memory in use */
  202         int32_t t_arm;          /* active real memory */
  203         int32_t t_vmshr;        /* shared virtual memory */
  204         int32_t t_avmshr;       /* active shared virtual memory */
  205         int32_t t_rmshr;        /* shared real memory */
  206         int32_t t_armshr;       /* active shared real memory */
  207         int32_t t_free;         /* free memory pages */
  208 };
  209 
  210 #endif

Cache object: f657d7970b3402bee4777a85383c8bfb


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