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/ktr.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) 1996 Berkeley Software Design, Inc. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
   10  *    notice, this list of conditions and the following disclaimer in the
   11  *    documentation and/or other materials provided with the distribution.
   12  * 3. Berkeley Software Design Inc's name may not be used to endorse or
   13  *    promote products derived from this software without specific prior
   14  *    written permission.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  *      from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $
   29  * $FreeBSD: releng/9.0/sys/sys/ktr.h 222813 2011-06-07 08:46:13Z attilio $
   30  */
   31 
   32 /*
   33  *      Wraparound kernel trace buffer support.
   34  */
   35 
   36 #ifndef _SYS_KTR_H_
   37 #define _SYS_KTR_H_
   38 
   39 /*
   40  * Trace classes
   41  *
   42  * Two of the trace classes (KTR_DEV and KTR_SUBSYS) are special in that
   43  * they are really placeholders so that indvidual drivers and subsystems
   44  * can map their internal tracing to the general class when they wish to
   45  * have tracing enabled and map it to 0 when they don't.
   46  */
   47 #define KTR_GEN         0x00000001              /* General (TR) */
   48 #define KTR_NET         0x00000002              /* Network */
   49 #define KTR_DEV         0x00000004              /* Device driver */
   50 #define KTR_LOCK        0x00000008              /* MP locking */
   51 #define KTR_SMP         0x00000010              /* MP general */
   52 #define KTR_SUBSYS      0x00000020              /* Subsystem. */
   53 #define KTR_PMAP        0x00000040              /* Pmap tracing */
   54 #define KTR_MALLOC      0x00000080              /* Malloc tracing */
   55 #define KTR_TRAP        0x00000100              /* Trap processing */
   56 #define KTR_INTR        0x00000200              /* Interrupt tracing */
   57 #define KTR_SIG         0x00000400              /* Signal processing */
   58 #define KTR_SPARE2      0x00000800              /* XXX Used by cxgb */
   59 #define KTR_PROC        0x00001000              /* Process scheduling */
   60 #define KTR_SYSC        0x00002000              /* System call */
   61 #define KTR_INIT        0x00004000              /* System initialization */
   62 #define KTR_SPARE3      0x00008000              /* XXX Used by cxgb */
   63 #define KTR_SPARE4      0x00010000              /* XXX Used by cxgb */
   64 #define KTR_EVH         0x00020000              /* Eventhandler */
   65 #define KTR_VFS         0x00040000              /* VFS events */
   66 #define KTR_VOP         0x00080000              /* Auto-generated vop events */
   67 #define KTR_VM          0x00100000              /* The virtual memory system */
   68 #define KTR_INET        0x00200000              /* IPv4 stack */
   69 #define KTR_RUNQ        0x00400000              /* Run queue */
   70 #define KTR_CONTENTION  0x00800000              /* Lock contention */
   71 #define KTR_UMA         0x01000000              /* UMA slab allocator */
   72 #define KTR_CALLOUT     0x02000000              /* Callouts and timeouts */
   73 #define KTR_GEOM        0x04000000              /* GEOM I/O events */
   74 #define KTR_BUSDMA      0x08000000              /* busdma(9) events */
   75 #define KTR_INET6       0x10000000              /* IPv6 stack */
   76 #define KTR_SCHED       0x20000000              /* Machine parsed sched info. */
   77 #define KTR_BUF         0x40000000              /* Buffer cache */
   78 #define KTR_ALL         0x7fffffff
   79 
   80 /* Trace classes to compile in */
   81 #ifdef KTR
   82 #ifndef KTR_COMPILE
   83 #define KTR_COMPILE     (KTR_ALL)
   84 #endif
   85 #else   /* !KTR */
   86 #undef KTR_COMPILE
   87 #define KTR_COMPILE 0
   88 #endif  /* KTR */
   89 
   90 /*
   91  * Version number for ktr_entry struct.  Increment this when you break binary
   92  * compatibility.
   93  */
   94 #define KTR_VERSION     2
   95 
   96 #define KTR_PARMS       6
   97 
   98 #ifndef LOCORE
   99 
  100 #include <sys/param.h>
  101 #include <sys/_cpuset.h>
  102 
  103 struct ktr_entry {
  104         u_int64_t ktr_timestamp;
  105         int     ktr_cpu;
  106         int     ktr_line;
  107         const   char *ktr_file;
  108         const   char *ktr_desc;
  109         struct  thread *ktr_thread;
  110         u_long  ktr_parms[KTR_PARMS];
  111 };
  112 
  113 extern cpuset_t ktr_cpumask;
  114 extern int ktr_mask;
  115 extern int ktr_entries;
  116 extern int ktr_verbose;
  117 
  118 extern volatile int ktr_idx;
  119 extern struct ktr_entry ktr_buf[];
  120 
  121 #ifdef KTR
  122 
  123 void    ktr_tracepoint(u_int mask, const char *file, int line,
  124             const char *format, u_long arg1, u_long arg2, u_long arg3,
  125             u_long arg4, u_long arg5, u_long arg6);
  126 
  127 #define CTR6(m, format, p1, p2, p3, p4, p5, p6) do {                    \
  128         if (KTR_COMPILE & (m))                                          \
  129                 ktr_tracepoint((m), __FILE__, __LINE__, format,         \
  130                     (u_long)(p1), (u_long)(p2), (u_long)(p3),           \
  131                     (u_long)(p4), (u_long)(p5), (u_long)(p6));          \
  132         } while(0)
  133 #define CTR0(m, format)                 CTR6(m, format, 0, 0, 0, 0, 0, 0)
  134 #define CTR1(m, format, p1)             CTR6(m, format, p1, 0, 0, 0, 0, 0)
  135 #define CTR2(m, format, p1, p2)         CTR6(m, format, p1, p2, 0, 0, 0, 0)
  136 #define CTR3(m, format, p1, p2, p3)     CTR6(m, format, p1, p2, p3, 0, 0, 0)
  137 #define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0)
  138 #define CTR5(m, format, p1, p2, p3, p4, p5)     CTR6(m, format, p1, p2, p3, p4, p5, 0)
  139 #else   /* KTR */
  140 #define CTR0(m, d)                      (void)0
  141 #define CTR1(m, d, p1)                  (void)0
  142 #define CTR2(m, d, p1, p2)              (void)0
  143 #define CTR3(m, d, p1, p2, p3)          (void)0
  144 #define CTR4(m, d, p1, p2, p3, p4)      (void)0
  145 #define CTR5(m, d, p1, p2, p3, p4, p5)  (void)0
  146 #define CTR6(m, d, p1, p2, p3, p4, p5, p6)      (void)0
  147 #endif  /* KTR */
  148 
  149 #define TR0(d)                          CTR0(KTR_GEN, d)
  150 #define TR1(d, p1)                      CTR1(KTR_GEN, d, p1)
  151 #define TR2(d, p1, p2)                  CTR2(KTR_GEN, d, p1, p2)
  152 #define TR3(d, p1, p2, p3)              CTR3(KTR_GEN, d, p1, p2, p3)
  153 #define TR4(d, p1, p2, p3, p4)          CTR4(KTR_GEN, d, p1, p2, p3, p4)
  154 #define TR5(d, p1, p2, p3, p4, p5)      CTR5(KTR_GEN, d, p1, p2, p3, p4, p5)
  155 #define TR6(d, p1, p2, p3, p4, p5, p6)  CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6)
  156 
  157 /*
  158  * The event macros implement KTR graphic plotting facilities provided
  159  * by src/tools/sched/schedgraph.py.  Three generic types of events are
  160  * supported: states, counters, and points.
  161  *
  162  * m is the ktr class for ktr_mask.
  163  * ident is the string identifier that owns the event (ie: "thread 10001")
  164  * etype is the type of event to plot (state, counter, point)
  165  * edat is the event specific data (state name, counter value, point name)
  166  * up to four attributes may be supplied as a name, value pair of arguments.
  167  *
  168  * etype and attribute names must be string constants.  This minimizes the
  169  * number of ktr slots required by construction the final format strings
  170  * at compile time.  Both must also include a colon and format specifier
  171  * (ie. "prio:%d", prio).  It is recommended that string arguments be
  172  * contained within escaped quotes if they may contain ',' or ':' characters.
  173  *
  174  * The special attribute (KTR_ATTR_LINKED, ident) creates a reference to another
  175  * id on the graph for easy traversal of related graph elements.
  176  */
  177 
  178 #define KTR_ATTR_LINKED "linkedto:\"%s\""
  179 #define KTR_EFMT(egroup, ident, etype)                                  \
  180             "KTRGRAPH group:\"" egroup "\", id:\"%s\", " etype ", attributes: "
  181 
  182 #define KTR_EVENT0(m, egroup, ident, etype, edat)                       \
  183         CTR2(m, KTR_EFMT(egroup, ident, etype) "none", ident, edat)
  184 #define KTR_EVENT1(m, egroup, ident, etype, edat, a0, v0)               \
  185         CTR3(m, KTR_EFMT(egroup, ident, etype) a0, ident, edat, (v0))
  186 #define KTR_EVENT2(m, egroup, ident, etype, edat, a0, v0, a1, v1)       \
  187         CTR4(m, KTR_EFMT(egroup, ident, etype) a0 ", " a1,              \
  188             ident, edat, (v0), (v1))
  189 #define KTR_EVENT3(m, egroup, ident, etype, edat, a0, v0, a1, v1, a2, v2)\
  190         CTR5(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2,       \
  191             ident, edat, (v0), (v1), (v2))
  192 #define KTR_EVENT4(m, egroup, ident, etype, edat,                       \
  193             a0, v0, a1, v1, a2, v2, a3, v3)                             \
  194         CTR6(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2 ", " a3,\
  195              ident, edat, (v0), (v1), (v2), (v3))
  196 
  197 /*
  198  * State functions graph state changes on an ident.
  199  */
  200 #define KTR_STATE0(m, egroup, ident, state)                             \
  201         KTR_EVENT0(m, egroup, ident, "state:\"%s\"", state)
  202 #define KTR_STATE1(m, egroup, ident, state, a0, v0)                     \
  203         KTR_EVENT1(m, egroup, ident, "state:\"%s\"", state, a0, (v0))
  204 #define KTR_STATE2(m, egroup, ident, state, a0, v0, a1, v1)             \
  205         KTR_EVENT2(m, egroup, ident, "state:\"%s\"", state, a0, (v0), a1, (v1))
  206 #define KTR_STATE3(m, egroup, ident, state, a0, v0, a1, v1, a2, v2)     \
  207         KTR_EVENT3(m, egroup, ident, "state:\"%s\"",                    \
  208             state, a0, (v0), a1, (v1), a2, (v2))
  209 #define KTR_STATE4(m, egroup, ident, state, a0, v0, a1, v1, a2, v2, a3, v3)\
  210         KTR_EVENT4(m, egroup, ident, "state:\"%s\"",                    \
  211             state, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  212 
  213 /*
  214  * Counter functions graph counter values.  The counter id
  215  * must not be intermixed with a state id. 
  216  */
  217 #define KTR_COUNTER0(m, egroup, ident, counter)                         \
  218         KTR_EVENT0(m, egroup, ident, "counter:%d", counter)
  219 #define KTR_COUNTER1(m, egroup, ident, edat, a0, v0)                    \
  220         KTR_EVENT1(m, egroup, ident, "counter:%d", counter, a0, (v0))
  221 #define KTR_COUNTER2(m, egroup, ident, counter, a0, v0, a1, v1)         \
  222         KTR_EVENT2(m, egroup, ident, "counter:%d", counter, a0, (v0), a1, (v1))
  223 #define KTR_COUNTER3(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2) \
  224         KTR_EVENT3(m, egroup, ident, "counter:%d",                      \
  225             counter, a0, (v0), a1, (v1), a2, (v2))
  226 #define KTR_COUNTER4(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2, a3, v3)\
  227         KTR_EVENT4(m, egroup, ident, "counter:%d",                      \
  228             counter, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  229 
  230 /*
  231  * Point functions plot points of interest on counter or state graphs.
  232  */
  233 #define KTR_POINT0(m, egroup, ident, point)                             \
  234         KTR_EVENT0(m, egroup, ident, "point:\"%s\"", point)
  235 #define KTR_POINT1(m, egroup, ident, point, a0, v0)                     \
  236         KTR_EVENT1(m, egroup, ident, "point:\"%s\"", point, a0, (v0))
  237 #define KTR_POINT2(m, egroup, ident, point, a0, v0, a1, v1)             \
  238         KTR_EVENT2(m, egroup, ident, "point:\"%s\"", point, a0, (v0), a1, (v1))
  239 #define KTR_POINT3(m, egroup, ident, point, a0, v0, a1, v1, a2, v2)     \
  240         KTR_EVENT3(m, egroup, ident, "point:\"%s\"", point,             \
  241             a0, (v0), a1, (v1), a2, (v2))
  242 #define KTR_POINT4(m, egroup, ident, point, a0, v0, a1, v1, a2, v2, a3, v3)\
  243         KTR_EVENT4(m, egroup, ident, "point:\"%s\"",                    \
  244             point, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  245 
  246 /*
  247  * Trace initialization events, similar to CTR with KTR_INIT, but
  248  * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to
  249  * save string space, the compiler doesn't optimize out strings
  250  * for the conditional ones above).
  251  */
  252 #if (KTR_COMPILE & KTR_INIT) != 0
  253 #define ITR0(d)                         CTR0(KTR_INIT, d)
  254 #define ITR1(d, p1)                     CTR1(KTR_INIT, d, p1)
  255 #define ITR2(d, p1, p2)                 CTR2(KTR_INIT, d, p1, p2)
  256 #define ITR3(d, p1, p2, p3)             CTR3(KTR_INIT, d, p1, p2, p3)
  257 #define ITR4(d, p1, p2, p3, p4)         CTR4(KTR_INIT, d, p1, p2, p3, p4)
  258 #define ITR5(d, p1, p2, p3, p4, p5)     CTR5(KTR_INIT, d, p1, p2, p3, p4, p5)
  259 #define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6)
  260 #else
  261 #define ITR0(d)
  262 #define ITR1(d, p1)
  263 #define ITR2(d, p1, p2)
  264 #define ITR3(d, p1, p2, p3)
  265 #define ITR4(d, p1, p2, p3, p4)
  266 #define ITR5(d, p1, p2, p3, p4, p5)
  267 #define ITR6(d, p1, p2, p3, p4, p5, p6)
  268 #endif
  269 
  270 #endif /* !LOCORE */
  271 
  272 #endif /* !_SYS_KTR_H_ */

Cache object: 79342b782d3690a72f47eed4f011c942


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