All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: notrace missing in lttng-ust
       [not found] <4FED6718.1000205@mentor.com>
@ 2012-06-30 18:16 ` Mathieu Desnoyers
       [not found] ` <20120630181600.GB30747@Krystal>
  1 sibling, 0 replies; 11+ messages in thread
From: Mathieu Desnoyers @ 2012-06-30 18:16 UTC (permalink / raw)
  To: Woegerer, Paul; +Cc: lttng-dev

* Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
> Hi Mathieu,
>
> libust 0.x uses notrace (__attribute__((no_instrument_function)) for all  
> functions that are involved in event emitting.
>
> For example:
> ./libust/marker.c:122:notrace void __ust_marker_empty_function(const  
> struct ust_marker *mdata,
> ./libust/marker.c:137:notrace void ust_marker_probe_cb(const struct  
> ust_marker *mdata,
> ./libust/marker.c:197:static notrace void  
> ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
>
> I just realized that this is no more the case for lttng-ust.
> Was it a conscious decision not to use notrace for LTTng 2.0 lttng-ust,  
> or is it just missing ?

just missing. only needed for -finstrument-functions.

>
> I would like to have notrace also in lttng-ust, at least for the  
> _DECLARE_TRACEPOINT macro in tracepoint.h.

I guess the probes generated by ust-tracepoint-event.h would need that
too. A patch that adds those noinline everywhere where it's needed
(hint: all functions called on the tracing patch within public headers
of lttng-ust 2.0 would be a good start). Please test the patch by
tracing a program automatically instrumented by -finstrument-functions
and see if things blow up.

Thanks,

Mathieu

> Like this for example:
>
> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
> index 5bab476..71665dc 100644
> --- a/include/lttng/tracepoint.h
> +++ b/include/lttng/tracepoint.h
> @@ -137,6 +137,7 @@ extern "C" {
>
>  #define _DECLARE_TRACEPOINT(_provider, _name, ...)     \
>  extern struct tracepoint __tracepoint_##_provider##___##_name;           
>   \
> +static inline void  
> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))  
> __attribute__ ((no_instrument_function));    \
>  static inline void  
> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
>  {                                            \
>      struct tracepoint_probe *__tp_probe;                        \
> @@ -158,12 +159,16 @@ end:     \
>      tp_rcu_read_unlock_bp();                            \
>  }                                            \
>  static inline void __tracepoint_register_##_provider##___##_name(char  
> *name,        \
> +        void (*func)(void), void *data) __attribute__  
> ((no_instrument_function));    \
> +static inline void __tracepoint_register_##_provider##___##_name(char  
> *name,        \
>          void (*func)(void), void *data) \
>  {                                            \
>      __tracepoint_probe_register(name, func, data,     \
>          __tracepoint_##_provider##___##_name.signature); \
>  }                                            \
>  static inline void __tracepoint_unregister_##_provider##___##_name(char 
> *name,        \
> +        void (*func)(void), void *data) __attribute__  
> ((no_instrument_function));    \
> +static inline void __tracepoint_unregister_##_provider##___##_name(char  
> *name,        \
>          void (*func)(void), void *data) \
>  {                                            \
>      __tracepoint_probe_unregister(name, func, data); \
>
> Greetings,
> Paul
>
> -- 
> Paul Woegerer | SW Development Engineer
> Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
> P 43.1.535991320
> Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS
>
> Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
> Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found] ` <20120630181600.GB30747@Krystal>
@ 2012-07-03  7:45   ` Woegerer, Paul
       [not found]   ` <4FF2A31D.9020100@mentor.com>
  1 sibling, 0 replies; 11+ messages in thread
From: Woegerer, Paul @ 2012-07-03  7:45 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev

[-- Attachment #1: Type: text/plain, Size: 4621 bytes --]

Hi Mathieu,

here is the revised patch that makes tracepoint.h and 
ust-tracepoint-event.h robust against -finstrument-functions.
I tested it against our small ackermann sample (3 custom tracepoints + 
-finstrument-functions). See screenshots.

Btw, nice macro metaprogramming in ust-tracepoint-event.h :)

Thanks,
Paul

On 06/30/2012 08:16 PM, Mathieu Desnoyers wrote:
> * Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
>> Hi Mathieu,
>>
>> libust 0.x uses notrace (__attribute__((no_instrument_function)) for all
>> functions that are involved in event emitting.
>>
>> For example:
>> ./libust/marker.c:122:notrace void __ust_marker_empty_function(const
>> struct ust_marker *mdata,
>> ./libust/marker.c:137:notrace void ust_marker_probe_cb(const struct
>> ust_marker *mdata,
>> ./libust/marker.c:197:static notrace void
>> ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
>>
>> I just realized that this is no more the case for lttng-ust.
>> Was it a conscious decision not to use notrace for LTTng 2.0 lttng-ust,
>> or is it just missing ?
> just missing. only needed for -finstrument-functions.
>
>> I would like to have notrace also in lttng-ust, at least for the
>> _DECLARE_TRACEPOINT macro in tracepoint.h.
> I guess the probes generated by ust-tracepoint-event.h would need that
> too. A patch that adds those noinline everywhere where it's needed
> (hint: all functions called on the tracing patch within public headers
> of lttng-ust 2.0 would be a good start). Please test the patch by
> tracing a program automatically instrumented by -finstrument-functions
> and see if things blow up.
>
> Thanks,
>
> Mathieu
>
>> Like this for example:
>>
>> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
>> index 5bab476..71665dc 100644
>> --- a/include/lttng/tracepoint.h
>> +++ b/include/lttng/tracepoint.h
>> @@ -137,6 +137,7 @@ extern "C" {
>>
>>   #define _DECLARE_TRACEPOINT(_provider, _name, ...)     \
>>   extern struct tracepoint __tracepoint_##_provider##___##_name;
>>    \
>> +static inline void
>> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))
>> __attribute__ ((no_instrument_function));    \
>>   static inline void
>> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
>>   {                                            \
>>       struct tracepoint_probe *__tp_probe;                        \
>> @@ -158,12 +159,16 @@ end:     \
>>       tp_rcu_read_unlock_bp();                            \
>>   }                                            \
>>   static inline void __tracepoint_register_##_provider##___##_name(char
>> *name,        \
>> +        void (*func)(void), void *data) __attribute__
>> ((no_instrument_function));    \
>> +static inline void __tracepoint_register_##_provider##___##_name(char
>> *name,        \
>>           void (*func)(void), void *data) \
>>   {                                            \
>>       __tracepoint_probe_register(name, func, data,     \
>>           __tracepoint_##_provider##___##_name.signature); \
>>   }                                            \
>>   static inline void __tracepoint_unregister_##_provider##___##_name(char
>> *name,        \
>> +        void (*func)(void), void *data) __attribute__
>> ((no_instrument_function));    \
>> +static inline void __tracepoint_unregister_##_provider##___##_name(char
>> *name,        \
>>           void (*func)(void), void *data) \
>>   {                                            \
>>       __tracepoint_probe_unregister(name, func, data); \
>>
>> Greetings,
>> Paul
>>
>> -- 
>> Paul Woegerer | SW Development Engineer
>> Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
>> P 43.1.535991320
>> Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS
>>
>> Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
>> Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
>>
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev@lists.lttng.org
>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


-- 
Paul Woegerer | SW Development Engineer
Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
P 43.1.535991320
Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.


[-- Attachment #2: 0001-Make-lttng-ust-robust-against-finstrument-functions.patch --]
[-- Type: text/x-patch, Size: 9606 bytes --]

From 29ce637941c1e3efefb2b5a82c2683c57f583ac1 Mon Sep 17 00:00:00 2001
From: Paul Woegerer <paul_woegerer@mentor.com>
Date: Tue, 3 Jul 2012 09:28:24 +0200
Subject: [PATCH] Make lttng-ust robust against -finstrument-functions.

---
 configure.ac                         |   12 ++++++++++++
 include/lttng/ringbuffer-config.h    |   20 ++++++++++++++++++++
 include/lttng/tracepoint.h           |   11 +++++++++++
 include/lttng/ust-config.h.in        |    3 +++
 include/lttng/ust-tracepoint-event.h |   11 +++++++++++
 5 files changed, 57 insertions(+)

diff --git a/configure.ac b/configure.ac
index edd3c20..b12216f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,7 @@ AC_CONFIG_SRCDIR([include/lttng/tracepoint.h])
 AC_CONFIG_HEADERS([config.h include/lttng/ust-config.h])
 AH_TEMPLATE([LTTNG_UST_HAVE_EFFICIENT_UNALIGNED_ACCESS], [Use efficient unaligned access.])
 AH_TEMPLATE([LTTNG_UST_HAVE_SDT_INTEGRATION], [SystemTap integration via sdt.h])
+AH_TEMPLATE([LTTNG_NOTRACE], [Prevent -finstrument-functions instrumentation])
 
 # Compute minor/major/patchlevel version numbers
 AC_PROG_SED
@@ -264,6 +265,17 @@ AS_IF([test "x$with_sdt" = "xyes"],[
 	])
 ])
 
+instrument_func_save_cflags="$CFLAGS"
+CFLAGS=-finstrument-functions
+AC_MSG_CHECKING([whether CC supports -finstrument-functions])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],[
+	AC_MSG_RESULT([yes])
+	AC_DEFINE([LTTNG_NOTRACE], [__attribute__((no_instrument_function))])
+],[
+	AC_MSG_RESULT([no])
+])
+CFLAGS="$instrument_func_save_cflags"
+
 #currently disabled.
 	#tests/hello2/Makefile
 	#tests/basic/Makefile
diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 24e7dbe..232e754 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -219,6 +219,10 @@ struct lttng_ust_lib_ring_buffer_ctx {
 	char padding[LTTNG_UST_RING_BUFFER_CTX_PADDING];
 };
 
+#ifndef LTTNG_NOTRACE
+#define LTTNG_NOTRACE
+#endif
+
 /**
  * lib_ring_buffer_ctx_init - initialize ring buffer context
  * @ctx: ring buffer context to initialize
@@ -232,6 +236,11 @@ static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			      struct channel *chan, void *priv,
 			      size_t data_size, int largest_align,
+			      int cpu, struct lttng_ust_shm_handle *handle) LTTNG_NOTRACE;
+static inline
+void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			      struct channel *chan, void *priv,
+			      size_t data_size, int largest_align,
 			      int cpu, struct lttng_ust_shm_handle *handle)
 {
 	ctx->chan = chan;
@@ -276,6 +285,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) LTTNG_NOTRACE;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return offset_align(align_drift, size_of_type);
@@ -290,6 +301,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) LTTNG_NOTRACE;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return 0;
@@ -303,6 +316,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  */
 static inline
 void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			   size_t alignment) LTTNG_NOTRACE;
+static inline
+void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			   size_t alignment)
 {
 	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
@@ -316,6 +332,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 static inline
 int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
 			     unsigned int switch_timer_interval,
+			     unsigned int read_timer_interval) LTTNG_NOTRACE;
+static inline
+int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
+			     unsigned int switch_timer_interval,
 			     unsigned int read_timer_interval)
 {
 	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 5bab476..855b022 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -23,6 +23,10 @@
 #include <assert.h>
 #include <lttng/ust-config.h>	/* for sdt */
 
+#ifndef LTTNG_NOTRACE
+#define LTTNG_NOTRACE
+#endif
+
 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
 #define SDT_USE_VARIADIC
 #include <sys/sdt.h>
@@ -137,6 +141,7 @@ extern "C" {
 
 #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
 extern struct tracepoint __tracepoint_##_provider##___##_name;				\
+static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) LTTNG_NOTRACE;	\
 static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
 {											\
 	struct tracepoint_probe *__tp_probe;						\
@@ -158,12 +163,16 @@ end:											\
 	tp_rcu_read_unlock_bp();							\
 }											\
 static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) LTTNG_NOTRACE;					\
+static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_register(name, func, data,					\
 		__tracepoint_##_provider##___##_name.signature);			\
 }											\
 static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) LTTNG_NOTRACE;					\
+static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_unregister(name, func, data);				\
@@ -249,6 +258,7 @@ int __tracepoint_registered
 struct tracepoint_dlopen tracepoint_dlopen
 	__attribute__((weak, visibility("hidden")));
 
+static void __attribute__((constructor)) __tracepoints__init(void) LTTNG_NOTRACE;
 static void __attribute__((constructor)) __tracepoints__init(void)
 {
 	if (__tracepoint_registered++)
@@ -285,6 +295,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
 				__start___tracepoints_ptrs);
 }
 
+static void __attribute__((destructor)) __tracepoints__destroy(void) LTTNG_NOTRACE;
 static void __attribute__((destructor)) __tracepoints__destroy(void)
 {
 	int ret;
diff --git a/include/lttng/ust-config.h.in b/include/lttng/ust-config.h.in
index 5d1ee40..b75dfb8 100644
--- a/include/lttng/ust-config.h.in
+++ b/include/lttng/ust-config.h.in
@@ -5,3 +5,6 @@
 
 /* DTrace/GDB/SystemTap integration via sdt.h */
 #undef LTTNG_UST_HAVE_SDT_INTEGRATION
+
+/* Prevent -finstrument-functions instrumentation */
+#undef LTTNG_NOTRACE
diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index 78d85af..35c33dd 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -89,6 +89,10 @@
 		__max1 > __max2 ? __max1: __max2;	\
 	})
 
+#ifndef LTTNG_NOTRACE
+#define LTTNG_NOTRACE
+#endif
+
 /*
  * Stage 0 of tracepoint event generation.
  *
@@ -278,6 +282,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
+static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) LTTNG_NOTRACE; \
 static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
 {									      \
 	size_t __event_len = 0;						      \
@@ -330,6 +335,7 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
 static inline								      \
+size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) LTTNG_NOTRACE; \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 {									      \
 	size_t __event_align = 1;					      \
@@ -400,6 +406,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
+static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) LTTNG_NOTRACE; \
 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 {									      \
 	struct ltt_event *__event = __tp_data;				      \
@@ -547,6 +554,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 static void __attribute__((constructor))
+_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) LTTNG_NOTRACE;
+static void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
 	int ret;
@@ -556,6 +565,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 }
 
 static void __attribute__((destructor))
+_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) LTTNG_NOTRACE;
+static void __attribute__((destructor))
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
 	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-- 
1.7.10.4


[-- Attachment #3: ackermann_before.png --]
[-- Type: image/png, Size: 32262 bytes --]

[-- Attachment #4: ackermann_after.png --]
[-- Type: image/png, Size: 14661 bytes --]

[-- Attachment #5: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]   ` <4FF2A31D.9020100@mentor.com>
@ 2012-07-17 13:42     ` Woegerer, Paul
  2012-07-17 14:13     ` Mathieu Desnoyers
       [not found]     ` <20120717141301.GA21204@Krystal>
  2 siblings, 0 replies; 11+ messages in thread
From: Woegerer, Paul @ 2012-07-17 13:42 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 5109 bytes --]

Hello Mathieu,

What is the status regarding this patch.
Any reason why it doesn't get merged ?

Thanks,
Paul

On 07/03/2012 09:45 AM, Woegerer, Paul wrote:
> Hi Mathieu,
>
> here is the revised patch that makes tracepoint.h and 
> ust-tracepoint-event.h robust against -finstrument-functions.
> I tested it against our small ackermann sample (3 custom tracepoints + 
> -finstrument-functions). See screenshots.
>
> Btw, nice macro metaprogramming in ust-tracepoint-event.h :)
>
> Thanks,
> Paul
>
> On 06/30/2012 08:16 PM, Mathieu Desnoyers wrote:
>> * Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
>>> Hi Mathieu,
>>>
>>> libust 0.x uses notrace (__attribute__((no_instrument_function)) for 
>>> all
>>> functions that are involved in event emitting.
>>>
>>> For example:
>>> ./libust/marker.c:122:notrace void __ust_marker_empty_function(const
>>> struct ust_marker *mdata,
>>> ./libust/marker.c:137:notrace void ust_marker_probe_cb(const struct
>>> ust_marker *mdata,
>>> ./libust/marker.c:197:static notrace void
>>> ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
>>>
>>> I just realized that this is no more the case for lttng-ust.
>>> Was it a conscious decision not to use notrace for LTTng 2.0 lttng-ust,
>>> or is it just missing ?
>> just missing. only needed for -finstrument-functions.
>>
>>> I would like to have notrace also in lttng-ust, at least for the
>>> _DECLARE_TRACEPOINT macro in tracepoint.h.
>> I guess the probes generated by ust-tracepoint-event.h would need that
>> too. A patch that adds those noinline everywhere where it's needed
>> (hint: all functions called on the tracing patch within public headers
>> of lttng-ust 2.0 would be a good start). Please test the patch by
>> tracing a program automatically instrumented by -finstrument-functions
>> and see if things blow up.
>>
>> Thanks,
>>
>> Mathieu
>>
>>> Like this for example:
>>>
>>> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
>>> index 5bab476..71665dc 100644
>>> --- a/include/lttng/tracepoint.h
>>> +++ b/include/lttng/tracepoint.h
>>> @@ -137,6 +137,7 @@ extern "C" {
>>>
>>>   #define _DECLARE_TRACEPOINT(_provider, _name, ...)     \
>>>   extern struct tracepoint __tracepoint_##_provider##___##_name;
>>>    \
>>> +static inline void
>>> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))
>>> __attribute__ ((no_instrument_function));    \
>>>   static inline void
>>> __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
>>>   {                                            \
>>>       struct tracepoint_probe *__tp_probe;                        \
>>> @@ -158,12 +159,16 @@ end:     \
>>>       tp_rcu_read_unlock_bp();                            \
>>>   }                                            \
>>>   static inline void __tracepoint_register_##_provider##___##_name(char
>>> *name,        \
>>> +        void (*func)(void), void *data) __attribute__
>>> ((no_instrument_function));    \
>>> +static inline void __tracepoint_register_##_provider##___##_name(char
>>> *name,        \
>>>           void (*func)(void), void *data) \
>>>   {                                            \
>>>       __tracepoint_probe_register(name, func, data,     \
>>>           __tracepoint_##_provider##___##_name.signature); \
>>>   }                                            \
>>>   static inline void 
>>> __tracepoint_unregister_##_provider##___##_name(char
>>> *name,        \
>>> +        void (*func)(void), void *data) __attribute__
>>> ((no_instrument_function));    \
>>> +static inline void 
>>> __tracepoint_unregister_##_provider##___##_name(char
>>> *name,        \
>>>           void (*func)(void), void *data) \
>>>   {                                            \
>>>       __tracepoint_probe_unregister(name, func, data); \
>>>
>>> Greetings,
>>> Paul
>>>
>>> -- 
>>> Paul Woegerer | SW Development Engineer
>>> Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
>>> P 43.1.535991320
>>> Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS
>>>
>>> Android is a trademark of Google Inc. Use of this trademark is 
>>> subject to Google Permissions.
>>> Linux is the registered trademark of Linus Torvalds in the U.S. and 
>>> other countries.
>>>
>>>
>>> _______________________________________________
>>> lttng-dev mailing list
>>> lttng-dev@lists.lttng.org
>>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
>
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


-- 
Paul Woegerer | SW Development Engineer
Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
P 43.1.535991320
Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.


[-- Attachment #1.2: Type: text/html, Size: 10164 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]   ` <4FF2A31D.9020100@mentor.com>
  2012-07-17 13:42     ` Woegerer, Paul
@ 2012-07-17 14:13     ` Mathieu Desnoyers
       [not found]     ` <20120717141301.GA21204@Krystal>
  2 siblings, 0 replies; 11+ messages in thread
From: Mathieu Desnoyers @ 2012-07-17 14:13 UTC (permalink / raw)
  To: Woegerer, Paul; +Cc: lttng-dev

* Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
> Hi Mathieu,
>
> here is the revised patch that makes tracepoint.h and  
> ust-tracepoint-event.h robust against -finstrument-functions.
> I tested it against our small ackermann sample (3 custom tracepoints +  
> -finstrument-functions). See screenshots.
>
> Btw, nice macro metaprogramming in ust-tracepoint-event.h :)

Some feedback, sorry for the delay, I've been busy working on filtering,

[...]


> From 29ce637941c1e3efefb2b5a82c2683c57f583ac1 Mon Sep 17 00:00:00 2001
> From: Paul Woegerer <paul_woegerer@mentor.com>
> Date: Tue, 3 Jul 2012 09:28:24 +0200
> Subject: [PATCH] Make lttng-ust robust against -finstrument-functions.
> 
> ---
>  configure.ac                         |   12 ++++++++++++
>  include/lttng/ringbuffer-config.h    |   20 ++++++++++++++++++++
>  include/lttng/tracepoint.h           |   11 +++++++++++
>  include/lttng/ust-config.h.in        |    3 +++
>  include/lttng/ust-tracepoint-event.h |   11 +++++++++++
>  5 files changed, 57 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index edd3c20..b12216f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -21,6 +21,7 @@ AC_CONFIG_SRCDIR([include/lttng/tracepoint.h])
>  AC_CONFIG_HEADERS([config.h include/lttng/ust-config.h])
>  AH_TEMPLATE([LTTNG_UST_HAVE_EFFICIENT_UNALIGNED_ACCESS], [Use efficient unaligned access.])
>  AH_TEMPLATE([LTTNG_UST_HAVE_SDT_INTEGRATION], [SystemTap integration via sdt.h])
> +AH_TEMPLATE([LTTNG_NOTRACE], [Prevent -finstrument-functions instrumentation])

I think we want to make the notrace always active. I don't see the point
in letting UST lib be compiled with those tracing stubs in place.

>  
>  # Compute minor/major/patchlevel version numbers
>  AC_PROG_SED
> @@ -264,6 +265,17 @@ AS_IF([test "x$with_sdt" = "xyes"],[
>  	])
>  ])
>  
> +instrument_func_save_cflags="$CFLAGS"
> +CFLAGS=-finstrument-functions
> +AC_MSG_CHECKING([whether CC supports -finstrument-functions])
> +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],[
> +	AC_MSG_RESULT([yes])
> +	AC_DEFINE([LTTNG_NOTRACE], [__attribute__((no_instrument_function))])
> +],[
> +	AC_MSG_RESULT([no])
> +])
> +CFLAGS="$instrument_func_save_cflags"

Well, pretty much all recent gcc and compilers supporting gcc extensions
like llvm seem to support the no_instrument_function attribute. I'd be
tempted to remove this stuff from configure.ac and assume
__attribute__((no_instrument_function)) can be used. We'll manage if we
see that it breaks compilers we care about.

We should create a include/lttng/ust-compiler.h with:

#define lttng_ust_notrace __attribute__((no_instrument_function))

so we don't duplicate the define.

> +
>  #currently disabled.
>  	#tests/hello2/Makefile
>  	#tests/basic/Makefile
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 24e7dbe..232e754 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -219,6 +219,10 @@ struct lttng_ust_lib_ring_buffer_ctx {
>  	char padding[LTTNG_UST_RING_BUFFER_CTX_PADDING];
>  };
>  
> +#ifndef LTTNG_NOTRACE
> +#define LTTNG_NOTRACE
> +#endif
> +
>  /**
>   * lib_ring_buffer_ctx_init - initialize ring buffer context
>   * @ctx: ring buffer context to initialize
> @@ -232,6 +236,11 @@ static inline
>  void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			      struct channel *chan, void *priv,
>  			      size_t data_size, int largest_align,
> +			      int cpu, struct lttng_ust_shm_handle *handle) LTTNG_NOTRACE;
> +static inline
> +void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			      struct channel *chan, void *priv,
> +			      size_t data_size, int largest_align,
>  			      int cpu, struct lttng_ust_shm_handle *handle)

Can't we simply specify the attribute on the function definition, rather
than having to duplicate its prototype ?

Thanks,

Mathieu

>  {
>  	ctx->chan = chan;
> @@ -276,6 +285,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) LTTNG_NOTRACE;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return offset_align(align_drift, size_of_type);
> @@ -290,6 +301,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) LTTNG_NOTRACE;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return 0;
> @@ -303,6 +316,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   */
>  static inline
>  void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			   size_t alignment) LTTNG_NOTRACE;
> +static inline
> +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			   size_t alignment)
>  {
>  	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
> @@ -316,6 +332,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  static inline
>  int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>  			     unsigned int switch_timer_interval,
> +			     unsigned int read_timer_interval) LTTNG_NOTRACE;
> +static inline
> +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
> +			     unsigned int switch_timer_interval,
>  			     unsigned int read_timer_interval)
>  {
>  	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
> index 5bab476..855b022 100644
> --- a/include/lttng/tracepoint.h
> +++ b/include/lttng/tracepoint.h
> @@ -23,6 +23,10 @@
>  #include <assert.h>
>  #include <lttng/ust-config.h>	/* for sdt */
>  
> +#ifndef LTTNG_NOTRACE
> +#define LTTNG_NOTRACE
> +#endif
> +
>  #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
>  #define SDT_USE_VARIADIC
>  #include <sys/sdt.h>
> @@ -137,6 +141,7 @@ extern "C" {
>  
>  #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
>  extern struct tracepoint __tracepoint_##_provider##___##_name;				\
> +static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) LTTNG_NOTRACE;	\
>  static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
>  {											\
>  	struct tracepoint_probe *__tp_probe;						\
> @@ -158,12 +163,16 @@ end:											\
>  	tp_rcu_read_unlock_bp();							\
>  }											\
>  static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) LTTNG_NOTRACE;					\
> +static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_register(name, func, data,					\
>  		__tracepoint_##_provider##___##_name.signature);			\
>  }											\
>  static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) LTTNG_NOTRACE;					\
> +static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_unregister(name, func, data);				\
> @@ -249,6 +258,7 @@ int __tracepoint_registered
>  struct tracepoint_dlopen tracepoint_dlopen
>  	__attribute__((weak, visibility("hidden")));
>  
> +static void __attribute__((constructor)) __tracepoints__init(void) LTTNG_NOTRACE;
>  static void __attribute__((constructor)) __tracepoints__init(void)
>  {
>  	if (__tracepoint_registered++)
> @@ -285,6 +295,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
>  				__start___tracepoints_ptrs);
>  }
>  
> +static void __attribute__((destructor)) __tracepoints__destroy(void) LTTNG_NOTRACE;
>  static void __attribute__((destructor)) __tracepoints__destroy(void)
>  {
>  	int ret;
> diff --git a/include/lttng/ust-config.h.in b/include/lttng/ust-config.h.in
> index 5d1ee40..b75dfb8 100644
> --- a/include/lttng/ust-config.h.in
> +++ b/include/lttng/ust-config.h.in
> @@ -5,3 +5,6 @@
>  
>  /* DTrace/GDB/SystemTap integration via sdt.h */
>  #undef LTTNG_UST_HAVE_SDT_INTEGRATION
> +
> +/* Prevent -finstrument-functions instrumentation */
> +#undef LTTNG_NOTRACE
> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
> index 78d85af..35c33dd 100644
> --- a/include/lttng/ust-tracepoint-event.h
> +++ b/include/lttng/ust-tracepoint-event.h
> @@ -89,6 +89,10 @@
>  		__max1 > __max2 ? __max1: __max2;	\
>  	})
>  
> +#ifndef LTTNG_NOTRACE
> +#define LTTNG_NOTRACE
> +#endif
> +
>  /*
>   * Stage 0 of tracepoint event generation.
>   *
> @@ -278,6 +282,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
> +static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) LTTNG_NOTRACE; \
>  static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>  {									      \
>  	size_t __event_len = 0;						      \
> @@ -330,6 +335,7 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>  static inline								      \
> +size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) LTTNG_NOTRACE; \
>  size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>  {									      \
>  	size_t __event_align = 1;					      \
> @@ -400,6 +406,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
> +static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) LTTNG_NOTRACE; \
>  static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>  {									      \
>  	struct ltt_event *__event = __tp_data;				      \
> @@ -547,6 +554,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>  /* Reset all macros within TRACEPOINT_EVENT */
>  #include <lttng/ust-tracepoint-event-reset.h>
>  static void __attribute__((constructor))
> +_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) LTTNG_NOTRACE;
> +static void __attribute__((constructor))
>  _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  {
>  	int ret;
> @@ -556,6 +565,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  }
>  
>  static void __attribute__((destructor))
> +_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) LTTNG_NOTRACE;
> +static void __attribute__((destructor))
>  _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>  {
>  	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
> -- 
> 1.7.10.4
> 




-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]     ` <20120717141301.GA21204@Krystal>
@ 2012-07-18 10:33       ` Woegerer, Paul
       [not found]       ` <500690E4.4020503@mentor.com>
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Woegerer, Paul @ 2012-07-18 10:33 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

On 07/17/2012 04:13 PM, Mathieu Desnoyers wrote:

> I think we want to make the notrace always active. I don't see the point
> in letting UST lib be compiled with those tracing stubs in place.

OK, I'll remove that ...

> We should create a include/lttng/ust-compiler.h with:
>
> #define lttng_ust_notrace __attribute__((no_instrument_function))
>
> so we don't duplicate the define.

... and use include/lttng/ust-compiler.h instead.

> Can't we simply specify the attribute on the function definition, rather
> than having to duplicate its prototype ?

No. I tried that before but unfortunately it didn't work. It only works 
consistently if the attribute is on the function declaration. If you try 
to put it on the definition it will result in compiler errors either 
when tracepoint providers are compiled or when tracepoint provider 
header files are used.

The updated patch is in the attachment.

Thanks,
Paul

-- 
Paul Woegerer | SW Development Engineer
Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
P 43.1.535991320
Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.


[-- Attachment #2: 0001-Make-lttng-ust-robust-against-finstrument-functions.patch --]
[-- Type: text/x-patch, Size: 9661 bytes --]

From 46e709a85edbca6b9c869148cadd2abac2f98acf Mon Sep 17 00:00:00 2001
From: Paul Woegerer <paul_woegerer@mentor.com>
Date: Wed, 18 Jul 2012 12:27:07 +0200
Subject: [PATCH] Make lttng-ust robust against -finstrument-functions.

---
 include/Makefile.am                  |    1 +
 include/lttng/ringbuffer-config.h    |   17 +++++++++++++++++
 include/lttng/tracepoint.h           |    8 ++++++++
 include/lttng/ust-compiler.h         |   21 +++++++++++++++++++++
 include/lttng/ust-tracepoint-event.h |    8 ++++++++
 5 files changed, 55 insertions(+)
 create mode 100644 include/lttng/ust-compiler.h

diff --git a/include/Makefile.am b/include/Makefile.am
index 633260b..208e74e 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -14,6 +14,7 @@ nobase_include_HEADERS = \
 	lttng/ringbuffer-abi.h \
 	lttng/ust-tracer.h \
 	lttng/ust-config.h \
+	lttng/ust-compiler.h \
 	lttng/ust.h \
 	lttng/ust-endian.h \
 	lttng/ringbuffer-config.h \
diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 24e7dbe..408d95a 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -27,6 +27,7 @@
 #include <urcu/arch.h>
 #include <string.h>
 #include "lttng/align.h"
+#include <lttng/ust-compiler.h>
 
 struct lttng_ust_lib_ring_buffer;
 struct channel;
@@ -232,6 +233,11 @@ static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			      struct channel *chan, void *priv,
 			      size_t data_size, int largest_align,
+			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
+static inline
+void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			      struct channel *chan, void *priv,
+			      size_t data_size, int largest_align,
 			      int cpu, struct lttng_ust_shm_handle *handle)
 {
 	ctx->chan = chan;
@@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return offset_align(align_drift, size_of_type);
@@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return 0;
@@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  */
 static inline
 void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			   size_t alignment) lttng_ust_notrace;
+static inline
+void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			   size_t alignment)
 {
 	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
@@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 static inline
 int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
 			     unsigned int switch_timer_interval,
+			     unsigned int read_timer_interval) lttng_ust_notrace;
+static inline
+int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
+			     unsigned int switch_timer_interval,
 			     unsigned int read_timer_interval)
 {
 	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 5bab476..77595d3 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -22,6 +22,7 @@
 #include <string.h>	/* for memset */
 #include <assert.h>
 #include <lttng/ust-config.h>	/* for sdt */
+#include <lttng/ust-compiler.h>
 
 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
 #define SDT_USE_VARIADIC
@@ -137,6 +138,7 @@ extern "C" {
 
 #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
 extern struct tracepoint __tracepoint_##_provider##___##_name;				\
+static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
 static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
 {											\
 	struct tracepoint_probe *__tp_probe;						\
@@ -158,12 +160,16 @@ end:											\
 	tp_rcu_read_unlock_bp();							\
 }											\
 static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) lttng_ust_notrace;					\
+static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_register(name, func, data,					\
 		__tracepoint_##_provider##___##_name.signature);			\
 }											\
 static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) lttng_ust_notrace;					\
+static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_unregister(name, func, data);				\
@@ -249,6 +255,7 @@ int __tracepoint_registered
 struct tracepoint_dlopen tracepoint_dlopen
 	__attribute__((weak, visibility("hidden")));
 
+static void __attribute__((constructor)) __tracepoints__init(void) lttng_ust_notrace;
 static void __attribute__((constructor)) __tracepoints__init(void)
 {
 	if (__tracepoint_registered++)
@@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
 				__start___tracepoints_ptrs);
 }
 
+static void __attribute__((destructor)) __tracepoints__destroy(void) lttng_ust_notrace;
 static void __attribute__((destructor)) __tracepoints__destroy(void)
 {
 	int ret;
diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
new file mode 100644
index 0000000..c35a23e
--- /dev/null
+++ b/include/lttng/ust-compiler.h
@@ -0,0 +1,21 @@
+#ifndef _LTTNG_UST_COMPILER_H
+#define _LTTNG_UST_COMPILER_H
+
+/*
+ * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *                       Paul Woegerer <paul_woegerer@mentor.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define lttng_ust_notrace __attribute__((no_instrument_function))
+
+#endif /* _LTTNG_UST_COMPILER_H */
diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index 8db1e68..8628dbe 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -16,6 +16,7 @@
 #include <urcu/compiler.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
+#include <lttng/ust-compiler.h>
 #include <string.h>
 
 /*
@@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
+static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
 static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
 {									      \
 	size_t __event_len = 0;						      \
@@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
 static inline								      \
+size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 {									      \
 	size_t __event_align = 1;					      \
@@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
  */
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
+static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 {									      \
 	struct ltt_event *__event = __tp_data;				      \
@@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 static void __attribute__((constructor))
+_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
+static void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
 	int ret;
@@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 }
 
 static void __attribute__((destructor))
+_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
+static void __attribute__((destructor))
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
 	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-- 
1.7.10.4


[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]       ` <500690E4.4020503@mentor.com>
@ 2012-07-18 11:42         ` Mathieu Desnoyers
       [not found]         ` <20120718114216.GA4061@Krystal>
  1 sibling, 0 replies; 11+ messages in thread
From: Mathieu Desnoyers @ 2012-07-18 11:42 UTC (permalink / raw)
  To: Woegerer, Paul; +Cc: lttng-dev

* Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
> On 07/17/2012 04:13 PM, Mathieu Desnoyers wrote:
>
>> I think we want to make the notrace always active. I don't see the point
>> in letting UST lib be compiled with those tracing stubs in place.
>
> OK, I'll remove that ...
>
>> We should create a include/lttng/ust-compiler.h with:
>>
>> #define lttng_ust_notrace __attribute__((no_instrument_function))
>>
>> so we don't duplicate the define.
>
> ... and use include/lttng/ust-compiler.h instead.
>
>> Can't we simply specify the attribute on the function definition, rather
>> than having to duplicate its prototype ?
>
> No. I tried that before but unfortunately it didn't work. It only works  
> consistently if the attribute is on the function declaration. If you try  
> to put it on the definition it will result in compiler errors either  
> when tracepoint providers are compiled or when tracepoint provider  
> header files are used.

Please try with the change I propose below,

>
> The updated patch is in the attachment.
>
> Thanks,
> Paul
>
> -- 
> Paul Woegerer | SW Development Engineer
> Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
> P 43.1.535991320
> Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS
>
> Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
> Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
>

> From 46e709a85edbca6b9c869148cadd2abac2f98acf Mon Sep 17 00:00:00 2001
> From: Paul Woegerer <paul_woegerer@mentor.com>
> Date: Wed, 18 Jul 2012 12:27:07 +0200
> Subject: [PATCH] Make lttng-ust robust against -finstrument-functions.
> 
> ---
>  include/Makefile.am                  |    1 +
>  include/lttng/ringbuffer-config.h    |   17 +++++++++++++++++
>  include/lttng/tracepoint.h           |    8 ++++++++
>  include/lttng/ust-compiler.h         |   21 +++++++++++++++++++++
>  include/lttng/ust-tracepoint-event.h |    8 ++++++++
>  5 files changed, 55 insertions(+)
>  create mode 100644 include/lttng/ust-compiler.h
> 
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 633260b..208e74e 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -14,6 +14,7 @@ nobase_include_HEADERS = \
>  	lttng/ringbuffer-abi.h \
>  	lttng/ust-tracer.h \
>  	lttng/ust-config.h \
> +	lttng/ust-compiler.h \
>  	lttng/ust.h \
>  	lttng/ust-endian.h \
>  	lttng/ringbuffer-config.h \
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 24e7dbe..408d95a 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -27,6 +27,7 @@
>  #include <urcu/arch.h>
>  #include <string.h>
>  #include "lttng/align.h"
> +#include <lttng/ust-compiler.h>
>  
>  struct lttng_ust_lib_ring_buffer;
>  struct channel;
> @@ -232,6 +233,11 @@ static inline
>  void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			      struct channel *chan, void *priv,
>  			      size_t data_size, int largest_align,
> +			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
> +static inline
> +void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			      struct channel *chan, void *priv,
> +			      size_t data_size, int largest_align,
>  			      int cpu, struct lttng_ust_shm_handle *handle)

e.g. here:

static lttng_ust_notrace
void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                        struct channel *chan, void *priv,
                        size_t data_size, int largest_align,
                        int cpu, struct lttng_ust_shm_handle *handle)
{
        ... body of function ...
}

Thanks,

Mathieu

>  {
>  	ctx->chan = chan;
> @@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return offset_align(align_drift, size_of_type);
> @@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return 0;
> @@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   */
>  static inline
>  void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			   size_t alignment) lttng_ust_notrace;
> +static inline
> +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			   size_t alignment)
>  {
>  	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
> @@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  static inline
>  int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>  			     unsigned int switch_timer_interval,
> +			     unsigned int read_timer_interval) lttng_ust_notrace;
> +static inline
> +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
> +			     unsigned int switch_timer_interval,
>  			     unsigned int read_timer_interval)
>  {
>  	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
> index 5bab476..77595d3 100644
> --- a/include/lttng/tracepoint.h
> +++ b/include/lttng/tracepoint.h
> @@ -22,6 +22,7 @@
>  #include <string.h>	/* for memset */
>  #include <assert.h>
>  #include <lttng/ust-config.h>	/* for sdt */
> +#include <lttng/ust-compiler.h>
>  
>  #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
>  #define SDT_USE_VARIADIC
> @@ -137,6 +138,7 @@ extern "C" {
>  
>  #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
>  extern struct tracepoint __tracepoint_##_provider##___##_name;				\
> +static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
>  static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
>  {											\
>  	struct tracepoint_probe *__tp_probe;						\
> @@ -158,12 +160,16 @@ end:											\
>  	tp_rcu_read_unlock_bp();							\
>  }											\
>  static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) lttng_ust_notrace;					\
> +static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_register(name, func, data,					\
>  		__tracepoint_##_provider##___##_name.signature);			\
>  }											\
>  static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) lttng_ust_notrace;					\
> +static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_unregister(name, func, data);				\
> @@ -249,6 +255,7 @@ int __tracepoint_registered
>  struct tracepoint_dlopen tracepoint_dlopen
>  	__attribute__((weak, visibility("hidden")));
>  
> +static void __attribute__((constructor)) __tracepoints__init(void) lttng_ust_notrace;
>  static void __attribute__((constructor)) __tracepoints__init(void)
>  {
>  	if (__tracepoint_registered++)
> @@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
>  				__start___tracepoints_ptrs);
>  }
>  
> +static void __attribute__((destructor)) __tracepoints__destroy(void) lttng_ust_notrace;
>  static void __attribute__((destructor)) __tracepoints__destroy(void)
>  {
>  	int ret;
> diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
> new file mode 100644
> index 0000000..c35a23e
> --- /dev/null
> +++ b/include/lttng/ust-compiler.h
> @@ -0,0 +1,21 @@
> +#ifndef _LTTNG_UST_COMPILER_H
> +#define _LTTNG_UST_COMPILER_H
> +
> +/*
> + * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> + *                       Paul Woegerer <paul_woegerer@mentor.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + */
> +
> +#define lttng_ust_notrace __attribute__((no_instrument_function))
> +
> +#endif /* _LTTNG_UST_COMPILER_H */
> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
> index 8db1e68..8628dbe 100644
> --- a/include/lttng/ust-tracepoint-event.h
> +++ b/include/lttng/ust-tracepoint-event.h
> @@ -16,6 +16,7 @@
>  #include <urcu/compiler.h>
>  #include <lttng/ust-events.h>
>  #include <lttng/ringbuffer-config.h>
> +#include <lttng/ust-compiler.h>
>  #include <string.h>
>  
>  /*
> @@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
> +static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>  static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>  {									      \
>  	size_t __event_len = 0;						      \
> @@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>  static inline								      \
> +size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
>  size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>  {									      \
>  	size_t __event_align = 1;					      \
> @@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>   */
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
> +static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>  static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>  {									      \
>  	struct ltt_event *__event = __tp_data;				      \
> @@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>  /* Reset all macros within TRACEPOINT_EVENT */
>  #include <lttng/ust-tracepoint-event-reset.h>
>  static void __attribute__((constructor))
> +_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> +static void __attribute__((constructor))
>  _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  {
>  	int ret;
> @@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  }
>  
>  static void __attribute__((destructor))
> +_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> +static void __attribute__((destructor))
>  _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>  {
>  	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
> -- 
> 1.7.10.4
> 


-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]         ` <20120718114216.GA4061@Krystal>
@ 2012-07-18 12:51           ` Woegerer, Paul
       [not found]           ` <5006B15F.30509@mentor.com>
  1 sibling, 0 replies; 11+ messages in thread
From: Woegerer, Paul @ 2012-07-18 12:51 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev

[-- Attachment #1: Type: text/plain, Size: 10896 bytes --]

On 07/18/2012 01:42 PM, Mathieu Desnoyers wrote:

> e.g. here:
>
> static lttng_ust_notrace
> void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>                          struct channel *chan, void *priv,
>                          size_t data_size, int largest_align,
>                          int cpu, struct lttng_ust_shm_handle *handle)
> {
>          ... body of function ...
> }

For ringbuffer-config.h that will work but if you try the same in 
tracepoint.h:258 with:

static lttng_ust_notrace void __attribute__((constructor)) 
__tracepoints__init(void)

you get:

Making all in hello.cxx
make[3]: Entering directory 
`/home/pwoegere/MGC/SA/lttng-ust/tests/hello.cxx'
CXX hello.o
In file included from ust_tests_hello.h:21:0,
from hello.cpp:33:
../../include/lttng/tracepoint.h:258:60: error: can’t set 
‘no_instrument_function’ attribute after definition

or if you try it in the macro definitons at tracepoint.h:141

you get:

Making all in hello.cxx
make[3]: Entering directory 
`/home/pwoegere/MGC/SA/lttng-ust/tests/hello.cxx'
CXX hello.o
In file included from hello.cpp:33:0:
ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’ 
attribute after definition
ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’ 
attribute after definition
ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’ 
attribute after definition
ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’ 
attribute after definition
ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’ 
attribute after definition
ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’ 
attribute after definition


Anyway I send you a patch that uses the attribute on the definitions 
wherever possible.

--
Paul

>
> Thanks,
>
> Mathieu
>
>>   {
>>   	ctx->chan = chan;
>> @@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>    * size_of_type must be non-zero.
>>    */
>>   static inline
>> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
>> +static inline
>>   unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>   {
>>   	return offset_align(align_drift, size_of_type);
>> @@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>    * size_of_type must be non-zero.
>>    */
>>   static inline
>> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
>> +static inline
>>   unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>   {
>>   	return 0;
>> @@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>    */
>>   static inline
>>   void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>> +			   size_t alignment) lttng_ust_notrace;
>> +static inline
>> +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>   			   size_t alignment)
>>   {
>>   	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
>> @@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>   static inline
>>   int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>>   			     unsigned int switch_timer_interval,
>> +			     unsigned int read_timer_interval) lttng_ust_notrace;
>> +static inline
>> +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>> +			     unsigned int switch_timer_interval,
>>   			     unsigned int read_timer_interval)
>>   {
>>   	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
>> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
>> index 5bab476..77595d3 100644
>> --- a/include/lttng/tracepoint.h
>> +++ b/include/lttng/tracepoint.h
>> @@ -22,6 +22,7 @@
>>   #include <string.h>	/* for memset */
>>   #include <assert.h>
>>   #include <lttng/ust-config.h>	/* for sdt */
>> +#include <lttng/ust-compiler.h>
>>   
>>   #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
>>   #define SDT_USE_VARIADIC
>> @@ -137,6 +138,7 @@ extern "C" {
>>   
>>   #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
>>   extern struct tracepoint __tracepoint_##_provider##___##_name;				\
>> +static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
>>   static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
>>   {											\
>>   	struct tracepoint_probe *__tp_probe;						\
>> @@ -158,12 +160,16 @@ end:											\
>>   	tp_rcu_read_unlock_bp();							\
>>   }											\
>>   static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>> +		void (*func)(void), void *data) lttng_ust_notrace;					\
>> +static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>>   		void (*func)(void), void *data)							\
>>   {											\
>>   	__tracepoint_probe_register(name, func, data,					\
>>   		__tracepoint_##_provider##___##_name.signature);			\
>>   }											\
>>   static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>> +		void (*func)(void), void *data) lttng_ust_notrace;					\
>> +static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>>   		void (*func)(void), void *data)							\
>>   {											\
>>   	__tracepoint_probe_unregister(name, func, data);				\
>> @@ -249,6 +255,7 @@ int __tracepoint_registered
>>   struct tracepoint_dlopen tracepoint_dlopen
>>   	__attribute__((weak, visibility("hidden")));
>>   
>> +static void __attribute__((constructor)) __tracepoints__init(void) lttng_ust_notrace;
>>   static void __attribute__((constructor)) __tracepoints__init(void)
>>   {
>>   	if (__tracepoint_registered++)
>> @@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
>>   				__start___tracepoints_ptrs);
>>   }
>>   
>> +static void __attribute__((destructor)) __tracepoints__destroy(void) lttng_ust_notrace;
>>   static void __attribute__((destructor)) __tracepoints__destroy(void)
>>   {
>>   	int ret;
>> diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
>> new file mode 100644
>> index 0000000..c35a23e
>> --- /dev/null
>> +++ b/include/lttng/ust-compiler.h
>> @@ -0,0 +1,21 @@
>> +#ifndef _LTTNG_UST_COMPILER_H
>> +#define _LTTNG_UST_COMPILER_H
>> +
>> +/*
>> + * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>> + *                       Paul Woegerer <paul_woegerer@mentor.com>
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a copy
>> + * of this software and associated documentation files (the "Software"), to deal
>> + * in the Software without restriction, including without limitation the rights
>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>> + * copies of the Software, and to permit persons to whom the Software is
>> + * furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice shall be included in
>> + * all copies or substantial portions of the Software.
>> + */
>> +
>> +#define lttng_ust_notrace __attribute__((no_instrument_function))
>> +
>> +#endif /* _LTTNG_UST_COMPILER_H */
>> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
>> index 8db1e68..8628dbe 100644
>> --- a/include/lttng/ust-tracepoint-event.h
>> +++ b/include/lttng/ust-tracepoint-event.h
>> @@ -16,6 +16,7 @@
>>   #include <urcu/compiler.h>
>>   #include <lttng/ust-events.h>
>>   #include <lttng/ringbuffer-config.h>
>> +#include <lttng/ust-compiler.h>
>>   #include <string.h>
>>   
>>   /*
>> @@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>>   
>>   #undef TRACEPOINT_EVENT_CLASS
>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
>> +static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>>   static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>>   {									      \
>>   	size_t __event_len = 0;						      \
>> @@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
>>   #undef TRACEPOINT_EVENT_CLASS
>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>>   static inline								      \
>> +size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
>>   size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>>   {									      \
>>   	size_t __event_align = 1;					      \
>> @@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>>    */
>>   #undef TRACEPOINT_EVENT_CLASS
>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>> +static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>>   static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>>   {									      \
>>   	struct ltt_event *__event = __tp_data;				      \
>> @@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>>   /* Reset all macros within TRACEPOINT_EVENT */
>>   #include <lttng/ust-tracepoint-event-reset.h>
>>   static void __attribute__((constructor))
>> +_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
>> +static void __attribute__((constructor))
>>   _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>>   {
>>   	int ret;
>> @@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>>   }
>>   
>>   static void __attribute__((destructor))
>> +_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
>> +static void __attribute__((destructor))
>>   _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>>   {
>>   	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
>> -- 
>> 1.7.10.4
>>
>


-- 
Paul Woegerer | SW Development Engineer
Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
P 43.1.535991320
Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.


[-- Attachment #2: 0001-Make-lttng-ust-robust-against-finstrument-functions.patch --]
[-- Type: text/x-patch, Size: 9665 bytes --]

From 46e709a85edbca6b9c869148cadd2abac2f98acf Mon Sep 17 00:00:00 2001
From: Paul Woegerer <paul_woegerer@mentor.com>
Date: Wed, 18 Jul 2012 12:27:07 +0200
Subject: [PATCH 1/2] Make lttng-ust robust against -finstrument-functions.

---
 include/Makefile.am                  |    1 +
 include/lttng/ringbuffer-config.h    |   17 +++++++++++++++++
 include/lttng/tracepoint.h           |    8 ++++++++
 include/lttng/ust-compiler.h         |   21 +++++++++++++++++++++
 include/lttng/ust-tracepoint-event.h |    8 ++++++++
 5 files changed, 55 insertions(+)
 create mode 100644 include/lttng/ust-compiler.h

diff --git a/include/Makefile.am b/include/Makefile.am
index 633260b..208e74e 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -14,6 +14,7 @@ nobase_include_HEADERS = \
 	lttng/ringbuffer-abi.h \
 	lttng/ust-tracer.h \
 	lttng/ust-config.h \
+	lttng/ust-compiler.h \
 	lttng/ust.h \
 	lttng/ust-endian.h \
 	lttng/ringbuffer-config.h \
diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 24e7dbe..408d95a 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -27,6 +27,7 @@
 #include <urcu/arch.h>
 #include <string.h>
 #include "lttng/align.h"
+#include <lttng/ust-compiler.h>
 
 struct lttng_ust_lib_ring_buffer;
 struct channel;
@@ -232,6 +233,11 @@ static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			      struct channel *chan, void *priv,
 			      size_t data_size, int largest_align,
+			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
+static inline
+void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			      struct channel *chan, void *priv,
+			      size_t data_size, int largest_align,
 			      int cpu, struct lttng_ust_shm_handle *handle)
 {
 	ctx->chan = chan;
@@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return offset_align(align_drift, size_of_type);
@@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * size_of_type must be non-zero.
  */
 static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
+static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return 0;
@@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  */
 static inline
 void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
+			   size_t alignment) lttng_ust_notrace;
+static inline
+void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			   size_t alignment)
 {
 	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
@@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 static inline
 int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
 			     unsigned int switch_timer_interval,
+			     unsigned int read_timer_interval) lttng_ust_notrace;
+static inline
+int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
+			     unsigned int switch_timer_interval,
 			     unsigned int read_timer_interval)
 {
 	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 5bab476..77595d3 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -22,6 +22,7 @@
 #include <string.h>	/* for memset */
 #include <assert.h>
 #include <lttng/ust-config.h>	/* for sdt */
+#include <lttng/ust-compiler.h>
 
 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
 #define SDT_USE_VARIADIC
@@ -137,6 +138,7 @@ extern "C" {
 
 #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
 extern struct tracepoint __tracepoint_##_provider##___##_name;				\
+static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
 static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
 {											\
 	struct tracepoint_probe *__tp_probe;						\
@@ -158,12 +160,16 @@ end:											\
 	tp_rcu_read_unlock_bp();							\
 }											\
 static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) lttng_ust_notrace;					\
+static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_register(name, func, data,					\
 		__tracepoint_##_provider##___##_name.signature);			\
 }											\
 static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
+		void (*func)(void), void *data) lttng_ust_notrace;					\
+static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
 		void (*func)(void), void *data)							\
 {											\
 	__tracepoint_probe_unregister(name, func, data);				\
@@ -249,6 +255,7 @@ int __tracepoint_registered
 struct tracepoint_dlopen tracepoint_dlopen
 	__attribute__((weak, visibility("hidden")));
 
+static void __attribute__((constructor)) __tracepoints__init(void) lttng_ust_notrace;
 static void __attribute__((constructor)) __tracepoints__init(void)
 {
 	if (__tracepoint_registered++)
@@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
 				__start___tracepoints_ptrs);
 }
 
+static void __attribute__((destructor)) __tracepoints__destroy(void) lttng_ust_notrace;
 static void __attribute__((destructor)) __tracepoints__destroy(void)
 {
 	int ret;
diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
new file mode 100644
index 0000000..c35a23e
--- /dev/null
+++ b/include/lttng/ust-compiler.h
@@ -0,0 +1,21 @@
+#ifndef _LTTNG_UST_COMPILER_H
+#define _LTTNG_UST_COMPILER_H
+
+/*
+ * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *                       Paul Woegerer <paul_woegerer@mentor.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#define lttng_ust_notrace __attribute__((no_instrument_function))
+
+#endif /* _LTTNG_UST_COMPILER_H */
diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index 8db1e68..8628dbe 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -16,6 +16,7 @@
 #include <urcu/compiler.h>
 #include <lttng/ust-events.h>
 #include <lttng/ringbuffer-config.h>
+#include <lttng/ust-compiler.h>
 #include <string.h>
 
 /*
@@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
+static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
 static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
 {									      \
 	size_t __event_len = 0;						      \
@@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
 static inline								      \
+size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 {									      \
 	size_t __event_align = 1;					      \
@@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
  */
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
+static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
 static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 {									      \
 	struct ltt_event *__event = __tp_data;				      \
@@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 static void __attribute__((constructor))
+_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
+static void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
 	int ret;
@@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 }
 
 static void __attribute__((destructor))
+_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
+static void __attribute__((destructor))
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
 	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-- 
1.7.10.4


[-- Attachment #3: 0002-Use-lttng_ust_notrace-on-definitons-instead-of-decla.patch --]
[-- Type: text/x-patch, Size: 6394 bytes --]

From 94372244110b3bc5e3223310525b349c8320be7e Mon Sep 17 00:00:00 2001
From: Paul Woegerer <paul_woegerer@mentor.com>
Date: Wed, 18 Jul 2012 14:46:25 +0200
Subject: [PATCH 2/2] Use lttng_ust_notrace on definitons (instead of
 declarations) where possible.

---
 include/lttng/ringbuffer-config.h    |   26 +++++---------------------
 include/lttng/ust-tracepoint-event.h |   17 +++++------------
 2 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 408d95a..558e071 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -229,12 +229,7 @@ struct lttng_ust_lib_ring_buffer_ctx {
  * @largest_align: largest alignment within data payload types
  * @cpu: processor id
  */
-static inline
-void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
-			      struct channel *chan, void *priv,
-			      size_t data_size, int largest_align,
-			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
-static inline
+static inline lttng_ust_notrace
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			      struct channel *chan, void *priv,
 			      size_t data_size, int largest_align,
@@ -281,9 +276,7 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * Calculate the offset needed to align the type.
  * size_of_type must be non-zero.
  */
-static inline
-unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
-static inline
+static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return offset_align(align_drift, size_of_type);
@@ -297,9 +290,7 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * Calculate the offset needed to align the type.
  * size_of_type must be non-zero.
  */
-static inline
-unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
-static inline
+static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
 	return 0;
@@ -311,10 +302,7 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * lib_ring_buffer_align_ctx - Align context offset on "alignment"
  * @ctx: ring buffer context.
  */
-static inline
-void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
-			   size_t alignment) lttng_ust_notrace;
-static inline
+static inline lttng_ust_notrace
 void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 			   size_t alignment)
 {
@@ -326,11 +314,7 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
  * lib_ring_buffer_check_config() returns 0 on success.
  * Used internally to check for valid configurations at channel creation.
  */
-static inline
-int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
-			     unsigned int switch_timer_interval,
-			     unsigned int read_timer_interval) lttng_ust_notrace;
-static inline
+static inline lttng_ust_notrace
 int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
 			     unsigned int switch_timer_interval,
 			     unsigned int read_timer_interval)
diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index 8628dbe..6fbd1d8 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -245,8 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
-static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
-static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
+static inline lttng_ust_notrace size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
 {									      \
 	size_t __event_len = 0;						      \
 	unsigned int __dynamic_len_idx = 0;				      \
@@ -362,8 +361,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
-static inline								      \
-size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
+static inline lttng_ust_notrace						      \
 size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 {									      \
 	size_t __event_align = 1;					      \
@@ -441,8 +439,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
  */
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
-static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
-static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
+static lttng_ust_notrace void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 {									      \
 	struct ltt_event *__event = __tp_data;				      \
 	struct ltt_channel *__chan = __event->chan;			      \
@@ -597,9 +594,7 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
 
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
-static void __attribute__((constructor))
-_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
-static void __attribute__((constructor))
+static lttng_ust_notrace void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
 	int ret;
@@ -608,9 +603,7 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 	assert(!ret);
 }
 
-static void __attribute__((destructor))
-_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
-static void __attribute__((destructor))
+static lttng_ust_notrace void __attribute__((destructor))
 _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
 	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
-- 
1.7.10.4


[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]           ` <5006B15F.30509@mentor.com>
@ 2012-07-18 19:32             ` Mathieu Desnoyers
  0 siblings, 0 replies; 11+ messages in thread
From: Mathieu Desnoyers @ 2012-07-18 19:32 UTC (permalink / raw)
  To: Woegerer, Paul; +Cc: lttng-dev

I ended up pushing your work as:

commit a8909ba54718ed54cefb1b839a5d41a065df09f9
Author: Paul Woegerer <paul_woegerer@mentor.com>
Date:   Wed Jul 18 15:28:44 2012 -0400

    Make lttng-ust robust against -finstrument-functions.
    
    [ Edit by Mathieu Desnoyers:
    
    We need to declare the no_instrument_function attribute on function
    declarations (rather than definition) for g++. Moved the attribute prior
    to the function declaration (rather than after) to follow the coding
    style within LTTng-UST. ]
    
    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Indeed, g++ is weird.

Thanks!

Mathieu

* Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
> On 07/18/2012 01:42 PM, Mathieu Desnoyers wrote:
>
>> e.g. here:
>>
>> static lttng_ust_notrace
>> void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>                          struct channel *chan, void *priv,
>>                          size_t data_size, int largest_align,
>>                          int cpu, struct lttng_ust_shm_handle *handle)
>> {
>>          ... body of function ...
>> }
>
> For ringbuffer-config.h that will work but if you try the same in  
> tracepoint.h:258 with:
>
> static lttng_ust_notrace void __attribute__((constructor))  
> __tracepoints__init(void)
>
> you get:
>
> Making all in hello.cxx
> make[3]: Entering directory  
> `/home/pwoegere/MGC/SA/lttng-ust/tests/hello.cxx'
> CXX hello.o
> In file included from ust_tests_hello.h:21:0,
> from hello.cpp:33:
> ../../include/lttng/tracepoint.h:258:60: error: can’t set  
> ‘no_instrument_function’ attribute after definition
>
> or if you try it in the macro definitons at tracepoint.h:141
>
> you get:
>
> Making all in hello.cxx
> make[3]: Entering directory  
> `/home/pwoegere/MGC/SA/lttng-ust/tests/hello.cxx'
> CXX hello.o
> In file included from hello.cpp:33:0:
> ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
> ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
> ust_tests_hello.h:43:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
> ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
> ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
> ust_tests_hello.h:48:1: error: can’t set ‘no_instrument_function’  
> attribute after definition
>
>
> Anyway I send you a patch that uses the attribute on the definitions  
> wherever possible.
>
> --
> Paul
>
>>
>> Thanks,
>>
>> Mathieu
>>
>>>   {
>>>   	ctx->chan = chan;
>>> @@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>>    * size_of_type must be non-zero.
>>>    */
>>>   static inline
>>> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
>>> +static inline
>>>   unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>>   {
>>>   	return offset_align(align_drift, size_of_type);
>>> @@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>>    * size_of_type must be non-zero.
>>>    */
>>>   static inline
>>> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
>>> +static inline
>>>   unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>>   {
>>>   	return 0;
>>> @@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>>>    */
>>>   static inline
>>>   void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>> +			   size_t alignment) lttng_ust_notrace;
>>> +static inline
>>> +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>>   			   size_t alignment)
>>>   {
>>>   	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
>>> @@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>>>   static inline
>>>   int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>>>   			     unsigned int switch_timer_interval,
>>> +			     unsigned int read_timer_interval) lttng_ust_notrace;
>>> +static inline
>>> +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>>> +			     unsigned int switch_timer_interval,
>>>   			     unsigned int read_timer_interval)
>>>   {
>>>   	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
>>> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
>>> index 5bab476..77595d3 100644
>>> --- a/include/lttng/tracepoint.h
>>> +++ b/include/lttng/tracepoint.h
>>> @@ -22,6 +22,7 @@
>>>   #include <string.h>	/* for memset */
>>>   #include <assert.h>
>>>   #include <lttng/ust-config.h>	/* for sdt */
>>> +#include <lttng/ust-compiler.h>
>>>     #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
>>>   #define SDT_USE_VARIADIC
>>> @@ -137,6 +138,7 @@ extern "C" {
>>>     #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
>>>   extern struct tracepoint __tracepoint_##_provider##___##_name;				\
>>> +static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
>>>   static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
>>>   {											\
>>>   	struct tracepoint_probe *__tp_probe;						\
>>> @@ -158,12 +160,16 @@ end:											\
>>>   	tp_rcu_read_unlock_bp();							\
>>>   }											\
>>>   static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>>> +		void (*func)(void), void *data) lttng_ust_notrace;					\
>>> +static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>>>   		void (*func)(void), void *data)							\
>>>   {											\
>>>   	__tracepoint_probe_register(name, func, data,					\
>>>   		__tracepoint_##_provider##___##_name.signature);			\
>>>   }											\
>>>   static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>>> +		void (*func)(void), void *data) lttng_ust_notrace;					\
>>> +static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>>>   		void (*func)(void), void *data)							\
>>>   {											\
>>>   	__tracepoint_probe_unregister(name, func, data);				\
>>> @@ -249,6 +255,7 @@ int __tracepoint_registered
>>>   struct tracepoint_dlopen tracepoint_dlopen
>>>   	__attribute__((weak, visibility("hidden")));
>>>   +static void __attribute__((constructor)) __tracepoints__init(void) 
>>> lttng_ust_notrace;
>>>   static void __attribute__((constructor)) __tracepoints__init(void)
>>>   {
>>>   	if (__tracepoint_registered++)
>>> @@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
>>>   				__start___tracepoints_ptrs);
>>>   }
>>>   +static void __attribute__((destructor)) 
>>> __tracepoints__destroy(void) lttng_ust_notrace;
>>>   static void __attribute__((destructor)) __tracepoints__destroy(void)
>>>   {
>>>   	int ret;
>>> diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
>>> new file mode 100644
>>> index 0000000..c35a23e
>>> --- /dev/null
>>> +++ b/include/lttng/ust-compiler.h
>>> @@ -0,0 +1,21 @@
>>> +#ifndef _LTTNG_UST_COMPILER_H
>>> +#define _LTTNG_UST_COMPILER_H
>>> +
>>> +/*
>>> + * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>> + *                       Paul Woegerer <paul_woegerer@mentor.com>
>>> + *
>>> + * Permission is hereby granted, free of charge, to any person obtaining a copy
>>> + * of this software and associated documentation files (the "Software"), to deal
>>> + * in the Software without restriction, including without limitation the rights
>>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>>> + * copies of the Software, and to permit persons to whom the Software is
>>> + * furnished to do so, subject to the following conditions:
>>> + *
>>> + * The above copyright notice and this permission notice shall be included in
>>> + * all copies or substantial portions of the Software.
>>> + */
>>> +
>>> +#define lttng_ust_notrace __attribute__((no_instrument_function))
>>> +
>>> +#endif /* _LTTNG_UST_COMPILER_H */
>>> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
>>> index 8db1e68..8628dbe 100644
>>> --- a/include/lttng/ust-tracepoint-event.h
>>> +++ b/include/lttng/ust-tracepoint-event.h
>>> @@ -16,6 +16,7 @@
>>>   #include <urcu/compiler.h>
>>>   #include <lttng/ust-events.h>
>>>   #include <lttng/ringbuffer-config.h>
>>> +#include <lttng/ust-compiler.h>
>>>   #include <string.h>
>>>     /*
>>> @@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>>>     #undef TRACEPOINT_EVENT_CLASS
>>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
>>> +static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>>>   static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>>>   {									      \
>>>   	size_t __event_len = 0;						      \
>>> @@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
>>>   #undef TRACEPOINT_EVENT_CLASS
>>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>>>   static inline								      \
>>> +size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
>>>   size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>>>   {									      \
>>>   	size_t __event_align = 1;					      \
>>> @@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>>>    */
>>>   #undef TRACEPOINT_EVENT_CLASS
>>>   #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>>> +static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>>>   static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>>>   {									      \
>>>   	struct ltt_event *__event = __tp_data;				      \
>>> @@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>>>   /* Reset all macros within TRACEPOINT_EVENT */
>>>   #include <lttng/ust-tracepoint-event-reset.h>
>>>   static void __attribute__((constructor))
>>> +_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
>>> +static void __attribute__((constructor))
>>>   _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>>>   {
>>>   	int ret;
>>> @@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>>>   }
>>>     static void __attribute__((destructor))
>>> +_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
>>> +static void __attribute__((destructor))
>>>   _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>>>   {
>>>   	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
>>> -- 
>>> 1.7.10.4
>>>
>>
>
>
> -- 
> Paul Woegerer | SW Development Engineer
> Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
> P 43.1.535991320
> Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS
>
> Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
> Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
>

> From 46e709a85edbca6b9c869148cadd2abac2f98acf Mon Sep 17 00:00:00 2001
> From: Paul Woegerer <paul_woegerer@mentor.com>
> Date: Wed, 18 Jul 2012 12:27:07 +0200
> Subject: [PATCH 1/2] Make lttng-ust robust against -finstrument-functions.
> 
> ---
>  include/Makefile.am                  |    1 +
>  include/lttng/ringbuffer-config.h    |   17 +++++++++++++++++
>  include/lttng/tracepoint.h           |    8 ++++++++
>  include/lttng/ust-compiler.h         |   21 +++++++++++++++++++++
>  include/lttng/ust-tracepoint-event.h |    8 ++++++++
>  5 files changed, 55 insertions(+)
>  create mode 100644 include/lttng/ust-compiler.h
> 
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 633260b..208e74e 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -14,6 +14,7 @@ nobase_include_HEADERS = \
>  	lttng/ringbuffer-abi.h \
>  	lttng/ust-tracer.h \
>  	lttng/ust-config.h \
> +	lttng/ust-compiler.h \
>  	lttng/ust.h \
>  	lttng/ust-endian.h \
>  	lttng/ringbuffer-config.h \
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 24e7dbe..408d95a 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -27,6 +27,7 @@
>  #include <urcu/arch.h>
>  #include <string.h>
>  #include "lttng/align.h"
> +#include <lttng/ust-compiler.h>
>  
>  struct lttng_ust_lib_ring_buffer;
>  struct channel;
> @@ -232,6 +233,11 @@ static inline
>  void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			      struct channel *chan, void *priv,
>  			      size_t data_size, int largest_align,
> +			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
> +static inline
> +void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			      struct channel *chan, void *priv,
> +			      size_t data_size, int largest_align,
>  			      int cpu, struct lttng_ust_shm_handle *handle)
>  {
>  	ctx->chan = chan;
> @@ -276,6 +282,8 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return offset_align(align_drift, size_of_type);
> @@ -290,6 +298,8 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   * size_of_type must be non-zero.
>   */
>  static inline
> +unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> +static inline
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return 0;
> @@ -303,6 +313,9 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   */
>  static inline
>  void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> +			   size_t alignment) lttng_ust_notrace;
> +static inline
> +void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			   size_t alignment)
>  {
>  	ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
> @@ -316,6 +329,10 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  static inline
>  int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>  			     unsigned int switch_timer_interval,
> +			     unsigned int read_timer_interval) lttng_ust_notrace;
> +static inline
> +int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
> +			     unsigned int switch_timer_interval,
>  			     unsigned int read_timer_interval)
>  {
>  	if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
> diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
> index 5bab476..77595d3 100644
> --- a/include/lttng/tracepoint.h
> +++ b/include/lttng/tracepoint.h
> @@ -22,6 +22,7 @@
>  #include <string.h>	/* for memset */
>  #include <assert.h>
>  #include <lttng/ust-config.h>	/* for sdt */
> +#include <lttng/ust-compiler.h>
>  
>  #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION
>  #define SDT_USE_VARIADIC
> @@ -137,6 +138,7 @@ extern "C" {
>  
>  #define _DECLARE_TRACEPOINT(_provider, _name, ...)			 		\
>  extern struct tracepoint __tracepoint_##_provider##___##_name;				\
> +static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) lttng_ust_notrace;	\
>  static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__))	\
>  {											\
>  	struct tracepoint_probe *__tp_probe;						\
> @@ -158,12 +160,16 @@ end:											\
>  	tp_rcu_read_unlock_bp();							\
>  }											\
>  static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) lttng_ust_notrace;					\
> +static inline void __tracepoint_register_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_register(name, func, data,					\
>  		__tracepoint_##_provider##___##_name.signature);			\
>  }											\
>  static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
> +		void (*func)(void), void *data) lttng_ust_notrace;					\
> +static inline void __tracepoint_unregister_##_provider##___##_name(char *name,		\
>  		void (*func)(void), void *data)							\
>  {											\
>  	__tracepoint_probe_unregister(name, func, data);				\
> @@ -249,6 +255,7 @@ int __tracepoint_registered
>  struct tracepoint_dlopen tracepoint_dlopen
>  	__attribute__((weak, visibility("hidden")));
>  
> +static void __attribute__((constructor)) __tracepoints__init(void) lttng_ust_notrace;
>  static void __attribute__((constructor)) __tracepoints__init(void)
>  {
>  	if (__tracepoint_registered++)
> @@ -285,6 +292,7 @@ static void __attribute__((constructor)) __tracepoints__init(void)
>  				__start___tracepoints_ptrs);
>  }
>  
> +static void __attribute__((destructor)) __tracepoints__destroy(void) lttng_ust_notrace;
>  static void __attribute__((destructor)) __tracepoints__destroy(void)
>  {
>  	int ret;
> diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h
> new file mode 100644
> index 0000000..c35a23e
> --- /dev/null
> +++ b/include/lttng/ust-compiler.h
> @@ -0,0 +1,21 @@
> +#ifndef _LTTNG_UST_COMPILER_H
> +#define _LTTNG_UST_COMPILER_H
> +
> +/*
> + * Copyright 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> + *                       Paul Woegerer <paul_woegerer@mentor.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + */
> +
> +#define lttng_ust_notrace __attribute__((no_instrument_function))
> +
> +#endif /* _LTTNG_UST_COMPILER_H */
> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
> index 8db1e68..8628dbe 100644
> --- a/include/lttng/ust-tracepoint-event.h
> +++ b/include/lttng/ust-tracepoint-event.h
> @@ -16,6 +16,7 @@
>  #include <urcu/compiler.h>
>  #include <lttng/ust-events.h>
>  #include <lttng/ringbuffer-config.h>
> +#include <lttng/ust-compiler.h>
>  #include <string.h>
>  
>  /*
> @@ -244,6 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
> +static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>  static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>  {									      \
>  	size_t __event_len = 0;						      \
> @@ -361,6 +363,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
>  static inline								      \
> +size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
>  size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>  {									      \
>  	size_t __event_align = 1;					      \
> @@ -438,6 +441,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>   */
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
> +static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
>  static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>  {									      \
>  	struct ltt_event *__event = __tp_data;				      \
> @@ -594,6 +598,8 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>  /* Reset all macros within TRACEPOINT_EVENT */
>  #include <lttng/ust-tracepoint-event-reset.h>
>  static void __attribute__((constructor))
> +_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> +static void __attribute__((constructor))
>  _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  {
>  	int ret;
> @@ -603,6 +609,8 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  }
>  
>  static void __attribute__((destructor))
> +_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> +static void __attribute__((destructor))
>  _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>  {
>  	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
> -- 
> 1.7.10.4
> 

> From 94372244110b3bc5e3223310525b349c8320be7e Mon Sep 17 00:00:00 2001
> From: Paul Woegerer <paul_woegerer@mentor.com>
> Date: Wed, 18 Jul 2012 14:46:25 +0200
> Subject: [PATCH 2/2] Use lttng_ust_notrace on definitons (instead of
>  declarations) where possible.
> 
> ---
>  include/lttng/ringbuffer-config.h    |   26 +++++---------------------
>  include/lttng/ust-tracepoint-event.h |   17 +++++------------
>  2 files changed, 10 insertions(+), 33 deletions(-)
> 
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 408d95a..558e071 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -229,12 +229,7 @@ struct lttng_ust_lib_ring_buffer_ctx {
>   * @largest_align: largest alignment within data payload types
>   * @cpu: processor id
>   */
> -static inline
> -void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> -			      struct channel *chan, void *priv,
> -			      size_t data_size, int largest_align,
> -			      int cpu, struct lttng_ust_shm_handle *handle) lttng_ust_notrace;
> -static inline
> +static inline lttng_ust_notrace
>  void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			      struct channel *chan, void *priv,
>  			      size_t data_size, int largest_align,
> @@ -281,9 +276,7 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>   * Calculate the offset needed to align the type.
>   * size_of_type must be non-zero.
>   */
> -static inline
> -unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> -static inline
> +static inline lttng_ust_notrace
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return offset_align(align_drift, size_of_type);
> @@ -297,9 +290,7 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   * Calculate the offset needed to align the type.
>   * size_of_type must be non-zero.
>   */
> -static inline
> -unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type) lttng_ust_notrace;
> -static inline
> +static inline lttng_ust_notrace
>  unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>  {
>  	return 0;
> @@ -311,10 +302,7 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
>   * lib_ring_buffer_align_ctx - Align context offset on "alignment"
>   * @ctx: ring buffer context.
>   */
> -static inline
> -void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
> -			   size_t alignment) lttng_ust_notrace;
> -static inline
> +static inline lttng_ust_notrace
>  void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>  			   size_t alignment)
>  {
> @@ -326,11 +314,7 @@ void lib_ring_buffer_align_ctx(struct lttng_ust_lib_ring_buffer_ctx *ctx,
>   * lib_ring_buffer_check_config() returns 0 on success.
>   * Used internally to check for valid configurations at channel creation.
>   */
> -static inline
> -int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
> -			     unsigned int switch_timer_interval,
> -			     unsigned int read_timer_interval) lttng_ust_notrace;
> -static inline
> +static inline lttng_ust_notrace
>  int lib_ring_buffer_check_config(const struct lttng_ust_lib_ring_buffer_config *config,
>  			     unsigned int switch_timer_interval,
>  			     unsigned int read_timer_interval)
> diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
> index 8628dbe..6fbd1d8 100644
> --- a/include/lttng/ust-tracepoint-event.h
> +++ b/include/lttng/ust-tracepoint-event.h
> @@ -245,8 +245,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
> -static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
> -static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
> +static inline lttng_ust_notrace size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
>  {									      \
>  	size_t __event_len = 0;						      \
>  	unsigned int __dynamic_len_idx = 0;				      \
> @@ -362,8 +361,7 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
>  
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
> -static inline								      \
> -size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) lttng_ust_notrace; \
> +static inline lttng_ust_notrace						      \
>  size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>  {									      \
>  	size_t __event_align = 1;					      \
> @@ -441,8 +439,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
>   */
>  #undef TRACEPOINT_EVENT_CLASS
>  #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)	      \
> -static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) lttng_ust_notrace; \
> -static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
> +static lttng_ust_notrace void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
>  {									      \
>  	struct ltt_event *__event = __tp_data;				      \
>  	struct ltt_channel *__chan = __event->chan;			      \
> @@ -597,9 +594,7 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
>  
>  /* Reset all macros within TRACEPOINT_EVENT */
>  #include <lttng/ust-tracepoint-event-reset.h>
> -static void __attribute__((constructor))
> -_TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> -static void __attribute__((constructor))
> +static lttng_ust_notrace void __attribute__((constructor))
>  _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  {
>  	int ret;
> @@ -608,9 +603,7 @@ _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
>  	assert(!ret);
>  }
>  
> -static void __attribute__((destructor))
> -_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void) lttng_ust_notrace;
> -static void __attribute__((destructor))
> +static lttng_ust_notrace void __attribute__((destructor))
>  _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
>  {
>  	ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
> -- 
> 1.7.10.4
> 


-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]     ` <20120717141301.GA21204@Krystal>
  2012-07-18 10:33       ` Woegerer, Paul
       [not found]       ` <500690E4.4020503@mentor.com>
@ 2012-10-01  4:06       ` Francis Giraldeau
       [not found]       ` <506916A9.2050308@gmail.com>
  3 siblings, 0 replies; 11+ messages in thread
From: Francis Giraldeau @ 2012-10-01  4:06 UTC (permalink / raw)
  To: lttng-dev; +Cc: Mathieu Desnoyers


[-- Attachment #1.1: Type: text/plain, Size: 1998 bytes --]

Le 2012-07-17 10:13, Mathieu Desnoyers a écrit :
> * Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
>> Hi Mathieu,
>>
>> here is the revised patch that makes tracepoint.h and  
>> ust-tracepoint-event.h robust against -finstrument-functions.
> 
> I think we want to make the notrace always active. I don't see the point
> in letting UST lib be compiled with those tracing stubs in place.

I just hit a case where it would have been useful to profile lttng-ust
itself.

When generating events in a tight loop, the average time to execute a
simple tracepoint is about 280ns on my machine. But the problem is that
once in a while (once out of a million execution) the latency bump to a
blazing 100us. I agree, it's still fast, but nonetheless the maximum is
~350 times more than the average, which is strange.

I tried many profiling tools (perf, valgrind, etc.) and none was
providing good results. It's no point to use lttng-ust itself (are
tracepoints reentrants?). So, I decided to try -finstrument-functions
stuff with a small pre-allocated ringbuffer to get the lowest latency
possible. Well, it turns out that I was getting no results for the
tracepoint, because function instrumentation is disabled.

I tried to re-enable it, but then the instrumented app fails with this
error message:

/usr/local/include/lttng/ust-tracepoint-event.h:646:
__lttng_events_init__npt: Assertion `!ret' failed.

I confess that I didn't look deeply into this problem, but it's quite
strange that the init fails in the case function instrumentation is
enabled. Could it be related to the dlopen() done at registration? Maybe
somebody has an idea, because I saw screenshots of similar profiling
previously on the ML ;) Here is the configuration options to lttng-ust
(the profiling library is miniprof[1]):

./configure CFLAGS="-finstrument-functions" LIBS="-lminiprof"
LDFLAGS="-L/usr/local/lib -Wl,-E"

Cheers,

Francis

[1] https://github.com/giraldeau/miniprof


[-- Attachment #1.2: Signature cryptographique S/MIME --]
[-- Type: application/pkcs7-signature, Size: 4489 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: notrace missing in lttng-ust
       [not found]       ` <506916A9.2050308@gmail.com>
@ 2012-10-01 15:29         ` Mathieu Desnoyers
  0 siblings, 0 replies; 11+ messages in thread
From: Mathieu Desnoyers @ 2012-10-01 15:29 UTC (permalink / raw)
  To: Francis Giraldeau; +Cc: lttng-dev

* Francis Giraldeau (francis.giraldeau@gmail.com) wrote:
> Le 2012-07-17 10:13, Mathieu Desnoyers a écrit :
> > * Woegerer, Paul (Paul_Woegerer@mentor.com) wrote:
> >> Hi Mathieu,
> >>
> >> here is the revised patch that makes tracepoint.h and  
> >> ust-tracepoint-event.h robust against -finstrument-functions.
> > 
> > I think we want to make the notrace always active. I don't see the point
> > in letting UST lib be compiled with those tracing stubs in place.
> 
> I just hit a case where it would have been useful to profile lttng-ust
> itself.
> 
> When generating events in a tight loop, the average time to execute a
> simple tracepoint is about 280ns on my machine. But the problem is that
> once in a while (once out of a million execution) the latency bump to a
> blazing 100us. I agree, it's still fast, but nonetheless the maximum is
> ~350 times more than the average, which is strange.

interesting indeed. I would expect this time might be spent in the
"write" to the fifo to wakeup the consumerd, but even then it is
surprising, as this is supposed to be a non-blocking fifo.

> I tried many profiling tools (perf, valgrind, etc.) and none was
> providing good results. It's no point to use lttng-ust itself (are
> tracepoints reentrants?).

that might not work indeed. Something about infinite recursion.

You might want to try kernel tracing, and see if this time is spent
anywhere in the kernel when doing UST tracing.

> So, I decided to try -finstrument-functions
> stuff with a small pre-allocated ringbuffer to get the lowest latency
> possible. Well, it turns out that I was getting no results for the
> tracepoint, because function instrumentation is disabled.

no, don't. you'll run into infinite recursion too.

> 
> I tried to re-enable it, but then the instrumented app fails with this
> error message:
> 
> /usr/local/include/lttng/ust-tracepoint-event.h:646:
> __lttng_events_init__npt: Assertion `!ret' failed.

Doing something like that might require that you LD_PRELOAD
liblttng-ust-tracepoint.so, so that its constructor runs before the
constructor registering the .so that contains the function callback.

Thanks,

Mathieu

> 
> I confess that I didn't look deeply into this problem, but it's quite
> strange that the init fails in the case function instrumentation is
> enabled. Could it be related to the dlopen() done at registration? Maybe
> somebody has an idea, because I saw screenshots of similar profiling
> previously on the ML ;) Here is the configuration options to lttng-ust
> (the profiling library is miniprof[1]):
> 
> ./configure CFLAGS="-finstrument-functions" LIBS="-lminiprof"
> LDFLAGS="-L/usr/local/lib -Wl,-E"
> 
> Cheers,
> 
> Francis
> 
> [1] https://github.com/giraldeau/miniprof
> 



-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* notrace missing in lttng-ust
@ 2012-06-29  8:28 Woegerer, Paul
  0 siblings, 0 replies; 11+ messages in thread
From: Woegerer, Paul @ 2012-06-29  8:28 UTC (permalink / raw)
  To: lttng-dev

Hi Mathieu,

libust 0.x uses notrace (__attribute__((no_instrument_function)) for all 
functions that are involved in event emitting.

For example:
./libust/marker.c:122:notrace void __ust_marker_empty_function(const 
struct ust_marker *mdata,
./libust/marker.c:137:notrace void ust_marker_probe_cb(const struct 
ust_marker *mdata,
./libust/marker.c:197:static notrace void 
ust_marker_probe_cb_noarg(const struct ust_marker *mdata,

I just realized that this is no more the case for lttng-ust.
Was it a conscious decision not to use notrace for LTTng 2.0 lttng-ust, 
or is it just missing ?

I would like to have notrace also in lttng-ust, at least for the 
_DECLARE_TRACEPOINT macro in tracepoint.h.
Like this for example:

diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 5bab476..71665dc 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -137,6 +137,7 @@ extern "C" {

  #define _DECLARE_TRACEPOINT(_provider, _name, ...)     \
  extern struct tracepoint __tracepoint_##_provider##___##_name;         
     \
+static inline void 
__tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) 
__attribute__ ((no_instrument_function));    \
  static inline void 
__tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
  {                                            \
      struct tracepoint_probe *__tp_probe;                        \
@@ -158,12 +159,16 @@ end:     \
      tp_rcu_read_unlock_bp();                            \
  }                                            \
  static inline void __tracepoint_register_##_provider##___##_name(char 
*name,        \
+        void (*func)(void), void *data) __attribute__ 
((no_instrument_function));    \
+static inline void __tracepoint_register_##_provider##___##_name(char 
*name,        \
          void (*func)(void), void *data) \
  {                                            \
      __tracepoint_probe_register(name, func, data,     \
          __tracepoint_##_provider##___##_name.signature); \
  }                                            \
  static inline void 
__tracepoint_unregister_##_provider##___##_name(char *name,        \
+        void (*func)(void), void *data) __attribute__ 
((no_instrument_function));    \
+static inline void __tracepoint_unregister_##_provider##___##_name(char 
*name,        \
          void (*func)(void), void *data) \
  {                                            \
      __tracepoint_probe_unregister(name, func, data); \

Greetings,
Paul

-- 
Paul Woegerer | SW Development Engineer
Mentor Embedded(tm) | Prinz Eugen Straße 72/2/4, Vienna, 1040 Austria
P 43.1.535991320
Nucleus® | Linux® | Android(tm) | Services | UI | Multi-OS

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-10-01 15:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4FED6718.1000205@mentor.com>
2012-06-30 18:16 ` notrace missing in lttng-ust Mathieu Desnoyers
     [not found] ` <20120630181600.GB30747@Krystal>
2012-07-03  7:45   ` Woegerer, Paul
     [not found]   ` <4FF2A31D.9020100@mentor.com>
2012-07-17 13:42     ` Woegerer, Paul
2012-07-17 14:13     ` Mathieu Desnoyers
     [not found]     ` <20120717141301.GA21204@Krystal>
2012-07-18 10:33       ` Woegerer, Paul
     [not found]       ` <500690E4.4020503@mentor.com>
2012-07-18 11:42         ` Mathieu Desnoyers
     [not found]         ` <20120718114216.GA4061@Krystal>
2012-07-18 12:51           ` Woegerer, Paul
     [not found]           ` <5006B15F.30509@mentor.com>
2012-07-18 19:32             ` Mathieu Desnoyers
2012-10-01  4:06       ` Francis Giraldeau
     [not found]       ` <506916A9.2050308@gmail.com>
2012-10-01 15:29         ` Mathieu Desnoyers
2012-06-29  8:28 Woegerer, Paul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.