dtrace bits from riastradh
This commit is contained in:
parent
dfddf4df80
commit
f341fbf934
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lockstat.c,v 1.19 2014/07/25 08:10:35 dholland Exp $ */
|
||||
/* $NetBSD: lockstat.c,v 1.20 2015/03/08 22:45:16 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.19 2014/07/25 08:10:35 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.20 2015/03/08 22:45:16 christos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -110,6 +110,20 @@ size_t lockstat_sizeb;
|
|||
int lockstat_busy;
|
||||
struct timespec lockstat_stime;
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
CTASSERT(LB_NEVENT <= 3);
|
||||
CTASSERT(LB_NLOCK <= (7 << LB_LOCK_SHIFT));
|
||||
void
|
||||
lockstat_probe_stub(uint32_t id, uintptr_t lock, uintptr_t callsite,
|
||||
uintptr_t flags, uintptr_t count, uintptr_t cycles)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t lockstat_probemap[LS_NPROBES];
|
||||
void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t,
|
||||
uintptr_t, uintptr_t, uintptr_t) = &lockstat_probe_stub;
|
||||
#endif
|
||||
|
||||
const struct cdevsw lockstat_cdevsw = {
|
||||
.d_open = lockstat_open,
|
||||
.d_close = lockstat_close,
|
||||
|
@ -344,6 +358,14 @@ lockstat_event(uintptr_t lock, uintptr_t callsite, u_int flags, u_int count,
|
|||
u_int event;
|
||||
int s;
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
uint32_t id;
|
||||
CTASSERT((LS_NPROBES & (LS_NPROBES - 1)) == 0);
|
||||
if ((id = lockstat_probemap[LS_COMPRESS(flags)]) != 0)
|
||||
(*lockstat_probe_func)(id, lock, callsite, flags, count,
|
||||
cycles);
|
||||
#endif
|
||||
|
||||
if ((flags & lockstat_enabled) != flags || count == 0)
|
||||
return;
|
||||
if (lock < lockstat_lockstart || lock > lockstat_lockend)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lockstat.h,v 1.10 2009/01/20 14:49:00 yamt Exp $ */
|
||||
/* $NetBSD: lockstat.h,v 1.11 2015/03/08 22:45:16 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -33,6 +33,7 @@
|
|||
#define _SYS_LOCKSTAT_H_
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_dtrace.h"
|
||||
#include <lockstat.h>
|
||||
#endif
|
||||
|
||||
|
@ -195,4 +196,17 @@ extern volatile u_int lockstat_enabled;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
#define LS_COMPRESS(f) \
|
||||
((((f) & 3) | (((f) & 7) >> 6)) & (LS_NPROBES - 1))
|
||||
#define LS_NPROBES 0x20 /* 5 bits */
|
||||
|
||||
extern uint32_t lockstat_probemap[];
|
||||
extern void (*lockstat_probe_func)(uint32_t, uintptr_t, uintptr_t,
|
||||
uintptr_t, uintptr_t, uintptr_t);
|
||||
|
||||
void lockstat_probe_stub(uint32_t, uintptr_t, uintptr_t,
|
||||
uintptr_t, uintptr_t, uintptr_t);
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_LOCKSTAT_H_ */
|
||||
|
|
Loading…
Reference in New Issue