2009-04-08 09:02:26

by Zhao Lei

[permalink] [raw]
Subject: [PATCH 1/2] Make __stringify support variable argument macro

For example:
__stringify(__entry->irq, __entry->ret) will convert it to:
"REC->irq, REC->ret"

It also support single argument as old macro.

Signed-off-by: Zhao Lei <[email protected]>
---
include/linux/stringify.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/stringify.h b/include/linux/stringify.h
index 0b43883..841cec8 100644
--- a/include/linux/stringify.h
+++ b/include/linux/stringify.h
@@ -6,7 +6,7 @@
* converts to "bar".
*/

-#define __stringify_1(x) #x
-#define __stringify(x) __stringify_1(x)
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)

#endif /* !__LINUX_STRINGIFY_H */
--
1.5.5.3


2009-04-08 09:03:38

by Zhao Lei

[permalink] [raw]
Subject: [PATCH 2/2] ftrace: Output REC->var instead of __entry->var for trace format

print fmt: "irq=%d return=%s", __entry->irq, __entry->ret ? \"handled\" : \"unhandled\"

"__entry" should be convert to "REC" by __stringify() macro.

Signed-off-by: Zhao Lei <[email protected]>
---
kernel/trace/trace_events_stage_2.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index 9e47c39..d694a8a 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -108,10 +108,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
return 0;

#undef __entry
-#define __entry "REC"
+#define __entry REC

#undef TP_printk
-#define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
+#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
--
1.5.5.3

2009-04-08 11:54:28

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 2/2] ftrace: Output REC->var instead of __entry->var for trace format

On Wed, Apr 08, 2009 at 05:00:13PM +0800, Zhaolei wrote:
> print fmt: "irq=%d return=%s", __entry->irq, __entry->ret ? \"handled\" : \"unhandled\"
>
> "__entry" should be convert to "REC" by __stringify() macro.
>
> Signed-off-by: Zhao Lei <[email protected]>
> ---
> kernel/trace/trace_events_stage_2.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
> index 9e47c39..d694a8a 100644
> --- a/kernel/trace/trace_events_stage_2.h
> +++ b/kernel/trace/trace_events_stage_2.h
> @@ -108,10 +108,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
> return 0;
>
> #undef __entry
> -#define __entry "REC"
> +#define __entry REC
>
> #undef TP_printk
> -#define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
> +#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
>
> #undef TRACE_EVENT
> #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
> --
> 1.5.5.3
>
>


Ah indeed nice catch.
The patch that expands stringify to multiple args looks good too.

2009-04-08 11:55:40

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 2/2] ftrace: Output REC->var instead of __entry->var for trace format

On Wed, Apr 08, 2009 at 05:00:13PM +0800, Zhaolei wrote:
> print fmt: "irq=%d return=%s", __entry->irq, __entry->ret ? \"handled\" : \"unhandled\"
>
> "__entry" should be convert to "REC" by __stringify() macro.
>
> Signed-off-by: Zhao Lei <[email protected]>
> ---
> kernel/trace/trace_events_stage_2.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
> index 9e47c39..d694a8a 100644
> --- a/kernel/trace/trace_events_stage_2.h
> +++ b/kernel/trace/trace_events_stage_2.h
> @@ -108,10 +108,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
> return 0;
>
> #undef __entry
> -#define __entry "REC"
> +#define __entry REC
>
> #undef TP_printk
> -#define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
> +#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)
>
> #undef TRACE_EVENT
> #define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
> --
> 1.5.5.3
>
>

Nice catch!
The other patch that expands stringify to multiple args looks good too.

2009-04-08 12:15:10

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 2/2] ftrace: Output REC->var instead of __entry->var for trace format


* Zhaolei <[email protected]> wrote:

> print fmt: "irq=%d return=%s", __entry->irq, __entry->ret ? \"handled\" : \"unhandled\"
>
> "__entry" should be convert to "REC" by __stringify() macro.
>
> Signed-off-by: Zhao Lei <[email protected]>
> ---
> kernel/trace/trace_events_stage_2.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)

good fix, but it is causing build trouble when applied to latest
tip/master:

include/trace/sched_event_types.h:257:1: error: macro "__stringify"
passed 3 arguments, but takes just 1

see: http://people.redhat.com/mingo/tip.git/README

Ingo

2009-04-10 14:07:33

by Zhao Lei

[permalink] [raw]
Subject: [tip:tracing/urgent] Make __stringify support variable argument macros too

Commit-ID: 8f7c2c37319a81ef4c2bfdec67b1ccd5744d97e4
Gitweb: http://git.kernel.org/tip/8f7c2c37319a81ef4c2bfdec67b1ccd5744d97e4
Author: Zhaolei <[email protected]>
AuthorDate: Wed, 8 Apr 2009 16:58:57 +0800
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 10 Apr 2009 15:48:52 +0200

Make __stringify support variable argument macros too

For example:

__stringify(__entry->irq, __entry->ret)

will now convert it to:

"REC->irq, REC->ret"

It also still supports single arguments as the old macro did.

Signed-off-by: Zhao Lei <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
include/linux/stringify.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/stringify.h b/include/linux/stringify.h
index 0b43883..841cec8 100644
--- a/include/linux/stringify.h
+++ b/include/linux/stringify.h
@@ -6,7 +6,7 @@
* converts to "bar".
*/

-#define __stringify_1(x) #x
-#define __stringify(x) __stringify_1(x)
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)

#endif /* !__LINUX_STRINGIFY_H */

2009-04-10 14:07:57

by Zhao Lei

[permalink] [raw]
Subject: [tip:tracing/urgent] ftrace: Output REC->var instead of __entry->var for trace format

Commit-ID: 0462b5664b2bda5a18fef7efb5bb32ce36590c1a
Gitweb: http://git.kernel.org/tip/0462b5664b2bda5a18fef7efb5bb32ce36590c1a
Author: Zhaolei <[email protected]>
AuthorDate: Wed, 8 Apr 2009 17:00:13 +0800
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 10 Apr 2009 15:48:53 +0200

ftrace: Output REC->var instead of __entry->var for trace format

print fmt: "irq=%d return=%s", __entry->irq, __entry->ret ? \"handled\" : \"unhandled\"

"__entry" should be convert to "REC" by __stringify() macro.

Signed-off-by: Zhao Lei <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
kernel/trace/trace_events_stage_2.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_events_stage_2.h b/kernel/trace/trace_events_stage_2.h
index 30743f7..d363c66 100644
--- a/kernel/trace/trace_events_stage_2.h
+++ b/kernel/trace/trace_events_stage_2.h
@@ -105,10 +105,10 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
return 0;

#undef __entry
-#define __entry "REC"
+#define __entry REC

#undef TP_printk
-#define TP_printk(fmt, args...) "%s, %s\n", #fmt, #args
+#define TP_printk(fmt, args...) "%s, %s\n", #fmt, __stringify(args)

#undef TP_fast_assign
#define TP_fast_assign(args...) args