Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev dtrace bits from riastradh



details:   https://anonhg.NetBSD.org/src/rev/efcedcee3461
branches:  trunk
changeset: 336654:efcedcee3461
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 08 22:45:16 2015 +0000

description:
dtrace bits from riastradh

diffstat:

 sys/dev/lockstat.c |  26 ++++++++++++++++++++++++--
 sys/dev/lockstat.h |  16 +++++++++++++++-
 2 files changed, 39 insertions(+), 3 deletions(-)

diffs (89 lines):

diff -r e8e56f92a4b3 -r efcedcee3461 sys/dev/lockstat.c
--- a/sys/dev/lockstat.c        Sun Mar 08 20:32:21 2015 +0000
+++ b/sys/dev/lockstat.c        Sun Mar 08 22:45:16 2015 +0000
@@ -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 @@
 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 @@
        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)
diff -r e8e56f92a4b3 -r efcedcee3461 sys/dev/lockstat.h
--- a/sys/dev/lockstat.h        Sun Mar 08 20:32:21 2015 +0000
+++ b/sys/dev/lockstat.h        Sun Mar 08 22:45:16 2015 +0000
@@ -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 @@
 
 #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_ */



Home | Main Index | Thread Index | Old Index