aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/lockstat.h18
-rw-r--r--sys/sys/rwlock.h7
-rw-r--r--sys/sys/sx.h13
3 files changed, 28 insertions, 10 deletions
diff --git a/sys/sys/lockstat.h b/sys/sys/lockstat.h
index e53a7e4b88c8..1cb9a21198ce 100644
--- a/sys/sys/lockstat.h
+++ b/sys/sys/lockstat.h
@@ -90,15 +90,25 @@ SDT_PROBE_DECLARE(lockstat, , , thread__spin);
LOCKSTAT_RECORD0(probe, lp); \
} while (0)
+#define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) do { \
+ lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \
+ LOCKSTAT_RECORD1(probe, lp, a); \
+} while (0)
+
#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \
lock_profile_release_lock(&(lp)->lock_object); \
LOCKSTAT_RECORD0(probe, lp); \
} while (0)
+#define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) do { \
+ lock_profile_release_lock(&(lp)->lock_object); \
+ LOCKSTAT_RECORD1(probe, lp, a); \
+} while (0)
+
extern int lockstat_enabled;
struct lock_object;
-extern uint64_t lockstat_nsecs(struct lock_object *);
+uint64_t lockstat_nsecs(struct lock_object *);
#else /* !KDTRACE_HOOKS */
@@ -111,9 +121,15 @@ extern uint64_t lockstat_nsecs(struct lock_object *);
#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \
lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l)
+#define LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(probe, lp, c, wt, f, l, a) \
+ LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l)
+
#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \
lock_profile_release_lock(&(lp)->lock_object)
+#define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) \
+ LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)
+
#endif /* !KDTRACE_HOOKS */
#endif /* _KERNEL */
#endif /* _SYS_LOCKSTAT_H */
diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h
index 960d4af7e263..f8947c55617a 100644
--- a/sys/sys/rwlock.h
+++ b/sys/sys/rwlock.h
@@ -99,8 +99,8 @@
if (!_rw_write_lock((rw), _tid)) \
_rw_wlock_hard((rw), _tid, (file), (line)); \
else \
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(rw__acquire, rw, \
- 0, 0, file, line); \
+ LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(rw__acquire, rw, \
+ 0, 0, file, line, LOCKSTAT_WRITER); \
} while (0)
/* Release a write lock. */
@@ -110,7 +110,8 @@
if ((rw)->rw_recurse) \
(rw)->rw_recurse--; \
else { \
- LOCKSTAT_PROFILE_RELEASE_LOCK(rw__release, rw); \
+ LOCKSTAT_PROFILE_RELEASE_RWLOCK(rw__release, rw, \
+ LOCKSTAT_WRITER); \
if (!_rw_write_unlock((rw), _tid)) \
_rw_wunlock_hard((rw), _tid, (file), (line)); \
} \
diff --git a/sys/sys/sx.h b/sys/sys/sx.h
index c01735c75f51..96a664f35e52 100644
--- a/sys/sys/sx.h
+++ b/sys/sys/sx.h
@@ -153,8 +153,8 @@ __sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file,
if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid))
error = _sx_xlock_hard(sx, tid, opts, file, line);
else
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx,
- 0, 0, file, line);
+ LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(sx__acquire, sx,
+ 0, 0, file, line, LOCKSTAT_WRITER);
return (error);
}
@@ -166,7 +166,8 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line)
uintptr_t tid = (uintptr_t)td;
if (sx->sx_recurse == 0)
- LOCKSTAT_PROFILE_RELEASE_LOCK(sx__release, sx);
+ LOCKSTAT_PROFILE_RELEASE_RWLOCK(sx__release, sx,
+ LOCKSTAT_WRITER);
if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED))
_sx_xunlock_hard(sx, tid, file, line);
}
@@ -182,8 +183,8 @@ __sx_slock(struct sx *sx, int opts, const char *file, int line)
!atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER))
error = _sx_slock_hard(sx, opts, file, line);
else
- LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(sx__acquire, sx,
- 0, 0, file, line);
+ LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(sx__acquire, sx,
+ 0, 0, file, line, LOCKSTAT_READER);
return (error);
}
@@ -200,7 +201,7 @@ __sx_sunlock(struct sx *sx, const char *file, int line)
{
uintptr_t x = sx->sx_lock;
- LOCKSTAT_PROFILE_RELEASE_LOCK(sx__release, sx);
+ LOCKSTAT_PROFILE_RELEASE_RWLOCK(sx__release, sx, LOCKSTAT_READER);
if (x == (SX_SHARERS_LOCK(1) | SX_LOCK_EXCLUSIVE_WAITERS) ||
!atomic_cmpset_rel_ptr(&sx->sx_lock, x, x - SX_ONE_SHARER))
_sx_sunlock_hard(sx, file, line);