]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tracing: bootstrap lttng-ust with mutex events
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 30 May 2014 21:13:12 +0000 (14:13 -0700)
committerSage Weil <sage@redhat.com>
Thu, 21 Aug 2014 17:57:27 +0000 (10:57 -0700)
See src/tracing/README.md

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
configure.ac
src/Makefile-env.am
src/Makefile.am
src/common/Makefile.am
src/common/Mutex.cc
src/tracing/Makefile.am [new file with mode: 0644]
src/tracing/README.md [new file with mode: 0644]
src/tracing/mutex.tp [new file with mode: 0644]
src/tracing/mutex.tp.c [new file with mode: 0644]
src/tracing/mutex.tp.h [new file with mode: 0644]

index 38c6deaba9e9f5b8a61cf2e4c6d5002fdd80fac3..40fa0ef78664035e40bd19852481bedc7470f275 100644 (file)
@@ -858,6 +858,7 @@ AC_CONFIG_FILES([Makefile
        src/ocf/ceph
        src/ocf/rbd
        src/java/Makefile
+       src/tracing/Makefile
        man/Makefile
        ceph.spec])
 AC_OUTPUT
index 57fa8d7968cf8943a9dce38c187498eaa2654f50..a48a644281d5b6ed5e07126d5bf500bf1e7ede54 100644 (file)
@@ -156,6 +156,7 @@ LIBRBD = librbd.la
 LIBKRBD = libkrbd.la
 LIBCEPHFS = libcephfs.la
 LIBERASURE_CODE = liberasure_code.la
+LIBTRACEPOINTS = tracing/libtracepoints.la
 
 if WITH_LIBAIO
 LIBOS += -laio
index 0f5dc732a9b53e14a5b11b668e08b4dab42ecd1c..2cde64543061af3fbe2fa23af2fd8c5a4ac52340 100644 (file)
@@ -1,7 +1,7 @@
 include Makefile-env.am
 
-SUBDIRS += ocf java
-DIST_SUBDIRS += gtest ocf libs3 java
+SUBDIRS += ocf java tracing
+DIST_SUBDIRS += gtest ocf libs3 java tracing
 
 
 
index 0b99c6e3f1589dd8121364c4dc42f6fddf2ad485..1d290a69f3f1d874de73c4da876edbe3aa966f36 100644 (file)
@@ -112,7 +112,8 @@ noinst_HEADERS += \
 LIBCOMMON_DEPS += \
        $(LIBERASURE_CODE) \
        $(LIBMSG) $(LIBAUTH) \
-       $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH)
+       $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
+       $(LIBTRACEPOINTS)
 
 if LINUX
 LIBCOMMON_DEPS += -lrt
index f1e9a550c81b9c5834e40e443102d2070b2f01a0..a79d6ade5d9f46bd6addf237453d81566ccec32a 100644 (file)
@@ -19,6 +19,7 @@
 #include "common/config.h"
 #include "include/utime.h"
 #include "common/Clock.h"
+#include "tracing/mutex.tp.h"
 
 Mutex::Mutex(const char *n, bool r, bool ld,
             bool bt,
@@ -77,20 +78,27 @@ Mutex::~Mutex() {
 }
 
 void Mutex::Lock(bool no_lockdep) {
+  utime_t start;
+  int r;
+
+  tracepoint(mutex, lock_enter, this, name);
+
   if (lockdep && g_lockdep && !no_lockdep) _will_lock();
 
   if (TryLock()) {
-    return;
+    goto out;
   }
 
-  utime_t start;
   if (logger && cct && cct->_conf->mutex_perf_counter)
     start = ceph_clock_now(cct);
-  int r = pthread_mutex_lock(&_m);
+  r = pthread_mutex_lock(&_m);
   if (logger && cct && cct->_conf->mutex_perf_counter)
     logger->tinc(l_mutex_wait,
                 ceph_clock_now(cct) - start);
   assert(r == 0);
   if (lockdep && g_lockdep) _locked();
   _post_lock();
+
+out:
+  tracepoint(mutex, lock_exit, this, name);
 }
diff --git a/src/tracing/Makefile.am b/src/tracing/Makefile.am
new file mode 100644 (file)
index 0000000..8da61a8
--- /dev/null
@@ -0,0 +1,8 @@
+libtracepoints_la_SOURCES = \
+       mutex.tp.c \
+       mutex.tp.h
+
+libtracepoints_la_LIBADD = -llttng-ust -ldl
+libtracepoints_la_CPPFLAGS = -DTRACEPOINT_DEFINE -DTRACEPOINT_PROBE_DYNAMIC_LINKAGE
+libtracepoints_la_LDFLAGS =
+noinst_LTLIBRARIES = libtracepoints.la
diff --git a/src/tracing/README.md b/src/tracing/README.md
new file mode 100644 (file)
index 0000000..1c86eb3
--- /dev/null
@@ -0,0 +1,32 @@
+Add New Provider
+================
+
+## Create tracepoint definition file
+
+Add tracepoint definitions for the provider into a `.tp` file. Documentation
+on defining a tracepoint can be found in `man lttng-ust`. By convention files
+are named according to the logical sub-system they correspond to (e.g.
+`mutex.tp`, `pg.tp`).
+
+## Generate tracepoint source files
+
+The `.tp` file is converted into source files using the `lttng-gen-tp` tool.
+
+    lttng-gen-tp mutex.tp -o mutex.tp.h -o mutex.tp.c
+
+## Add source files to libtracepoints.la
+
+Modify Makefile.am to include the generated source files from the previous
+step.
+
+## Commit changes to Git
+
+Commit both the source `.tp` file as well as the generated sources, and the
+changes to Makefile.am.
+
+Add Tracepoint to Existing Provider
+===================================
+
+New tracepoints can be added to an existing provider by updating the
+corresponding `.tp` file and re-generating the source files. Make sure to
+commit the updated files back into Git.
diff --git a/src/tracing/mutex.tp b/src/tracing/mutex.tp
new file mode 100644 (file)
index 0000000..82bdf15
--- /dev/null
@@ -0,0 +1,19 @@
+TRACEPOINT_EVENT(mutex, lock_enter,
+    TP_ARGS(
+        const void *, addr,
+        const char *, name),
+    TP_FIELDS(
+        ctf_integer_hex(unsigned long, addr, addr)
+        ctf_string(name, name)
+    )
+)
+
+TRACEPOINT_EVENT(mutex, lock_exit,
+    TP_ARGS(
+        const void *, addr,
+        const char *, name),
+    TP_FIELDS(
+        ctf_integer_hex(unsigned long, addr, addr)
+        ctf_string(name, name)
+    )
+)
diff --git a/src/tracing/mutex.tp.c b/src/tracing/mutex.tp.c
new file mode 100644 (file)
index 0000000..1727e80
--- /dev/null
@@ -0,0 +1,7 @@
+
+#define TRACEPOINT_CREATE_PROBES
+/*
+ * The header containing our TRACEPOINT_EVENTs.
+ */
+#define TRACEPOINT_DEFINE
+#include "mutex.tp.h"
diff --git a/src/tracing/mutex.tp.h b/src/tracing/mutex.tp.h
new file mode 100644 (file)
index 0000000..24d4554
--- /dev/null
@@ -0,0 +1,35 @@
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER mutex
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./mutex.tp.h"
+
+#if !defined(MUTEX_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define MUTEX_TP_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(mutex, lock_enter,
+    TP_ARGS(
+        const void *, addr,
+        const char *, name),
+    TP_FIELDS(
+        ctf_integer_hex(unsigned long, addr, addr)
+        ctf_string(name, name)
+    )
+)
+
+TRACEPOINT_EVENT(mutex, lock_exit,
+    TP_ARGS(
+        const void *, addr,
+        const char *, name),
+    TP_FIELDS(
+        ctf_integer_hex(unsigned long, addr, addr)
+        ctf_string(name, name)
+    )
+)
+
+#endif /* MUTEX_TP_H */
+
+#include <lttng/tracepoint-event.h>