Skip to contentSkip to conversation

TRACE_EVENT_ABI ?

PATCH In review Arjan van de Ven 3 participants 10 messages Sep 21, 2009 – Sep 23, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
maintainer
#1 lore raw
Quoted 6 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

Quoted 6 lines

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

I don't know what you've done so far, but can't you simply in tracepoint.h define:

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

And every time TRACE_EVENT_API is used, it will simply do whatever TRACE_EVENT is at that time?

I've done similar tricks with other code.

-- Steve

maintainer
#2 lore raw
In reply to Arjan van de Ven

[ Resending due to wrong SMTP server ]

Quoted 6 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

Quoted 7 lines

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

I don't know what you've done so far, but can't you simply in tracepoint.h define:

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

And every time TRACE_EVENT_API is used, it will simply do whatever TRACE_EVENT is at that time?

I've done similar tricks with other code.

-- Steve

#3 lore raw
Quoted 16 lines · On Mon, 21 Sep 2009 09:26:41 -0400 (EDT) Steven Rostedt <[email protected]>…

[ Resending due to wrong SMTP server ]

Quoted 10 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Quoted 8 lines
Quoted 3 lines

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

I don't know what you've done so far, but can't you simply in tracepoint.h define:

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

unfortunately, due to the preprocessor trickery around TRACE_EVENT this completely barfs.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
maintainer
#4 lore raw
Quoted 23 lines · Arjan van de Ven
Quoted 20 lines · On Mon, 21 Sep 2009 09:26:41 -0400 (EDT) Steven Rostedt <[email protected]>…

[ Resending due to wrong SMTP server ]

Quoted 13 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

Quoted 7 lines
Quoted 4 lines

I don't know what you've done so far, but can't you simply in tracepoint.h define:

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

unfortunately, due to the preprocessor trickery around TRACE_EVENT this completely barfs.

I forgot to tell you about PARAMS.

This patch compiled for me;

include/linux/tracepoint.h +4 -0
index 63a3f7a..9a983d6 100644
@@ -280,6 +280,10 @@ static inline void tracepoint_synchronize_unregister(void)
  * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
+#define TRACE_EVENT_API(name, proto, args, tstruct, assign, print)	\
+	TRACE_EVENT(name, PARAMS(proto), PARAMS(args),			\
+		    PARAMS(tstruct), PARAMS(assign), PARAMS(print))
+
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #define TRACE_EVENT_FN(name, proto, args, struct,		\
include/trace/events/sched.h +1 -1
index b48f1ad..0ee1eb6 100644
@@ -149,7 +149,7 @@ TRACE_EVENT(sched_wakeup_new,
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
-TRACE_EVENT(sched_switch,
+TRACE_EVENT_API(sched_switch,
 
 	TP_PROTO(struct rq *rq, struct task_struct *prev,
 		 struct task_struct *next),
#5 lore raw
Quoted 27 lines · Steven Rostedt
Quoted 26 lines · Arjan van de Ven
Quoted 23 lines · On Mon, 21 Sep 2009 09:26:41 -0400 (EDT) Steven Rostedt <[email protected]>…

[ Resending due to wrong SMTP server ]

Quoted 6 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

Quoted 7 lines

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

I don't know what you've done so far, but can't you simply in tracepoint.h define:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

unfortunately, due to the preprocessor trickery around TRACE_EVENT this completely barfs.

I forgot to tell you about PARAMS.

This patch compiled for me;

Oh! PARAMS!

I've needed something to "contain" cpp args by the past so that they are not substituted too early, which is needed while relaying cpp args from a macro to another. I needed this to fix TRACE_EVENT_FN: it barfed for the exact same reason.

So I've created __cpparg(), which I'm just discovering, does the exact same thing than PARAM... :-/

I'm going to s/__cpparg/PARAM for the consistency.

Quoted 30 lines
include/linux/tracepoint.h +4 -0
index 63a3f7a..9a983d6 100644
@@ -280,6 +280,10 @@ static inline void tracepoint_synchronize_unregister(void)
  * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
+#define TRACE_EVENT_API(name, proto, args, tstruct, assign, print)	\
+	TRACE_EVENT(name, PARAMS(proto), PARAMS(args),			\
+		    PARAMS(tstruct), PARAMS(assign), PARAMS(print))
+
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #define TRACE_EVENT_FN(name, proto, args, struct,		\
include/trace/events/sched.h +1 -1
index b48f1ad..0ee1eb6 100644
@@ -149,7 +149,7 @@ TRACE_EVENT(sched_wakeup_new,
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
-TRACE_EVENT(sched_switch,
+TRACE_EVENT_API(sched_switch,
 
 	TP_PROTO(struct rq *rq, struct task_struct *prev,
 		 struct task_struct *next),
#6 lore raw
In reply to Steven Rostedt
Quoted 28 lines · On Mon, 21 Sep 2009 12:46:07 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 27 lines · Arjan van de Ven
Quoted 24 lines · On Mon, 21 Sep 2009 09:26:41 -0400 (EDT) Steven Rostedt <[email protected]>…

[ Resending due to wrong SMTP server ]

Quoted 6 lines · Arjan van de Ven

Hi,

Ingo suggested to make a TRACE_EVENT_ABI, which is equivalent in implementation to TRACE_EVENT, except that it signals a stable interface.

Quoted 8 lines

In trying to implement this I'm running into a wall where TRACE_EVENT keeps being defined in many different ways all over the place, making this a really nasty hack to make it just an alias.

Do you have any clever ideas on how to make this an alias without fouling up the whole tracing system?

I don't know what you've done so far, but can't you simply in tracepoint.h define:

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

#define TRACE_EVENT_API(a,b,c,d,e) TRACE_EVENT(a,b,c,d,e)

unfortunately, due to the preprocessor trickery around TRACE_EVENT this completely barfs.

I forgot to tell you about PARAMS.

This patch compiled for me;

your magic skills exceed mine ;-)

mind sending me a signoff for this ?

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
maintainer
#7 lore raw
Quoted 11 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 21 Sep 2009 12:46:07 -0400 Steven Rostedt <[email protected]> wrote:

On Mon, 2009-09-21 at 15:28 +0200, Arjan van de Ven wrote:

This patch compiled for me;

your magic skills exceed mine ;-)

mind sending me a signoff for this ?

Sure,

#8 lore raw

PATCH 1/1 introduce TRACE_EVENT_ABI (was Re: TRACE_EVENT_ABI ?)

Quoted 11 lines · On Mon, 21 Sep 2009 17:20:31 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 10 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 21 Sep 2009 12:46:07 -0400 Steven Rostedt <[email protected]> wrote:

On Mon, 2009-09-21 at 15:28 +0200, Arjan van de Ven wrote:

This patch compiled for me;

your magic skills exceed mine ;-)

Quoted 8 lines
Quoted 1 line

mind sending me a signoff for this ?

Sure,

From e2c647ae2d3ddc25b804f0419956caf40d89c606 Mon Sep 17 00:00:00 2001

From: Steven Rostedt <[email protected]>
Date: Mon, 21 Sep 2009 20:14:53 +0200
Subject: [PATCH] trace: introduce TRACE_EVENT_ABI

Some trace events are suitable to form a stable userspace ABI; this patch introduces infrastructure to mark them as such, and marks the first few tracepoints this way

---
 include/linux/tracepoint.h   |    4 ++++
 include/trace/events/power.h |    6 +++---
 include/trace/events/sched.h |    4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)
include/linux/tracepoint.h +4 -0
index 63a3f7a..4cb454f 100644
@@ -280,6 +280,10 @@ static inline void tracepoint_synchronize_unregister(void)
  * TRACE_EVENT_FN to perform any (un)registration work.
  */
 
+#define TRACE_EVENT_ABI(name, proto, args, tstruct, assign, print)	\
+	TRACE_EVENT(name, PARAMS(proto), PARAMS(args),			\
+		    PARAMS(tstruct), PARAMS(assign), PARAMS(print))
+
 #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
 #define TRACE_EVENT_FN(name, proto, args, struct,		\
include/trace/events/power.h +3 -3
index ea6d579..7f0e86e 100644
@@ -18,7 +18,7 @@ enum {
 
 
 
-TRACE_EVENT(power_start,
+TRACE_EVENT_ABI(power_start,
 
 	TP_PROTO(unsigned int type, unsigned int state),
 
@@ -37,7 +37,7 @@ TRACE_EVENT(power_start,
 	TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, (unsigned long)__entry->state)
 );
 
-TRACE_EVENT(power_end,
+TRACE_EVENT_ABI(power_end,
 
 	TP_PROTO(int dummy),
 
@@ -56,7 +56,7 @@ TRACE_EVENT(power_end,
 );
 
 
-TRACE_EVENT(power_frequency,
+TRACE_EVENT_ABI(power_frequency,
 
 	TP_PROTO(unsigned int type, unsigned int state),
 
include/trace/events/sched.h +2 -2
index 4069c43..93a3e17 100644
@@ -83,7 +83,7 @@ TRACE_EVENT(sched_wait_task,
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
-TRACE_EVENT(sched_wakeup,
+TRACE_EVENT_ABI(sched_wakeup,
 
 	TP_PROTO(struct rq *rq, struct task_struct *p, int success),
 
@@ -149,7 +149,7 @@ TRACE_EVENT(sched_wakeup_new,
  * (NOTE: the 'rq' argument is not used by generic trace events,
  *        but used by the latency tracer plugin. )
  */
-TRACE_EVENT(sched_switch,
+TRACE_EVENT_ABI(sched_switch,
 
 	TP_PROTO(struct rq *rq, struct task_struct *prev,
 		 struct task_struct *next),
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#9 lore raw

Re: [patch] introduce TRACE_EVENT_ABI (was Re: TRACE_EVENT_ABI ?)

2009/9/23, Arjan van de Ven <[email protected]>:

Quoted 22 lines

From e2c647ae2d3ddc25b804f0419956caf40d89c606 Mon Sep 17 00:00:00 2001
From: Steven Rostedt <[email protected]>
Date: Mon, 21 Sep 2009 20:14:53 +0200
Subject: [PATCH] trace: introduce TRACE_EVENT_ABI

Some trace events are suitable to form a stable userspace ABI; this patch introduces infrastructure to mark them as such, and marks the first few tracepoints this way

---
 include/linux/tracepoint.h   |    4 ++++
 include/trace/events/power.h |    6 +++---
 include/trace/events/sched.h |    4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)
include/linux/tracepoint.h +0 -0
index 63a3f7a..4cb454f 100644

include/linux/tracepoint.h static inline void tracepoint_synchronize_unregister(void) · line 286

Quoted 7 lines
include/linux/tracepoint.h +4 -0
@@ -280,6 +280,10 @@ static inline void tracepoint_synchronize_unregister(void)
 * TRACE_EVENT_FN to perform any (un)registration work.
 */
 
+#define TRACE_EVENT_ABI(name, proto, args, tstruct, assign, print)     \
+       TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
+                   PARAMS(tstruct), PARAMS(assign), PARAMS(print))
+

You may probably need to undefine it from trace/define_trace.h once every cpp magic have been done (ie: once trace/ftrace.h have been included.)

Because some files include several tracepoint/trace event headers, then linux/tracepoint.h gets included several times and eventually TRACE_EVENT_ABI() would be redefined (and then crash).

That's why we have:

#ifdef CONFIG_EVENT_TRACING
#include <trace/ftrace.h>
#endif

#undef TRACE_EVENT
#undef TRACE_EVENT_FN
#undef TRACE_HEADER_MULTI_READ

in define_trace.h: to allow such re-inclusion of tracepoint.h and avoid redefinitions of TRACE_EVENT and TRACE_EVENT_FN.

So you just need to add:

#undef TRACE_EVENT
#undef TRACE_EVENT_FN
+#undef TRACE_EVENT_ABI
#undef TRACE_HEADER_MULTI_READ

The problem is visible if you build napi that has such multiple tracepoint headers included in a single C file.

Thanks.