Fix: baddr_statedump tracepoint registration
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 Dec 2013 13:36:06 +0000 (08:36 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 Dec 2013 13:36:06 +0000 (08:36 -0500)
Make sure that the ust_baddr_statedump probe is registered prior to
using the tracepoint in lttng_ust_baddr_statedump(). This fix solves the
issue that in rare cases the very first ust_baddr_statedump events were
missing.

Use a reference counting approach that allows constructors/destructors
of the probe to be called many times, as long as the number of calls to
constructor matches the number of calls to destructor.

Reported-by: Paul Woegerer <paul_woegerer@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-tracepoint-event.h
liblttng-ust/Makefile.am
liblttng-ust/lttng-ust-baddr.c
liblttng-ust/ust_baddr_statedump.c [deleted file]

index be580307a5b3eda641fbab9414cb614ef9e5b791..eb6b2ea401ff7a48ff385ed443d4a7eb6e7d5426 100644 (file)
@@ -685,6 +685,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
        .minor = LTTNG_UST_PROVIDER_MINOR,
 };
 
+static int _TP_COMBINE_TOKENS(__probe_register_refcount___, TRACEPOINT_PROVIDER);
+
 /*
  * Stage 9 of tracepoint event generation.
  *
@@ -692,6 +694,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
  *
  * Generate the constructor as an externally visible symbol for use when
  * linking the probe statically.
+ *
+ * Register refcount is protected by libc dynamic loader mutex.
  */
 
 /* Reset all macros within TRACEPOINT_EVENT */
@@ -703,6 +707,10 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
        int ret;
 
+       if (_TP_COMBINE_TOKENS(__probe_register_refcount___,
+                       TRACEPOINT_PROVIDER)++) {
+               return;
+       }
        /*
         * __tracepoint_provider_check_ ## TRACEPOINT_PROVIDER() is a
         * static inline function that ensures every probe PROVIDER
@@ -724,6 +732,10 @@ _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void);
 static void
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
+       if (--_TP_COMBINE_TOKENS(__probe_register_refcount___,
+                       TRACEPOINT_PROVIDER)) {
+               return;
+       }
        lttng_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
 }
 
index b165c3219896ccda953f2ace5ad3a1decb3cb110..e9022d8a469d899f2910cf1931006fbc7538fa78 100644 (file)
@@ -37,7 +37,6 @@ liblttng_ust_runtime_la_SOURCES = \
        lttng-hash-helper.h \
        lttng-ust-baddr.c \
        lttng-ust-baddr.h \
-       ust_baddr_statedump.c \
        ust_baddr_statedump.h \
        tracepoint-internal.h \
        clock.h \
index b7843e24886c11bb99531470b97c11a5ae66158c..90ffe688a3c65ba18c28f54a719f5a33ac235db8 100644 (file)
@@ -36,6 +36,8 @@
 #include "lttng-ust-baddr.h"
 
 #define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#define TP_SESSION_CHECK
 #include "ust_baddr_statedump.h"
 
 struct extract_data {
@@ -199,10 +201,12 @@ void lttng_ust_baddr_statedump_init(void)
 {
        __tracepoints__init();
        __tracepoints__ptrs_init();
+       __lttng_events_init__ust_baddr_statedump();
 }
 
 void lttng_ust_baddr_statedump_destroy(void)
 {
+       __lttng_events_exit__ust_baddr_statedump();
        __tracepoints__ptrs_destroy();
        __tracepoints__destroy();
 }
diff --git a/liblttng-ust/ust_baddr_statedump.c b/liblttng-ust/ust_baddr_statedump.c
deleted file mode 100644 (file)
index 9097008..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2013  Paul Woegerer <paul_woegerer@mentor.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#define _LGPL_SOURCE
-#define TRACEPOINT_CREATE_PROBES
-#define TP_SESSION_CHECK
-#include "ust_baddr_statedump.h"
This page took 0.027559 seconds and 4 git commands to generate.