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-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) 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: releng/10.0/sys/sys/lockstat.h 228448 2011-12-12 23:29:32Z attilio $
   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 extern uint32_t lockstat_probemap[LS_NPROBES];
  153 typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1,
  154     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
  155 extern lockstat_probe_func_t lockstat_probe_func;
  156 extern uint64_t lockstat_nsecs(void);
  157 
  158 #ifdef  KDTRACE_HOOKS
  159 /*
  160  * Macros to record lockstat probes.
  161  */
  162 #define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4)  do {       \
  163         uint32_t id;                                                    \
  164                                                                         \
  165         if ((id = lockstat_probemap[(probe)]))                          \
  166             (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \
  167                 (arg3), (arg4));                                        \
  168 } while (0)
  169 
  170 #define LOCKSTAT_RECORD(probe, lp, arg1) \
  171         LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
  172 
  173 #define LOCKSTAT_RECORD0(probe, lp)     \
  174         LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0)
  175 
  176 #define LOCKSTAT_RECORD1(probe, lp, arg1) \
  177         LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0)
  178 
  179 #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \
  180         LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0)
  181 
  182 #define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \
  183         LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0)
  184 
  185 #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l)  do {   \
  186         uint32_t id;                                                         \
  187                                                                              \
  188         lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l);   \
  189         if ((id = lockstat_probemap[(probe)]))                               \
  190                 (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0);     \
  191 } while (0)
  192 
  193 #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)  do {                       \
  194         uint32_t id;                                                         \
  195                                                                              \
  196         lock_profile_release_lock(&(lp)->lock_object);                       \
  197         if ((id = lockstat_probemap[(probe)]))                               \
  198                 (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0);     \
  199 } while (0)
  200 
  201 #else   /* !KDTRACE_HOOKS */
  202 
  203 #define LOCKSTAT_RECORD(probe, lp, arg1)
  204 #define LOCKSTAT_RECORD0(probe, lp)
  205 #define LOCKSTAT_RECORD1(probe, lp, arg1)
  206 #define LOCKSTAT_RECORD2(probe, lp, arg1, arg2)
  207 #define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3)
  208 #define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4)
  209 
  210 #define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l)    \
  211         lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l)
  212 
  213 #define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)                        \
  214         lock_profile_release_lock(&(lp)->lock_object)
  215 
  216 #endif  /* !KDTRACE_HOOKS */
  217 
  218 #endif  /* _KERNEL */
  219 
  220 #endif  /* _SYS_LOCKSTAT_H */

Cache object: d218377ae796ffce1f3d348d61036053


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