Changeset 9c1490a in rtems-libbsd


Ignore:
Timestamp:
Nov 14, 2017, 12:06:39 PM (19 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
eeb3fd5d9b07ac9a2e280cff60a1b762bd273a8d, 1e989998de954bef51e6c19cc3d64d39f32100aa
Children:
3f23fcd
Parents:
b03a1c0
git-author:
Sebastian Huber <sebastian.huber@…> (11/14/17 12:06:39)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/16/17 07:11:42)
Message:

LOCKING(9): Update to current FreeBSD version

Location:
rtemsbsd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/include/machine/_kernel_lock.h

    rb03a1c0 r9c1490a  
    2626 * SUCH DAMAGE.
    2727 *
    28  *      from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $
     28 *      from BSDI Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp
    2929 * $FreeBSD$
    3030 */
     
    3535#include <sys/queue.h>
    3636#include <sys/_lock.h>
     37#include <sys/ktr_class.h>
    3738
    3839struct lock_list_entry;
     
    5758
    5859struct lock_class {
    59         const   char *lc_name;
    60         unsigned int lc_flags;
    61         void    (*lc_assert)(struct lock_object *lock, int what);
    62         void    (*lc_ddb_show)(struct lock_object *lock);
    63         void    (*lc_lock)(struct lock_object *lock, int how);
    64         int     (*lc_owner)(struct lock_object *lock, struct thread **owner);
    65         int     (*lc_unlock)(struct lock_object *lock);
     60        const           char *lc_name;
     61        unsigned int    lc_flags;
     62        void            (*lc_assert)(const struct lock_object *lock, int what);
     63        void            (*lc_ddb_show)(const struct lock_object *lock);
     64        void            (*lc_lock)(struct lock_object *lock, __uintptr_t how);
     65        int             (*lc_owner)(const struct lock_object *lock,
     66                            struct thread **owner);
     67        __uintptr_t     (*lc_unlock)(struct lock_object *lock);
    6668};
    6769
     
    8082#define LO_UPGRADABLE   0x00200000      /* Lock may be upgraded/downgraded. */
    8183#define LO_DUPOK        0x00400000      /* Don't check for duplicate acquires */
     84#define LO_IS_VNODE     0x00800000      /* Tell WITNESS about a VNODE lock */
    8285#define LO_CLASSMASK    0x0f000000      /* Class index bitmask. */
    8386#define LO_NOPROFILE    0x10000000      /* Don't profile this lock */
     87#define LO_NEW          0x20000000      /* Don't check for double-init */
    8488
    8589/*
     
    122126 * work with both debug and non-debug kernels.
    123127 */
    124 #if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || defined(INVARIANT_SUPPORT) || defined(KTR) || defined(LOCK_PROFILING)
     128#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || \
     129    defined(LOCK_PROFILING) || defined(KTR)
    125130#define LOCK_DEBUG      1
    126131#else
     
    151156 * line    - line number
    152157 */
     158#if LOCK_DEBUG > 0
    153159#define LOCK_LOG_TEST(lo, flags)                                        \
    154160        (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0)
     161#else
     162#define LOCK_LOG_TEST(lo, flags)        0
     163#endif
     164
    155165
    156166#define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do {      \
     
    158168                CTR6(KTR_LOCK, opname " (%s) %s %p r = %d at %s:%d",    \
    159169                    LOCK_CLASS(lo)->lc_name, (lo)->lo_name,             \
    160                     (lo), (u_int)(recurse), (file), (line));            \
     170                    (lo), (unsigned int)(recurse), (file), (line));     \
    161171} while (0)
    162172
     
    165175                CTR6(KTR_LOCK, "TRY_" opname " (%s) %s %p result=%d at %s:%d",\
    166176                    LOCK_CLASS(lo)->lc_name, (lo)->lo_name,             \
    167                     (lo), (u_int)(result), (file), (line));             \
     177                    (lo), (unsigned int)(result), (file), (line));      \
    168178} while (0)
    169179
     
    193203extern struct lock_class lock_class_rw;
    194204extern struct lock_class lock_class_rm;
     205extern struct lock_class lock_class_rm_sleepable;
    195206extern struct lock_class lock_class_lockmgr;
    196207
    197208extern struct lock_class *lock_classes[];
     209
     210struct lock_delay_config {
     211        unsigned int base;
     212        unsigned int max;
     213};
     214
     215struct lock_delay_arg {
     216        struct lock_delay_config *config;
     217        unsigned int delay;
     218        unsigned int spin_cnt;
     219};
     220
     221static inline void
     222lock_delay_arg_init(struct lock_delay_arg *la, struct lock_delay_config *lc)
     223{
     224        la->config = lc;
     225        la->delay = lc->base;
     226        la->spin_cnt = 0;
     227}
     228
     229#define LOCK_DELAY_SYSINIT(func) \
     230        SYSINIT(func##_ld, SI_SUB_LOCK, SI_ORDER_ANY, func, NULL)
     231
     232#define LOCK_DELAY_SYSINIT_DEFAULT(lc) \
     233        SYSINIT(lock_delay_##lc##_ld, SI_SUB_LOCK, SI_ORDER_ANY, \
     234            lock_delay_default_init, &lc)
    198235
    199236void    lock_init(struct lock_object *, struct lock_class *,
    200237            const char *, const char *, int);
    201238void    lock_destroy(struct lock_object *);
     239void    lock_delay(struct lock_delay_arg *);
     240void    lock_delay_default_init(struct lock_delay_config *);
    202241void    spinlock_enter(void);
    203242void    spinlock_exit(void);
     
    216255            int (*)(const char *, ...));
    217256int     witness_warn(int, struct lock_object *, const char *, ...);
    218 void    witness_assert(struct lock_object *, int, const char *, int);
     257void    witness_assert(const struct lock_object *, int, const char *, int);
    219258void    witness_display_spinlock(struct lock_object *, struct thread *,
    220259            int (*)(const char *, ...));
     
    305344#endif  /* WITNESS */
    306345
    307 /*
    308  * Helper macros to allow developers to add explicit lock order checks
    309  * wherever they please without having to actually grab a lock to do so.
    310  */
    311 #define witness_check(l)                                                \
    312         WITNESS_CHECKORDER(&(l)->lock_object, LOP_EXCLUSIVE, LOCK_FILE, \
    313             LOCK_LINE, NULL)
    314 
    315 #define witness_check_shared(l)                                         \
    316         WITNESS_CHECKORDER(&(l)->lock_object, 0, LOCK_FILE, LOCK_LINE, NULL)
    317 
    318346#endif  /* _KERNEL */
    319347#endif  /* _MACHINE__KERNEL_LOCK_H_ */
  • rtemsbsd/rtems/rtems-kernel-mutex.c

    rb03a1c0 r9c1490a  
    4949#include <sys/conf.h>
    5050
    51 static void assert_mtx(struct lock_object *lock, int what);
    52 static void lock_mtx(struct lock_object *lock, int how);
    53 #ifdef KDTRACE_HOOKS
    54 static int  owner_mtx(struct lock_object *lock, struct thread **owner);
    55 #endif
    56 static int  unlock_mtx(struct lock_object *lock);
     51static void     assert_mtx(const struct lock_object *lock, int what);
     52static void     lock_mtx(struct lock_object *lock, uintptr_t how);
     53#ifdef KDTRACE_HOOKS
     54static int      owner_mtx(const struct lock_object *lock,
     55                    struct thread **owner);
     56#endif
     57static uintptr_t unlock_mtx(struct lock_object *lock);
    5758
    5859/*
     
    6061 */
    6162struct lock_class lock_class_mtx_sleep = {
    62   .lc_name = "sleep mutex",
    63   .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
    64   .lc_assert = assert_mtx,
     63        .lc_name = "sleep mutex",
     64        .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
     65        .lc_assert = assert_mtx,
    6566#ifdef DDB
    66   .lc_ddb_show = db_show_mtx,
    67 #endif
    68   .lc_lock = lock_mtx,
    69   .lc_unlock = unlock_mtx,
    70 #ifdef KDTRACE_HOOKS
    71   .lc_owner = owner_mtx,
     67        .lc_ddb_show = db_show_mtx,
     68#endif
     69        .lc_lock = lock_mtx,
     70        .lc_unlock = unlock_mtx,
     71#ifdef KDTRACE_HOOKS
     72        .lc_owner = owner_mtx,
    7273#endif
    7374};
    7475
    7576struct lock_class lock_class_mtx_spin = {
    76   .lc_name = "spin mutex",
    77   .lc_flags = LC_SPINLOCK | LC_RECURSABLE,
    78   .lc_assert = assert_mtx,
     77        .lc_name = "spin mutex",
     78        .lc_flags = LC_SPINLOCK | LC_RECURSABLE,
     79        .lc_assert = assert_mtx,
    7980#ifdef DDB
    80   .lc_ddb_show = db_show_mtx,
    81 #endif
    82   .lc_lock = lock_mtx,
    83   .lc_unlock = unlock_mtx,
    84 #ifdef KDTRACE_HOOKS
    85   .lc_owner = owner_mtx,
     81        .lc_ddb_show = db_show_mtx,
     82#endif
     83        .lc_lock = lock_mtx,
     84        .lc_unlock = unlock_mtx,
     85#ifdef KDTRACE_HOOKS
     86        .lc_owner = owner_mtx,
    8687#endif
    8788};
     
    9091
    9192void
    92 assert_mtx(struct lock_object *lock, int what)
    93 {
    94   mtx_assert((struct mtx *)lock, what);
    95 }
    96 
    97 void
    98 lock_mtx(struct lock_object *lock, int how)
    99 {
     93assert_mtx(const struct lock_object *lock, int what)
     94{
     95
     96        mtx_assert((const struct mtx *)lock, what);
     97}
     98
     99void
     100lock_mtx(struct lock_object *lock, uintptr_t how)
     101{
     102
    100103        mtx_lock((struct mtx *)lock);
    101104}
    102105
    103 int
     106uintptr_t
    104107unlock_mtx(struct lock_object *lock)
    105108{
     109
    106110        mtx_unlock((struct mtx *)lock);
    107 
    108111        return (0);
    109112}
    110 
    111113
    112114#ifdef KDTRACE_HOOKS
  • rtemsbsd/rtems/rtems-kernel-rwlock.c

    rb03a1c0 r9c1490a  
    5959#endif
    6060
    61 static void assert_rw(struct lock_object *lock, int what);
    62 static void lock_rw(struct lock_object *lock, int how);
     61static void     assert_rw(const struct lock_object *lock, int what);
     62static void     lock_rw(struct lock_object *lock, uintptr_t how);
    6363#ifdef KDTRACE_HOOKS
    64 static int  owner_rw(struct lock_object *lock, struct thread **owner);
    65 #endif
    66 static int unlock_rw(struct lock_object *lock);
     64static int      owner_rw(const struct lock_object *lock, struct thread **owner);
     65#endif
     66static uintptr_t unlock_rw(struct lock_object *lock);
    6767
    6868struct lock_class lock_class_rw = {
    69   .lc_name = "rw",
    70   .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE,
    71   .lc_assert = assert_rw,
     69        .lc_name = "rw",
     70        .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE,
     71        .lc_assert = assert_rw,
    7272#ifdef DDB
    73   .lc_ddb_show = db_show_rwlock,
    74 #endif
    75   .lc_lock = lock_rw,
    76   .lc_unlock = unlock_rw,
     73        .lc_ddb_show = db_show_rwlock,
     74#endif
     75        .lc_lock = lock_rw,
     76        .lc_unlock = unlock_rw,
    7777#ifdef KDTRACE_HOOKS
    78   .lc_owner = owner_rw,
     78        .lc_owner = owner_rw,
    7979#endif
    8080};
     
    8585
    8686void
    87 assert_rw(struct lock_object *lock, int what)
    88 {
    89   rw_assert((struct rwlock *)lock, what);
    90 }
    91 
    92 void
    93 lock_rw(struct lock_object *lock, int how)
    94 {
    95   rw_wlock((struct rwlock *)lock);
    96 }
    97 
    98 int
     87assert_rw(const struct lock_object *lock, int what)
     88{
     89
     90        rw_assert((const struct rwlock *)lock, what);
     91}
     92
     93void
     94lock_rw(struct lock_object *lock, uintptr_t how)
     95{
     96
     97        rw_wlock((struct rwlock *)lock);
     98}
     99
     100uintptr_t
    99101unlock_rw(struct lock_object *lock)
    100102{
    101   rw_unlock((struct rwlock *)lock);
    102 
    103   return (0);
     103
     104        rw_unlock((struct rwlock *)lock);
     105        return (0);
    104106}
    105107
  • rtemsbsd/rtems/rtems-kernel-sx.c

    rb03a1c0 r9c1490a  
    4848#include <sys/sx.h>
    4949
    50 static void assert_sx(struct lock_object *lock, int what);
    51 static void lock_sx(struct lock_object *lock, int how);
     50static void     assert_sx(const struct lock_object *lock, int what);
     51static void     lock_sx(struct lock_object *lock, uintptr_t how);
    5252#ifdef KDTRACE_HOOKS
    53 static int  owner_sx(struct lock_object *lock, struct thread **owner);
    54 #endif
    55 static int unlock_sx(struct lock_object *lock);
     53static int      owner_sx(const struct lock_object *lock, struct thread **owner);
     54#endif
     55static uintptr_t unlock_sx(struct lock_object *lock);
    5656
    5757struct lock_class lock_class_sx = {
    58   .lc_name = "sx",
    59   .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
    60   .lc_assert = assert_sx,
     58        .lc_name = "sx",
     59        .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
     60        .lc_assert = assert_sx,
    6161#ifdef DDB
    62   .lc_ddb_show = db_show_sx,
    63 #endif
    64   .lc_lock = lock_sx,
    65   .lc_unlock = unlock_sx,
     62        .lc_ddb_show = db_show_sx,
     63#endif
     64        .lc_lock = lock_sx,
     65        .lc_unlock = unlock_sx,
    6666#ifdef KDTRACE_HOOKS
    67   .lc_owner = owner_sx,
     67        .lc_owner = owner_sx,
    6868#endif
    6969};
     
    7474
    7575void
    76 assert_sx(struct lock_object *lock, int what)
    77 {
    78   sx_assert((struct sx *)lock, what);
    79 }
    80 
    81 void
    82 lock_sx(struct lock_object *lock, int how)
    83 {
     76assert_sx(const struct lock_object *lock, int what)
     77{
     78
     79        sx_assert((const struct sx *)lock, what);
     80}
     81
     82void
     83lock_sx(struct lock_object *lock, uintptr_t how)
     84{
     85
    8486        sx_xlock((struct sx *)lock);
    8587}
    8688
    87 int
     89uintptr_t
    8890unlock_sx(struct lock_object *lock)
    8991{
     92
    9093        sx_xunlock((struct sx *)lock);
    91 
    9294        return (0);
    9395}
Note: See TracChangeset for help on using the changeset viewer.