Created
September 25, 2014 16:22
-
-
Save dotnwat/2573361ffa3e4dfac641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 873b53923069d5dc50b0a54348987a48e1b7a7ba | |
Author: Noah Watkins <noahwatkins@gmail.com> | |
Date: Fri May 30 14:13:12 2014 -0700 | |
tracing: bootstrap lttng-ust with mutex events | |
See src/tracing/README.md | |
Signed-off-by: Noah Watkins <noahwatkins@gmail.com> | |
diff --git a/configure.ac b/configure.ac | |
index 0703eb9..822bb26 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -801,6 +801,7 @@ AC_CONFIG_FILES([Makefile | |
src/ocf/ceph | |
src/ocf/rbd | |
src/java/Makefile | |
+ src/tracing/Makefile | |
man/Makefile | |
ceph.spec]) | |
AC_OUTPUT | |
diff --git a/src/Makefile-env.am b/src/Makefile-env.am | |
index e33f8cc..9e603bb 100644 | |
--- a/src/Makefile-env.am | |
+++ b/src/Makefile-env.am | |
@@ -153,6 +153,7 @@ LIBRBD = librbd.la | |
LIBKRBD = libkrbd.la | |
LIBCEPHFS = libcephfs.la | |
LIBERASURE_CODE = liberasure_code.la | |
+LIBTRACEPOINTS = tracing/libtracepoints.la | |
if WITH_LIBAIO | |
LIBOS += -laio | |
diff --git a/src/Makefile.am b/src/Makefile.am | |
index 3501a7c..b0abf7e 100644 | |
--- a/src/Makefile.am | |
+++ b/src/Makefile.am | |
@@ -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 | |
# subdirs | |
diff --git a/src/common/Makefile.am b/src/common/Makefile.am | |
index bb5c43f..c0f65d1 100644 | |
--- a/src/common/Makefile.am | |
+++ b/src/common/Makefile.am | |
@@ -111,7 +111,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 | |
diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc | |
index f1e9a55..0a407f9 100644 | |
--- a/src/common/Mutex.cc | |
+++ b/src/common/Mutex.cc | |
@@ -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,35 @@ 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); | |
+} | |
+ | |
+void Mutex::Unlock() { | |
+ _pre_unlock(); | |
+ if (lockdep && g_lockdep) _will_unlock(); | |
+ int r = pthread_mutex_unlock(&_m); | |
+ assert(r == 0); | |
+ tracepoint(mutex, unlock, this, name); | |
} | |
diff --git a/src/common/Mutex.h b/src/common/Mutex.h | |
index e26a090..e2ebe1f 100644 | |
--- a/src/common/Mutex.h | |
+++ b/src/common/Mutex.h | |
@@ -101,12 +101,7 @@ public: | |
assert(nlock == 0); | |
} | |
} | |
- void Unlock() { | |
- _pre_unlock(); | |
- if (lockdep && g_lockdep) _will_unlock(); | |
- int r = pthread_mutex_unlock(&_m); | |
- assert(r == 0); | |
- } | |
+ void Unlock(); | |
friend class Cond; | |
diff --git a/src/tracing/Makefile.am b/src/tracing/Makefile.am | |
new file mode 100644 | |
index 0000000..f759a6a | |
--- /dev/null | |
+++ b/src/tracing/Makefile.am | |
@@ -0,0 +1,8 @@ | |
+libtracepoints_la_SOURCES = \ | |
+ mutex.tp.c \ | |
+ mutex.tp.h | |
+ | |
+libtracepoints_la_LIBADD = -llttng-ust -ldl | |
+libtracepoints_la_CPPFLAGS = -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 | |
index 0000000..1c86eb3 | |
--- /dev/null | |
+++ b/src/tracing/README.md | |
@@ -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 | |
index 0000000..7cdfdb3 | |
--- /dev/null | |
+++ b/src/tracing/mutex.tp | |
@@ -0,0 +1,29 @@ | |
+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) | |
+ ) | |
+) | |
+ | |
+TRACEPOINT_EVENT(mutex, unlock, | |
+ 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 | |
index 0000000..1727e80 | |
--- /dev/null | |
+++ b/src/tracing/mutex.tp.c | |
@@ -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 | |
index 0000000..e26e86d | |
--- /dev/null | |
+++ b/src/tracing/mutex.tp.h | |
@@ -0,0 +1,45 @@ | |
+ | |
+#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) | |
+ ) | |
+) | |
+ | |
+TRACEPOINT_EVENT(mutex, unlock, | |
+ 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment