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/11.1/sys/sys/ktr.h 283283 2015-05-22 11:09:41Z jhb $
   30  */
   31 
   32 /*
   33  *      Wraparound kernel trace buffer support.
   34  */
   35 
   36 #ifndef _SYS_KTR_H_
   37 #define _SYS_KTR_H_
   38 
   39 #include <sys/ktr_class.h>
   40 
   41 /*
   42  * Version number for ktr_entry struct.  Increment this when you break binary
   43  * compatibility.
   44  */
   45 #define KTR_VERSION     2
   46 
   47 #define KTR_PARMS       6
   48 
   49 #ifndef LOCORE
   50 
   51 #include <sys/param.h>
   52 #include <sys/_cpuset.h>
   53 
   54 struct ktr_entry {
   55         u_int64_t ktr_timestamp;
   56         int     ktr_cpu;
   57         int     ktr_line;
   58         const   char *ktr_file;
   59         const   char *ktr_desc;
   60         struct  thread *ktr_thread;
   61         u_long  ktr_parms[KTR_PARMS];
   62 };
   63 
   64 extern cpuset_t ktr_cpumask;
   65 extern uint64_t ktr_mask;
   66 extern int ktr_entries;
   67 extern int ktr_verbose;
   68 
   69 extern volatile int ktr_idx;
   70 extern struct ktr_entry *ktr_buf;
   71 
   72 #ifdef KTR
   73 
   74 void    ktr_tracepoint(uint64_t mask, const char *file, int line,
   75             const char *format, u_long arg1, u_long arg2, u_long arg3,
   76             u_long arg4, u_long arg5, u_long arg6);
   77 
   78 #define CTR6(m, format, p1, p2, p3, p4, p5, p6) do {                    \
   79         if (KTR_COMPILE & (m))                                          \
   80                 ktr_tracepoint((m), __FILE__, __LINE__, format,         \
   81                     (u_long)(p1), (u_long)(p2), (u_long)(p3),           \
   82                     (u_long)(p4), (u_long)(p5), (u_long)(p6));          \
   83         } while(0)
   84 #define CTR0(m, format)                 CTR6(m, format, 0, 0, 0, 0, 0, 0)
   85 #define CTR1(m, format, p1)             CTR6(m, format, p1, 0, 0, 0, 0, 0)
   86 #define CTR2(m, format, p1, p2)         CTR6(m, format, p1, p2, 0, 0, 0, 0)
   87 #define CTR3(m, format, p1, p2, p3)     CTR6(m, format, p1, p2, p3, 0, 0, 0)
   88 #define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0)
   89 #define CTR5(m, format, p1, p2, p3, p4, p5)     CTR6(m, format, p1, p2, p3, p4, p5, 0)
   90 #else   /* KTR */
   91 #define CTR0(m, d)                      (void)0
   92 #define CTR1(m, d, p1)                  (void)0
   93 #define CTR2(m, d, p1, p2)              (void)0
   94 #define CTR3(m, d, p1, p2, p3)          (void)0
   95 #define CTR4(m, d, p1, p2, p3, p4)      (void)0
   96 #define CTR5(m, d, p1, p2, p3, p4, p5)  (void)0
   97 #define CTR6(m, d, p1, p2, p3, p4, p5, p6)      (void)0
   98 #endif  /* KTR */
   99 
  100 #define TR0(d)                          CTR0(KTR_GEN, d)
  101 #define TR1(d, p1)                      CTR1(KTR_GEN, d, p1)
  102 #define TR2(d, p1, p2)                  CTR2(KTR_GEN, d, p1, p2)
  103 #define TR3(d, p1, p2, p3)              CTR3(KTR_GEN, d, p1, p2, p3)
  104 #define TR4(d, p1, p2, p3, p4)          CTR4(KTR_GEN, d, p1, p2, p3, p4)
  105 #define TR5(d, p1, p2, p3, p4, p5)      CTR5(KTR_GEN, d, p1, p2, p3, p4, p5)
  106 #define TR6(d, p1, p2, p3, p4, p5, p6)  CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6)
  107 
  108 /*
  109  * The event macros implement KTR graphic plotting facilities provided
  110  * by src/tools/sched/schedgraph.py.  Three generic types of events are
  111  * supported: states, counters, and points.
  112  *
  113  * m is the ktr class for ktr_mask.
  114  * ident is the string identifier that owns the event (ie: "thread 10001")
  115  * etype is the type of event to plot (state, counter, point)
  116  * edat is the event specific data (state name, counter value, point name)
  117  * up to four attributes may be supplied as a name, value pair of arguments.
  118  *
  119  * etype and attribute names must be string constants.  This minimizes the
  120  * number of ktr slots required by construction the final format strings
  121  * at compile time.  Both must also include a colon and format specifier
  122  * (ie. "prio:%d", prio).  It is recommended that string arguments be
  123  * contained within escaped quotes if they may contain ',' or ':' characters.
  124  *
  125  * The special attribute (KTR_ATTR_LINKED, ident) creates a reference to another
  126  * id on the graph for easy traversal of related graph elements.
  127  */
  128 
  129 #define KTR_ATTR_LINKED "linkedto:\"%s\""
  130 #define KTR_EFMT(egroup, ident, etype)                                  \
  131             "KTRGRAPH group:\"" egroup "\", id:\"%s\", " etype ", attributes: "
  132 
  133 #define KTR_EVENT0(m, egroup, ident, etype, edat)                       \
  134         CTR2(m, KTR_EFMT(egroup, ident, etype) "none", ident, edat)
  135 #define KTR_EVENT1(m, egroup, ident, etype, edat, a0, v0)               \
  136         CTR3(m, KTR_EFMT(egroup, ident, etype) a0, ident, edat, (v0))
  137 #define KTR_EVENT2(m, egroup, ident, etype, edat, a0, v0, a1, v1)       \
  138         CTR4(m, KTR_EFMT(egroup, ident, etype) a0 ", " a1,              \
  139             ident, edat, (v0), (v1))
  140 #define KTR_EVENT3(m, egroup, ident, etype, edat, a0, v0, a1, v1, a2, v2)\
  141         CTR5(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2,       \
  142             ident, edat, (v0), (v1), (v2))
  143 #define KTR_EVENT4(m, egroup, ident, etype, edat,                       \
  144             a0, v0, a1, v1, a2, v2, a3, v3)                             \
  145         CTR6(m,KTR_EFMT(egroup, ident, etype) a0 ", " a1 ", " a2 ", " a3,\
  146              ident, edat, (v0), (v1), (v2), (v3))
  147 
  148 /*
  149  * State functions graph state changes on an ident.
  150  */
  151 #define KTR_STATE0(m, egroup, ident, state)                             \
  152         KTR_EVENT0(m, egroup, ident, "state:\"%s\"", state)
  153 #define KTR_STATE1(m, egroup, ident, state, a0, v0)                     \
  154         KTR_EVENT1(m, egroup, ident, "state:\"%s\"", state, a0, (v0))
  155 #define KTR_STATE2(m, egroup, ident, state, a0, v0, a1, v1)             \
  156         KTR_EVENT2(m, egroup, ident, "state:\"%s\"", state, a0, (v0), a1, (v1))
  157 #define KTR_STATE3(m, egroup, ident, state, a0, v0, a1, v1, a2, v2)     \
  158         KTR_EVENT3(m, egroup, ident, "state:\"%s\"",                    \
  159             state, a0, (v0), a1, (v1), a2, (v2))
  160 #define KTR_STATE4(m, egroup, ident, state, a0, v0, a1, v1, a2, v2, a3, v3)\
  161         KTR_EVENT4(m, egroup, ident, "state:\"%s\"",                    \
  162             state, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  163 
  164 /*
  165  * Counter functions graph counter values.  The counter id
  166  * must not be intermixed with a state id. 
  167  */
  168 #define KTR_COUNTER0(m, egroup, ident, counter)                         \
  169         KTR_EVENT0(m, egroup, ident, "counter:%d", counter)
  170 #define KTR_COUNTER1(m, egroup, ident, edat, a0, v0)                    \
  171         KTR_EVENT1(m, egroup, ident, "counter:%d", counter, a0, (v0))
  172 #define KTR_COUNTER2(m, egroup, ident, counter, a0, v0, a1, v1)         \
  173         KTR_EVENT2(m, egroup, ident, "counter:%d", counter, a0, (v0), a1, (v1))
  174 #define KTR_COUNTER3(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2) \
  175         KTR_EVENT3(m, egroup, ident, "counter:%d",                      \
  176             counter, a0, (v0), a1, (v1), a2, (v2))
  177 #define KTR_COUNTER4(m, egroup, ident, counter, a0, v0, a1, v1, a2, v2, a3, v3)\
  178         KTR_EVENT4(m, egroup, ident, "counter:%d",                      \
  179             counter, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  180 
  181 /*
  182  * Point functions plot points of interest on counter or state graphs.
  183  */
  184 #define KTR_POINT0(m, egroup, ident, point)                             \
  185         KTR_EVENT0(m, egroup, ident, "point:\"%s\"", point)
  186 #define KTR_POINT1(m, egroup, ident, point, a0, v0)                     \
  187         KTR_EVENT1(m, egroup, ident, "point:\"%s\"", point, a0, (v0))
  188 #define KTR_POINT2(m, egroup, ident, point, a0, v0, a1, v1)             \
  189         KTR_EVENT2(m, egroup, ident, "point:\"%s\"", point, a0, (v0), a1, (v1))
  190 #define KTR_POINT3(m, egroup, ident, point, a0, v0, a1, v1, a2, v2)     \
  191         KTR_EVENT3(m, egroup, ident, "point:\"%s\"", point,             \
  192             a0, (v0), a1, (v1), a2, (v2))
  193 #define KTR_POINT4(m, egroup, ident, point, a0, v0, a1, v1, a2, v2, a3, v3)\
  194         KTR_EVENT4(m, egroup, ident, "point:\"%s\"",                    \
  195             point, a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  196 
  197 /*
  198  * Start functions denote the start of a region of code or operation
  199  * and should be paired with stop functions for timing of nested
  200  * sequences.
  201  *
  202  * Specifying extra attributes with the name "key" will result in
  203  * multi-part keys.  For example a block device and offset pair
  204  * might be used to describe a buf undergoing I/O.
  205  */
  206 #define KTR_START0(m, egroup, ident, key)                               \
  207         KTR_EVENT0(m, egroup, ident, "start:0x%jX", (uintmax_t)key)
  208 #define KTR_START1(m, egroup, ident, key, a0, v0)                       \
  209         KTR_EVENT1(m, egroup, ident, "start:0x%jX", (uintmax_t)key, a0, (v0))
  210 #define KTR_START2(m, egroup, ident, key, a0, v0, a1, v1)               \
  211         KTR_EVENT2(m, egroup, ident, "start:0x%jX", (uintmax_t)key,     \
  212             a0, (v0), a1, (v1))
  213 #define KTR_START3(m, egroup, ident, key, a0, v0, a1, v1, a2, v2)\
  214         KTR_EVENT3(m, egroup, ident, "start:0x%jX", (uintmax_t)key,     \
  215             a0, (v0), a1, (v1), a2, (v2))
  216 #define KTR_START4(m, egroup, ident, key,                               \
  217             a0, v0, a1, v1, a2, v2, a3, v3)                             \
  218         KTR_EVENT4(m, egroup, ident, "start:0x%jX", (uintmax_t)key,     \
  219             a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  220 
  221 /*
  222  * Stop functions denote the end of a region of code or operation
  223  * and should be paired with start functions for timing of nested
  224  * sequences.
  225  */
  226 #define KTR_STOP0(m, egroup, ident, key)                                \
  227         KTR_EVENT0(m, egroup, ident, "stop:0x%jX", (uintmax_t)key)
  228 #define KTR_STOP1(m, egroup, ident, key, a0, v0)                        \
  229         KTR_EVENT1(m, egroup, ident, "stop:0x%jX", (uintmax_t)key, a0, (v0))
  230 #define KTR_STOP2(m, egroup, ident, key, a0, v0, a1, v1)                \
  231         KTR_EVENT2(m, egroup, ident, "stop:0x%jX", (uintmax_t)key,      \
  232             a0, (v0), a1, (v1))
  233 #define KTR_STOP3(m, egroup, ident, key, a0, v0, a1, v1, a2, v2)\
  234         KTR_EVENT3(m, egroup, ident, "stop:0x%jX", (uintmax_t)key,      \
  235             a0, (v0), a1, (v1), a2, (v2))
  236 #define KTR_STOP4(m, egroup, ident,                                     \
  237             key, a0, v0, a1, v1, a2, v2, a3, v3)                        \
  238         KTR_EVENT4(m, egroup, ident, "stop:0x%jX", (uintmax_t)key,      \
  239             a0, (v0), a1, (v1), a2, (v2), a3, (v3))
  240 
  241 /*
  242  * Trace initialization events, similar to CTR with KTR_INIT, but
  243  * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to
  244  * save string space, the compiler doesn't optimize out strings
  245  * for the conditional ones above).
  246  */
  247 #if (KTR_COMPILE & KTR_INIT) != 0
  248 #define ITR0(d)                         CTR0(KTR_INIT, d)
  249 #define ITR1(d, p1)                     CTR1(KTR_INIT, d, p1)
  250 #define ITR2(d, p1, p2)                 CTR2(KTR_INIT, d, p1, p2)
  251 #define ITR3(d, p1, p2, p3)             CTR3(KTR_INIT, d, p1, p2, p3)
  252 #define ITR4(d, p1, p2, p3, p4)         CTR4(KTR_INIT, d, p1, p2, p3, p4)
  253 #define ITR5(d, p1, p2, p3, p4, p5)     CTR5(KTR_INIT, d, p1, p2, p3, p4, p5)
  254 #define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6)
  255 #else
  256 #define ITR0(d)
  257 #define ITR1(d, p1)
  258 #define ITR2(d, p1, p2)
  259 #define ITR3(d, p1, p2, p3)
  260 #define ITR4(d, p1, p2, p3, p4)
  261 #define ITR5(d, p1, p2, p3, p4, p5)
  262 #define ITR6(d, p1, p2, p3, p4, p5, p6)
  263 #endif
  264 
  265 #endif /* !LOCORE */
  266 
  267 #endif /* !_SYS_KTR_H_ */

Cache object: 9d0407c7c01a454975fadf052e89d941


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