53 */
54 typedef struct rrwlock {
55 kmutex_t rr_lock;
56 kcondvar_t rr_cv;
57 kthread_t *rr_writer;
58 refcount_t rr_anon_rcount;
59 refcount_t rr_linked_rcount;
60 boolean_t rr_writer_wanted;
61 boolean_t rr_track_all;
62 } rrwlock_t;
63
64 /*
65 * 'tag' is used in reference counting tracking. The
66 * 'tag' must be the same in a rrw_enter() as in its
67 * corresponding rrw_exit().
68 */
69 void rrw_init(rrwlock_t *rrl, boolean_t track_all);
70 void rrw_destroy(rrwlock_t *rrl);
71 void rrw_enter(rrwlock_t *rrl, krw_t rw, void *tag);
72 void rrw_enter_read(rrwlock_t *rrl, void *tag);
73 void rrw_enter_write(rrwlock_t *rrl);
74 void rrw_exit(rrwlock_t *rrl, void *tag);
75 boolean_t rrw_held(rrwlock_t *rrl, krw_t rw);
76 void rrw_tsd_destroy(void *arg);
77
78 #define RRW_READ_HELD(x) rrw_held(x, RW_READER)
79 #define RRW_WRITE_HELD(x) rrw_held(x, RW_WRITER)
80 #define RRW_LOCK_HELD(x) \
81 (rrw_held(x, RW_WRITER) || rrw_held(x, RW_READER))
82
83 /*
84 * A reader-mostly lock implementation, tuning above reader-writer locks
85 * for hightly parallel read acquisitions, pessimizing write acquisitions.
86 *
87 * This should be a prime number. See comment in rrwlock.c near
88 * RRM_TD_LOCK() for details.
89 */
90 #define RRM_NUM_LOCKS 17
91 typedef struct rrmlock {
92 rrwlock_t locks[RRM_NUM_LOCKS];
|
53 */
54 typedef struct rrwlock {
55 kmutex_t rr_lock;
56 kcondvar_t rr_cv;
57 kthread_t *rr_writer;
58 refcount_t rr_anon_rcount;
59 refcount_t rr_linked_rcount;
60 boolean_t rr_writer_wanted;
61 boolean_t rr_track_all;
62 } rrwlock_t;
63
64 /*
65 * 'tag' is used in reference counting tracking. The
66 * 'tag' must be the same in a rrw_enter() as in its
67 * corresponding rrw_exit().
68 */
69 void rrw_init(rrwlock_t *rrl, boolean_t track_all);
70 void rrw_destroy(rrwlock_t *rrl);
71 void rrw_enter(rrwlock_t *rrl, krw_t rw, void *tag);
72 void rrw_enter_read(rrwlock_t *rrl, void *tag);
73 void rrw_enter_read_prio(rrwlock_t *rrl, void *tag);
74 void rrw_enter_write(rrwlock_t *rrl);
75 void rrw_exit(rrwlock_t *rrl, void *tag);
76 boolean_t rrw_held(rrwlock_t *rrl, krw_t rw);
77 void rrw_tsd_destroy(void *arg);
78
79 #define RRW_READ_HELD(x) rrw_held(x, RW_READER)
80 #define RRW_WRITE_HELD(x) rrw_held(x, RW_WRITER)
81 #define RRW_LOCK_HELD(x) \
82 (rrw_held(x, RW_WRITER) || rrw_held(x, RW_READER))
83
84 /*
85 * A reader-mostly lock implementation, tuning above reader-writer locks
86 * for hightly parallel read acquisitions, pessimizing write acquisitions.
87 *
88 * This should be a prime number. See comment in rrwlock.c near
89 * RRM_TD_LOCK() for details.
90 */
91 #define RRM_NUM_LOCKS 17
92 typedef struct rrmlock {
93 rrwlock_t locks[RRM_NUM_LOCKS];
|