From: Noah Watkins Date: Fri, 30 May 2014 21:13:12 +0000 (-0700) Subject: tracing: bootstrap lttng-ust with mutex events X-Git-Tag: v0.86~231^2~80 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=115cfb3a2ec0fea10bbb43878b5603de1c71f7e0;p=ceph.git tracing: bootstrap lttng-ust with mutex events See src/tracing/README.md Signed-off-by: Noah Watkins --- diff --git a/configure.ac b/configure.ac index 38c6deaba9e9..40fa0ef78664 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/Makefile-env.am b/src/Makefile-env.am index 57fa8d7968cf..a48a644281d5 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 0f5dc732a9b5..2cde64543061 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 diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 0b99c6e3f158..1d290a69f3f1 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc index f1e9a550c81b..a79d6ade5d9f 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,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 index 000000000000..8da61a843e7f --- /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_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 index 000000000000..1c86eb3b04ba --- /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 000000000000..82bdf15a5220 --- /dev/null +++ b/src/tracing/mutex.tp @@ -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 index 000000000000..1727e8089c76 --- /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 000000000000..24d45543863b --- /dev/null +++ b/src/tracing/mutex.tp.h @@ -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 + +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