home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / vm / trace.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  11.3 KB  |  354 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. /*
  11.  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12.  *         PROPRIETARY NOTICE (Combined)
  13.  * 
  14.  * This source code is unpublished proprietary information
  15.  * constituting, or derived under license from AT&T's UNIX(r) System V.
  16.  * In addition, portions of such source code were derived from Berkeley
  17.  * 4.3 BSD under license from the Regents of the University of
  18.  * California.
  19.  * 
  20.  * 
  21.  * 
  22.  *         Copyright Notice 
  23.  * 
  24.  * Notice of copyright on this source code product does not indicate 
  25.  * publication.
  26.  * 
  27.  *     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  28.  *     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  29.  *               All rights reserved.
  30.  *  
  31.  */
  32.  
  33. #ifndef _VM_TRACE_H
  34. #define _VM_TRACE_H
  35.  
  36. #ident    "@(#)/usr/include/vm/trace.h.sl 1.1 4.0 12/08/90 18658 AT&T-USL"
  37.  
  38. /*
  39.  * Trace point definitions.  Beware of conflicts with the
  40.  * window system keyboard translation macros (TR_ASCII et al).
  41.  *
  42.  * The set of active trace points is recorded in the variable
  43.  * tracedevents.  Because we declare this variable as an fd_set,
  44.  * the maximum allowable trace point index is bounded by FD_SETSIZE.
  45.  *
  46.  * For the most part, these trace points are quite specific to SunOS 4.0.
  47.  *
  48.  * The trace point definitions follow stringent conventions for the benefit
  49.  * of postprocessors wishing to manipulate trace information.  The names
  50.  * all start with TR_, and each definition is followed on the next line by
  51.  * a comment whose content is a printf-like formatting string.  Successive
  52.  * format items are fed by successive tr_datum* values from the current
  53.  * trace item.  The only unusual format is %C, which is followed by an angle
  54.  * bracketed, comma separated list of (unquoted) strings, the i-th of which
  55.  * is to be printed when the associated value is i (0-origin).
  56.  *
  57.  * Note that the current trace points confine themselves to the C, d, and
  58.  * x formats so that postprocessors can confine themselves to supporting
  59.  * only these formats.  This situation may change when additional trace
  60.  * points are defined.
  61.  */
  62.  
  63. /*
  64.  * User-level trace annotation.
  65.  */
  66. #define TR_STAMP        0    /* user: vtrace(VTR_STAMP, value); */
  67. /* "value %d pid %d" */
  68.  
  69. /*
  70.  * Paging trace points.  The TR_PG_* trace points all start by recording
  71.  * pp, vp, and off values.
  72.  */
  73. #define TR_PG_POCLEAN        1    /* about to clean a page in pageout */
  74. /* "pp %x vp %x off %d hand %d freemem %d" */
  75. #define TR_PG_POFREE        2    /* add page to free list in pageout */
  76. /* "pp %x vp %x off %d hand %d freemem %d" */
  77. #define TR_PG_RECLAIM        3    /* page obtained in page_reclaim */
  78. /* "pp %x vp %x off %d ap %x age %d freemem %d" */
  79. #define TR_PG_ENTER        4 /* page_enter: page assoc. with <vp,off> */
  80. /* "pp %x vp %x off %d retval %d" */
  81. #define TR_PG_ABORT        5 /* page_abort: page disassoc. w/ <vp,off> */
  82. /* "pp %x vp %x off %d code %C<aborted,kept,intrans>" */
  83. #define TR_PG_FREE        6    /* call to page_free */
  84. /* "pp %x vp %x off %d dontneed %d freemem %d code %C<gone,free,cachetl,cachehd>" */
  85. #define TR_PG_ALLOC        7    /* single page allocated in page_get */
  86. /* "pp %x vp %x off %d age %d fromcache %d" */
  87. #define TR_PG_SEGMAP_FLT    8    /* segmap_fault sets p_ref = 1 */
  88. /* "pp %x vp %x off %d softlock %d" */
  89. #define TR_PG_SEGVN_FLT        9    /* segvn_fault sets p_ref = 1 */
  90. /* "pp %x vp %x off %d softlock %d" */
  91. #define TR_PG_PVN_DONE        10    /* pvn_done sets p_gone = 1 */
  92. /* "pp %x vp %x off %d" */
  93. #define TR_PG_PVN_GETDIRTY    11    /* pvn_getdirty sets p_ref = 0 */
  94. /* "pp %x vp %x off %d" */
  95. #define TR_PG_HAT_NEWSEG    12    /* hat_newseg OR's p_ref */
  96. /* "pp %x vp %x off %d referenced %d" */
  97. #define TR_PG_HAT_GETPME    13    /* hat_getpme OR's p_ref */
  98. /* "pp %x vp %x off %d referenced %d" */
  99. #define TR_PG_POREF        14    /* clock hand finds p_ref == 1 */
  100. /* "pp %x vp %x off %d hand %d" */
  101.  
  102. #define TR_PAGE_GET_SLEEP    19    /* sleep during page alloc request */
  103. /* "bytes %x canwait %d freemem %d after? %d" */
  104. #define TR_PAGE_GET        20    /* page allocation request */
  105. /* "bytes %x canwait %d freemem %d code %C<allocated,toobig,nomem>" */
  106.  
  107. /*
  108.  * Page abort codes
  109.  */
  110. #define TRC_ABORT_ABORTED    0
  111. #define TRC_ABORT_KEPT        1
  112. #define TRC_ABORT_INTRANS    2
  113.  
  114. /*
  115.  * Page free codes
  116.  */
  117. #define TRC_FREE_GONE        0
  118. #define TRC_FREE_FREE        1
  119. #define TRC_FREE_CACHETL    2
  120. #define TRC_FREE_CACHEHD    3
  121.  
  122. /*
  123.  * Page get codes
  124.  */
  125. #define TRC_GET_ALLOCATED    0
  126. #define TRC_GET_TOOBIG        1
  127. #define TRC_GET_NOMEM        2
  128. /*
  129.  * File system buffer tracing points; all trace <dev, bn>
  130.  */
  131. #define TR_BREADHIT        21    /* buffer read found in cache */
  132. /* "" */
  133. #define TR_BREADMISS        22    /* buffer read not in cache */
  134. /* "" */
  135. #define TR_BWRITE        23    /* buffer written */
  136. /* "" */
  137. #define TR_BRELSE        24    /* brelse */
  138. /* "" */
  139.  
  140. /*
  141.  *  Calibration trace record
  142.  */
  143. #define TR_CALIBRATE        30    /* calibration point in hardclock */
  144. /* "seqnum %d sec %d usec %d" */
  145.  
  146. /*
  147.  * Paging daemon trace points
  148.  */
  149. #define TR_PAGEOUT        31    /* pageout daemon statistics */
  150. /* "after? %d nscan %d desscan %d freemem %d lotsfree %d" */
  151. #define TR_PAGEOUT_CALL        32    /* pageout daemon call */
  152. /* "callpoint %C<getnpage,getfrlw,schedcpu,schedpag,swdone>" */
  153. #define TR_PAGEOUT_MAXPGIO    33    /* pushes > maxpgio in checkpage */
  154. /* "freemem %d nscan %d" */
  155. #define TR_PAGEOUT_WRAP        34    /* front clock hand wrap around */
  156. /* "freemem %d hand %d" */
  157. /*
  158.  * Pageout daemon call location codes
  159.  */
  160. #define TRC_POCALL_GETNPAGE    0
  161. #define TRC_POCALL_GETFRLW    1
  162. #define TRC_POCALL_SCHEDCPU    2
  163. #define TRC_POCALL_SCHEDPAG    3
  164. #define TRC_POCALL_SWDONE    4
  165.  
  166. /*
  167.  * Mapping of objects to vnode and <vnode, offset> values
  168.  */
  169. #define TR_MP_SWAP        40    /* allocate a page of swap */
  170. /* "vp %x off %d ap %x" */
  171. #define TR_MP_LNODE        41    /* allocate an lnode */
  172. /* "vp %x lvp %x" */
  173. #define TR_MP_SNODE        42    /* allocate an snode */
  174. /* "vp %x dev %x makespecvp %d" */
  175. #define TR_MP_INODE        43    /* allocate an inode */
  176. /* "vp %x dev %x inode %x" */
  177. #define TR_MP_RNODE        44    /* allocate an rnode */
  178. /* "vp %x fsid %x %x len %x fid %x %x" */
  179. #define TR_MP_TRUNC0        45    /* truncate file to zero length */
  180. /* "vp %x" */
  181. #define TR_MP_TRUNC        46    /* truncate file */
  182. /* "vp %x newlen %d oldlen %d" */
  183.  
  184. /*
  185.  * Segment trace points
  186.  */
  187. #define TR_SEG_GETMAP        50    /* get a segmap */
  188. /* "seg %x addr %d type %C<kseg,segkmap,anon,file,unk> vp %x off %d" */
  189. #define TR_SEG_RELMAP        51    /* release a segmap */
  190. /* "seg %x addr %d type %C<kseg,segkmap,anon,file,unk> refcnt %d" */
  191. #define TR_SEG_ALLOCPAGE    52    /* call to rm_allocpage */
  192. /* "seg %x addr %d type %C<kseg,segkmap,anon,file,unk> vp %x off %d pp %x" */
  193. #define TR_SEG_GETPAGE        53    /* call to VOP_GETPAGE */
  194. /* "seg %x addr %d type %C<kseg,segkmap,anon,file,unk>" */
  195. #define TR_SEG_KLUSTER        54    /* call to pvn_kluster */
  196. /* "seg %x addr %d readahead %d" */
  197.  
  198. /*
  199.  * Segment type codes
  200.  */
  201. #define TRC_SEG_KSEG        0
  202. #define TRC_SEG_SEGKMAP        1
  203. #define TRC_SEG_ANON        2
  204. #define TRC_SEG_FILE        3
  205. #define TRC_SEG_UNK        4
  206.  
  207. /*
  208.  * Process trace points
  209.  */
  210. #define TR_PR_WAKEUP        60    /* before call to wakeup */
  211. /* "ptime %d cpu %d stime %d runout %d" */
  212.  
  213. /*
  214.  * Swapper trace points
  215.  */
  216. #define TR_SWAP_LOOP        70    /* at loop: in sched */
  217. /* "mapwant %d avenrun %d avefree %d avefree30 %d pginrate %d pgoutrate %d" */
  218. #define TR_SWAP_OUT        71    /* call to swapout */
  219. /* "proc %x hardwap? %d freed %d" */
  220. #define TR_SWAP_SLEEP        72    /* sched calls sleep() */
  221. /* "chan %x runin %d runout %d wantin %d" */
  222. #define TR_SWAP_IN_CHECK    73    /* decision point on calling swapin */
  223. /* "proc %x freemem %d deficit %d needs %d outpri %d maxslp %d" */
  224. #define TR_SWAP_OUT_CHECK    74    /* decision point on calling swapout */
  225. /* "proc %x sleeper %d desperate %d deservin %d inpri %d maxslp %d" */
  226. #define TR_SWAP_IN        75    /* call to swapin */
  227. /* "proc %x taken %d" */
  228. #define TR_SWAP_OUT_CHECK0    76    /* decision point on calling swapout */
  229. /* "proc %x freemem %d rssize %d slptime %d maxslp %d swappable %x" */
  230.  
  231. /*
  232.  * ufs trace points
  233.  */
  234. #define TR_UFS_RWIP        80    /* call to rwip */
  235. /* "inode %x uio %x rw %x ioflag %d offset %d location %C<enter,getmap,bmapalloc,uiomove,release,iupdat,return>" */
  236.  
  237. /*
  238.  * rwip location type codes
  239.  */
  240. #define TRC_RWIP_ENTER        0
  241. #define TRC_RWIP_GETMAP        1
  242. #define TRC_RWIP_BMAPALLOC    2
  243. #define TRC_RWIP_UIOMOVE    3
  244. #define TRC_RWIP_RELEASE    4
  245. #define TRC_RWIP_IUPDAT        5
  246. #define TRC_RWIP_RETURN        6
  247.  
  248. /*
  249.  * Memory allocator trace points; all trace the amount of memory involved.
  250.  */
  251.  
  252. /*
  253.  * System call trace points.
  254.  */
  255.  
  256. /*
  257.  * Parameters needed for trace post-processing.  Be careful to keep this
  258.  * up-to-date.  MAXTRACEID is the highest number used for a trace id.
  259.  * MAXTRACECODE is the highest number used to represent a code, for example
  260.  * the codes for TR_PG_FREE are gone, free, cachetl, and cachehd.  These are
  261.  * represented as 0, 1, 2, and 3, respectively.  If 3 were the highest code
  262.  * used for any trace point, that would be the value of MAXTRACECODE.
  263.  
  264.  */
  265. #define MAXTRACEID    TR_UFS_RWIP
  266. #define MAXTRACECODE    TRC_RWIP_RETURN
  267.  
  268. /*
  269.  * Generic format for data saved with trace calls.
  270.  *
  271.  * The format of tr_time varies depending on whether or not there's
  272.  * a high resolution timer available.  If so, it's the timer's value;
  273.  * if not, it's the low 16 bits of hrestime.tv_sec concatenated to the
  274.  * high 16 bits of hrestime.tv_usec.  Tr_pid records the process active
  275.  * at the time of the trace call; it's not meaningful if called from
  276.  * interrupt level.
  277.  */
  278. struct trace_rec {
  279.     u_long    tr_time;
  280.     short    tr_tag;
  281.     u_short    tr_pid;
  282.     u_long    tr_datum0;
  283.     u_long    tr_datum1;
  284.     u_long    tr_datum2;
  285.     u_long    tr_datum3;
  286.     u_long    tr_datum4;
  287.     u_long    tr_datum5;
  288. };
  289.  
  290.  
  291.  
  292. /*
  293.  * Requests for the vtrace() system call.
  294.  */
  295. #define VTR_DISABLE    0        /* trace specified events */
  296. #define VTR_ENABLE    1        /* don't trace specified events */
  297. #define VTR_VALUE    2        /* return currently-traced events */
  298. #define VTR_STAMP    3        /* cause TR_STAMP event */
  299. #define VTR_RESET    4        /* reset eventstraced to zero */
  300.  
  301. #ifdef    _KERNEL
  302. #ifdef    TRACE
  303.  
  304. extern fd_set    tracedevents;
  305. extern u_int    tracebufents;
  306. extern u_int    eventstraced;
  307. extern struct    trace_rec *tracebuffer;
  308. extern void    inittrace();
  309. extern void    resettracebuf();
  310. extern void    traceit();
  311.  
  312. #define pack(a, b)    ((a)<<16)|(b)
  313.  
  314. /*
  315.  * Lint doesn't believe that there are valid reasons for comparing
  316.  * constants to each other...
  317.  */
  318. #ifdef    lint
  319. #define trace(ev, d0, d1, d2, d3, d4, d5) \
  320.     if (FD_ISSET((ev), &tracedevents)) \
  321.         traceit((ev), (u_long)(d0), (u_long)(d1), (u_long)(d2), \
  322.             (u_long)(d3), (u_long)(d4), (u_long)(d5))
  323. #else    /* lint */
  324. #define trace(ev, d0, d1, d2, d3, d4, d5) \
  325.     if ((u_int)(ev) < FD_SETSIZE && FD_ISSET((ev), &tracedevents)) \
  326.         traceit((ev), (u_long)(d0), (u_long)(d1), (u_long)(d2), \
  327.             (u_long)(d3), (u_long)(d4), (u_long)(d5))
  328. #endif    /* lint */
  329.  
  330. #define trace6(ev, d0, d1, d2, d3, d4, d5) \
  331.     trace(ev, d0, d1, d2, d3, d4, d5)
  332. #define trace5(ev, d0, d1, d2, d3, d4)    trace(ev, d0, d1, d2, d3, d4, 0)
  333. #define trace4(ev, d0, d1, d2, d3)    trace(ev, d0, d1, d2, d3, 0, 0)
  334. #define trace3(ev, d0, d1, d2)        trace(ev, d0, d1, d2, 0, 0, 0)
  335. #define trace2(ev, d0, d1)        trace(ev, d0, d1, 0, 0, 0, 0)
  336. #define trace1(ev, d0)            trace(ev, d0, 0, 0, 0, 0, 0)
  337.  
  338. #else    /* TRACE */
  339.  
  340. #define pack(a, b)
  341.  
  342. #define trace    trace6
  343. #define trace6(ev, d0, d1, d2, d3, d4, d5)
  344. #define trace5(ev, d0, d1, d2, d3, d4)
  345. #define trace4(ev, d0, d1, d2, d3)
  346. #define trace3(ev, d0, d1, d2)
  347. #define trace2(ev, d0, d1)
  348. #define trace1(ev, d0)
  349.  
  350. #endif    /* TRACE */
  351. #endif    /* _KERNEL */
  352.  
  353. #endif    /* _VM_TRACE_H */
  354.