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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
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/11.1/sys/sys/vmmeter.h 320693 2017-07-05 19:24:53Z markj $
   31  */
   32 
   33 #ifndef _SYS_VMMETER_H_
   34 #define _SYS_VMMETER_H_
   35 
   36 /*
   37  * This value is used by ps(1) to change sleep state flag from 'S' to
   38  * 'I' and by the sched process to set the alarm clock.
   39  */
   40 #define MAXSLP                  20
   41 
   42 /*
   43  * System wide statistics counters.
   44  * Locking:
   45  *      a - locked by atomic operations
   46  *      c - constant after initialization
   47  *      f - locked by vm_page_queue_free_mtx
   48  *      p - locked by being in the PCPU and atomicity respect to interrupts
   49  *      q - changes are synchronized by the corresponding vm_pagequeue lock
   50  */
   51 struct vmmeter {
   52         /*
   53          * General system activity.
   54          */
   55         u_int v_swtch;          /* (p) context switches */
   56         u_int v_trap;           /* (p) calls to trap */
   57         u_int v_syscall;        /* (p) calls to syscall() */
   58         u_int v_intr;           /* (p) device interrupts */
   59         u_int v_soft;           /* (p) software interrupts */
   60         /*
   61          * Virtual memory activity.
   62          */
   63         u_int v_vm_faults;      /* (p) address memory faults */
   64         u_int v_io_faults;      /* (p) page faults requiring I/O */
   65         u_int v_cow_faults;     /* (p) copy-on-writes faults */
   66         u_int v_cow_optim;      /* (p) optimized copy-on-writes faults */
   67         u_int v_zfod;           /* (p) pages zero filled on demand */
   68         u_int v_ozfod;          /* (p) optimized zero fill pages */
   69         u_int v_swapin;         /* (p) swap pager pageins */
   70         u_int v_swapout;        /* (p) swap pager pageouts */
   71         u_int v_swappgsin;      /* (p) swap pager pages paged in */
   72         u_int v_swappgsout;     /* (p) swap pager pages paged out */
   73         u_int v_vnodein;        /* (p) vnode pager pageins */
   74         u_int v_vnodeout;       /* (p) vnode pager pageouts */
   75         u_int v_vnodepgsin;     /* (p) vnode_pager pages paged in */
   76         u_int v_vnodepgsout;    /* (p) vnode pager pages paged out */
   77         u_int v_intrans;        /* (p) intransit blocking page faults */
   78         u_int v_reactivated;    /* (p) pages reactivated by the pagedaemon */
   79         u_int v_pdwakeups;      /* (p) times daemon has awaken from sleep */
   80         u_int v_pdpages;        /* (p) pages analyzed by daemon */
   81         u_int v_pdshortfalls;   /* (p) page reclamation shortfalls */
   82 
   83         u_int v_tcached;        /* (p) total pages cached */
   84         u_int v_dfree;          /* (p) pages freed by daemon */
   85         u_int v_pfree;          /* (p) pages freed by exiting processes */
   86         u_int v_tfree;          /* (p) total pages freed */
   87         /*
   88          * Distribution of page usages.
   89          */
   90         u_int v_page_size;      /* (c) page size in bytes */
   91         u_int v_page_count;     /* (c) total number of pages in system */
   92         u_int v_free_reserved;  /* (c) pages reserved for deadlock */
   93         u_int v_free_target;    /* (c) pages desired free */
   94         u_int v_free_min;       /* (c) pages desired free */
   95         u_int v_free_count;     /* (f) pages free */
   96         u_int v_wire_count;     /* (a) pages wired down */
   97         u_int v_active_count;   /* (q) pages active */
   98         u_int v_inactive_target; /* (c) pages desired inactive */
   99         u_int v_inactive_count; /* (q) pages inactive */
  100         u_int v_laundry_count;  /* (q) pages eligible for laundering */
  101         u_int v_cache_count;    /* (f) pages on cache queue */
  102         u_int v_pageout_free_min;   /* (c) min pages reserved for kernel */
  103         u_int v_interrupt_free_min; /* (c) reserved pages for int code */
  104         u_int v_free_severe;    /* (c) severe page depletion point */
  105         /*
  106          * Fork/vfork/rfork activity.
  107          */
  108         u_int v_forks;          /* (p) fork() calls */
  109         u_int v_vforks;         /* (p) vfork() calls */
  110         u_int v_rforks;         /* (p) rfork() calls */
  111         u_int v_kthreads;       /* (p) fork() calls by kernel */
  112         u_int v_forkpages;      /* (p) VM pages affected by fork() */
  113         u_int v_vforkpages;     /* (p) VM pages affected by vfork() */
  114         u_int v_rforkpages;     /* (p) VM pages affected by rfork() */
  115         u_int v_kthreadpages;   /* (p) VM pages affected by fork() by kernel */
  116 };
  117 #ifdef _KERNEL
  118 
  119 extern struct vmmeter vm_cnt;
  120 
  121 extern u_int vm_pageout_wakeup_thresh;
  122 
  123 /*
  124  * Return TRUE if we are under our severe low-free-pages threshold
  125  *
  126  * This routine is typically used at the user<->system interface to determine
  127  * whether we need to block in order to avoid a low memory deadlock.
  128  */
  129 static inline int
  130 vm_page_count_severe(void)
  131 {
  132 
  133         return (vm_cnt.v_free_severe > vm_cnt.v_free_count);
  134 }
  135 
  136 /*
  137  * Return TRUE if we are under our minimum low-free-pages threshold.
  138  *
  139  * This routine is typically used within the system to determine whether
  140  * we can execute potentially very expensive code in terms of memory.  It
  141  * is also used by the pageout daemon to calculate when to sleep, when
  142  * to wake waiters up, and when (after making a pass) to become more
  143  * desperate.
  144  */
  145 static inline int
  146 vm_page_count_min(void)
  147 {
  148 
  149         return (vm_cnt.v_free_min > vm_cnt.v_free_count);
  150 }
  151 
  152 /*
  153  * Return TRUE if we have not reached our free page target during
  154  * free page recovery operations.
  155  */
  156 static inline int
  157 vm_page_count_target(void)
  158 {
  159 
  160         return (vm_cnt.v_free_target > vm_cnt.v_free_count);
  161 }
  162 
  163 /*
  164  * Return the number of pages we need to free-up or cache
  165  * A positive number indicates that we do not have enough free pages.
  166  */
  167 static inline int
  168 vm_paging_target(void)
  169 {
  170 
  171         return (vm_cnt.v_free_target - vm_cnt.v_free_count);
  172 }
  173 
  174 /*
  175  * Returns TRUE if the pagedaemon needs to be woken up.
  176  */
  177 static inline int
  178 vm_paging_needed(void)
  179 {
  180 
  181         return (vm_cnt.v_free_count < vm_pageout_wakeup_thresh);
  182 }
  183 
  184 /*
  185  * Return the number of pages we need to launder.
  186  * A positive number indicates that we have a shortfall of clean pages.
  187  */
  188 static inline int
  189 vm_laundry_target(void)
  190 {
  191 
  192         return (vm_paging_target());
  193 }
  194 
  195 /*
  196  * Obtain the value of a per-CPU counter.
  197  */
  198 #define VM_METER_PCPU_CNT(member)                                       \
  199         vm_meter_cnt(__offsetof(struct vmmeter, member))
  200 
  201 u_int   vm_meter_cnt(size_t);
  202 
  203 #endif
  204 
  205 /* systemwide totals computed every five seconds */
  206 struct vmtotal {
  207         int16_t t_rq;           /* length of the run queue */
  208         int16_t t_dw;           /* jobs in ``disk wait'' (neg priority) */
  209         int16_t t_pw;           /* jobs in page wait */
  210         int16_t t_sl;           /* jobs sleeping in core */
  211         int16_t t_sw;           /* swapped out runnable/short block jobs */
  212         int32_t t_vm;           /* total virtual memory */
  213         int32_t t_avm;          /* active virtual memory */
  214         int32_t t_rm;           /* total real memory in use */
  215         int32_t t_arm;          /* active real memory */
  216         int32_t t_vmshr;        /* shared virtual memory */
  217         int32_t t_avmshr;       /* active shared virtual memory */
  218         int32_t t_rmshr;        /* shared real memory */
  219         int32_t t_armshr;       /* active shared real memory */
  220         int32_t t_free;         /* free memory pages */
  221 };
  222 
  223 #endif

Cache object: 94ae1f07ceb5909b56a8f9d8d6fd8c1a


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