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/lockstat.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) 2008-2009 Stacey Son <sson@FreeBSD.org> 
    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  *
   13  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   16  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
   17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   23  * SUCH DAMAGE.
   24  *
   25  * $FreeBSD$
   26  */
   27  
   28 /*
   29  * DTrace lockstat provider definitions
   30  *
   31  */
   32 
   33 #ifndef _SYS_LOCKSTAT_H
   34 #define _SYS_LOCKSTAT_H
   35 
   36 #ifdef  _KERNEL
   37 
   38 /*
   39  * Spin Locks
   40  */
   41 #define LS_MTX_SPIN_LOCK_ACQUIRE        0
   42 #define LS_MTX_SPIN_UNLOCK_RELEASE      1
   43 #define LS_MTX_SPIN_LOCK_SPIN           2
   44 
   45 /*
   46  * Adaptive Locks
   47  */
   48 #define LS_MTX_LOCK_ACQUIRE             3
   49 #define LS_MTX_UNLOCK_RELEASE           4
   50 #define LS_MTX_LOCK_SPIN                5
   51 #define LS_MTX_LOCK_BLOCK               6
   52 #define LS_MTX_TRYLOCK_ACQUIRE          7
   53 
   54 /*
   55  * Reader/Writer Locks
   56  */
   57 #define LS_RW_RLOCK_ACQUIRE             8
   58 #define LS_RW_RUNLOCK_RELEASE           9       
   59 #define LS_RW_WLOCK_ACQUIRE             10
   60 #define LS_RW_WUNLOCK_RELEASE           11
   61 #define LS_RW_RLOCK_SPIN                12
   62 #define LS_RW_RLOCK_BLOCK               13
   63 #define LS_RW_WLOCK_SPIN                14
   64 #define LS_RW_WLOCK_BLOCK               15
   65 #define LS_RW_TRYUPGRADE_UPGRADE        16
   66 #define LS_RW_DOWNGRADE_DOWNGRADE       17
   67 
   68 /*
   69  * Shared/Exclusive Locks
   70  */
   71 #define LS_SX_SLOCK_ACQUIRE             18
   72 #define LS_SX_SUNLOCK_RELEASE           19
   73 #define LS_SX_XLOCK_ACQUIRE             20
   74 #define LS_SX_XUNLOCK_RELEASE           21
   75 #define LS_SX_SLOCK_SPIN                22
   76 #define LS_SX_SLOCK_BLOCK               23
   77 #define LS_SX_XLOCK_SPIN                24
   78 #define LS_SX_XLOCK_BLOCK               25
   79 #define LS_SX_TRYUPGRADE_UPGRADE        26
   80 #define LS_SX_DOWNGRADE_DOWNGRADE       27
   81 
   82 /* 
   83  * Thread Locks
   84  */
   85 #define LS_THREAD_LOCK_SPIN             28
   86 
   87 /*
   88  * Lockmanager Locks 
   89  *  According to locking(9) Lockmgr locks are "Largely deprecated"
   90  *  so no support for these have been added in the lockstat provider.
   91  */
   92 
   93 #define LS_NPROBES                      29
   94 
   95 #define LS_MTX_LOCK                     "mtx_lock"
   96 #define LS_MTX_UNLOCK                   "mtx_unlock"
   97 #define LS_MTX_SPIN_LOCK                "mtx_lock_spin"
   98 #define LS_MTX_SPIN_UNLOCK              "mtx_unlock_spin"
   99 #define LS_MTX_TRYLOCK                  "mtx_trylock"
  100 #define LS_RW_RLOCK                     "rw_rlock"
  101 #define LS_RW_WLOCK                     "rw_wlock"
  102 #define LS_RW_RUNLOCK                   "rw_runlock"
  103 #define LS_RW_WUNLOCK                   "rw_wunlock"
  104 #define LS_RW_TRYUPGRADE                "rw_try_upgrade"
  105 #define LS_RW_DOWNGRADE                 "rw_downgrade"
  106 #define LS_SX_SLOCK                     "sx_slock"
  107 #define LS_SX_XLOCK                     "sx_xlock"
  108 #define LS_SX_SUNLOCK                   "sx_sunlock"
  109 #define LS_SX_XUNLOCK                   "sx_xunlock"
  110 #define LS_SX_TRYUPGRADE                "sx_try_upgrade"
  111 #define LS_SX_DOWNGRADE                 "sx_downgrade"
  112 #define LS_THREAD_LOCK                  "thread_lock"
  113 
  114 #define LS_ACQUIRE                      "acquire"
  115 #define LS_RELEASE                      "release"
  116 #define LS_SPIN                         "spin"
  117 #define LS_BLOCK                        "block"
  118 #define LS_UPGRADE                      "upgrade"
  119 #define LS_DOWNGRADE                    "downgrade"
  120 
  121 #define LS_TYPE_ADAPTIVE                "adaptive"
  122 #define LS_TYPE_SPIN                    "spin"
  123 #define LS_TYPE_THREAD                  "thread"
  124 #define LS_TYPE_RW                      "rw"
  125 #define LS_TYPE_SX                      "sx"
  126 
  127 #define LSA_ACQUIRE                     (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE)
  128 #define LSA_RELEASE                     (LS_TYPE_ADAPTIVE "-" LS_RELEASE)
  129 #define LSA_SPIN                        (LS_TYPE_ADAPTIVE "-" LS_SPIN)
  130 #define LSA_BLOCK                       (LS_TYPE_ADAPTIVE "-" LS_BLOCK)
  131 #define LSS_ACQUIRE                     (LS_TYPE_SPIN "-" LS_ACQUIRE)
  132 #define LSS_RELEASE                     (LS_TYPE_SPIN "-" LS_RELEASE)
  133 #define LSS_SPIN                        (LS_TYPE_SPIN "-" LS_SPIN)
  134 #define LSR_ACQUIRE                     (LS_TYPE_RW "-" LS_ACQUIRE)
  135 #define LSR_RELEASE                     (LS_TYPE_RW "-" LS_RELEASE)
  136 #define LSR_BLOCK                       (LS_TYPE_RW "-" LS_BLOCK)
  137 #define LSR_SPIN                        (LS_TYPE_RW "-" LS_SPIN)
  138 #define LSR_UPGRADE                     (LS_TYPE_RW "-" LS_UPGRADE)
  139 #define LSR_DOWNGRADE                   (LS_TYPE_RW "-" LS_DOWNGRADE)
  140 #define LSX_ACQUIRE                     (LS_TYPE_SX "-" LS_ACQUIRE)
  141 #define LSX_RELEASE                     (LS_TYPE_SX "-" LS_RELEASE)
  142 #define LSX_BLOCK                       (LS_TYPE_SX "-" LS_BLOCK)
  143 #define LSX_SPIN                        (LS_TYPE_SX "-" LS_SPIN)
  144 #define LSX_UPGRADE                     (LS_TYPE_SX "-" LS_UPGRADE)
  145 #define LSX_DOWNGRADE                   (LS_TYPE_SX "-" LS_DOWNGRADE)
  146 #define LST_SPIN                        (LS_TYPE_THREAD "-" LS_SPIN)
  147 
  148 /*
  149  * The following must match the type definition of dtrace_probe.  It is
  150  * defined this way to avoid having to rely on CDDL code.
  151  */
  152 struct lock_object;
  153 extern uint32_t lockstat_probemap[LS_NPROBES];
  154 typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1,
  155     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
  156 extern lockstat_probe_func_t lockstat_probe_func;
  157 extern uint64_t lockstat_nsecs(struct lock_object *);
  158 extern int lockstat_enabled;
  159 
  160 #ifdef  KDTRACE_HOOKS
  161 /*
  162  * Macros to record lockstat probes.
  163  */
  164 #define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4)  do {       \
  165         uint32_t id;                                                    \
  166                                                                         \
  167         if ((id = lockstat_probemap[(probe)]))                          \
  168             (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \
  169                 (arg3), (arg4));                                        \
  170 } while (0)
  171 
  172 #define LOCKSTAT_RECORD(probe, lp, arg1) \
  173         LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
  174 
  175 #define LOCKSTAT_RECORD0(probe, lp)     \
  176         LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0)
  177 
  178 #define LOCKSTAT_RECORD1(probe, lp, arg1) \
  179         LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
  180 
  181 #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \
  182         LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0)
  183 
  184 #define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \
  185         LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0)
  186 
  187 #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l)  do {   \
  188         uint32_t id;                                                         \
  189                                                                              \
  190         lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l);   \
  191         if ((id = lockstat_probemap[(probe)]))                               \
  192                 (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0);     \
  193 } while (0)
  194 
  195 #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)  do {                       \
  196         uint32_t id;                                                         \
  197                                                                              \
  198         lock_profile_release_lock(&(lp)->lock_object);                       \
  199         if ((id = lockstat_probemap[(probe)]))                               \
  200                 (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0);     \
  201 } while (0)
  202 
  203 #define LOCKSTAT_WRITER         0
  204 #define LOCKSTAT_READER         1
  205 
  206 #else   /* !KDTRACE_HOOKS */
  207 
  208 #define LOCKSTAT_RECORD(probe, lp, arg1)
  209 #define LOCKSTAT_RECORD0(probe, lp)
  210 #define LOCKSTAT_RECORD1(probe, lp, arg1)
  211 #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2)
  212 #define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3)
  213 #define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4)
  214 
  215 #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l)    \
  216         lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l)
  217 
  218 #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)                        \
  219         lock_profile_release_lock(&(lp)->lock_object)
  220 
  221 #endif  /* !KDTRACE_HOOKS */
  222 
  223 #endif  /* _KERNEL */
  224 
  225 #endif  /* _SYS_LOCKSTAT_H */

Cache object: 6e83ec4b0c841da17015445f47b4d849


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