Skip to contentSkip to conversation

tracepoints for softirq entry/exit - tracepoints

PATCH Applied Jason Baron 5 participants 16 messages Mar 12, 2009 – Mar 16, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 tracepoints for softirq entry/exit - tracepoints

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +12 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index ba1511f..c378d53 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -186,6 +187,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(irq_softirq_entry);
+DEFINE_TRACE(irq_softirq_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -212,8 +216,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_irq_softirq_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_irq_softirq_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
#1 lore raw
Quoted 48 lines · Jason Baron

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +12 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +1 -0
index ba1511f..c378d53 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*

kernel/softirq.c EXPORT_SYMBOL(local_bh_enable_ip); · line 191

Quoted 5 lines
kernel/softirq.c +2 -0
@@ -186,6 +187,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(irq_softirq_entry);
+DEFINE_TRACE(irq_softirq_exit);

Just one nit here. The "irq_" prefix seems to me too much. On the trace we have:

/* irq_softirq_entry: softirq=nb action=nb_to_logical_name */

It's even too much words that says the same things. Moreover, we have the logical name, the number seems not very useful because we have its logical translation just after.

I would suggest to have just:

/* softirq_entry: nb_to_logical_name */

ie:

/* softirq_entry: SCHED_SOFTIRQ */

Don't you think it's more clear and obvious?

Other than that, I think these tracepoints are a good idea.

Quoted 14 lines
kernel/softirq.c +2 -1
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -212,8 +216,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_irq_softirq_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_irq_softirq_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
Acked-by
#2 lore raw
Quoted 67 lines · Frederic Weisbecker
Quoted 48 lines · Jason Baron

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +12 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +1 -0
index ba1511f..c378d53 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*

kernel/softirq.c EXPORT_SYMBOL(local_bh_enable_ip); · line 191

Quoted 5 lines
kernel/softirq.c +2 -0
@@ -186,6 +187,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(irq_softirq_entry);
+DEFINE_TRACE(irq_softirq_exit);

Just one nit here. The "irq_" prefix seems to me too much. On the trace we have:

/* irq_softirq_entry: softirq=nb action=nb_to_logical_name */

It's even too much words that says the same things. Moreover, we have the logical name, the number seems not very useful because we have its logical translation just after.

I would suggest to have just:

Quoted 7 lines

/* softirq_entry: nb_to_logical_name */

ie:

/* softirq_entry: SCHED_SOFTIRQ */

Don't you think it's more clear and obvious?

yeah.

Quoted 1 line

Other than that, I think these tracepoints are a good idea.

agreed.

Ingo

#3 lore raw

[tip:tracing/ftrace] tracing: tracepoints for softirq entry/exit - tracepoints

In reply to Jason Baron
Commit-ID:  39842323ceb368d2ea36ab7696aedbe296e13b61
Gitweb:     http://git.kernel.org/tip/39842323ceb368d2ea36ab7696aedbe296e13b61
Author:     Jason Baron <[email protected]>
AuthorDate: Thu, 12 Mar 2009 14:36:03 -0400
Commit:     Steven Rostedt <[email protected]>
CommitDate: Thu, 12 Mar 2009 21:20:58 -0400

tracing: tracepoints for softirq entry/exit - tracepoints

Introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

[
s/irq_softirq_/softirq_/ for trace point names and Fixed printf format in TRACE_FORMAT macro
- Steven Rostedt
]

LKML-Reference: <[email protected]>

---
 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +12 -0
index 214bb92..85964eb 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_FORMAT(softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", (int)(h - vec), softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", (int)(h - vec), softirq_to_name[h-vec])
+	);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index 9f90fdc..a5e8123 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -186,6 +187,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(softirq_entry);
+DEFINE_TRACE(softirq_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -212,8 +216,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_softirq_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_softirq_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
#4 lore raw
In reply to Jason Baron
Quoted 22 lines · * Jason Baron ([email protected]) wrote:

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +0 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 52

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

Mathieu

Quoted 37 lines
include/trace/irq_event_types.h +2 -0
+	);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index ba1511f..c378d53 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -186,6 +187,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(irq_softirq_entry);
+DEFINE_TRACE(irq_softirq_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -212,8 +216,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_irq_softirq_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_irq_softirq_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#5 lore raw
Quoted 32 lines · Mathieu Desnoyers
Quoted 31 lines · * Jason Baron ([email protected]) wrote:

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +9 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
Quoted 8 lines

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 52

Quoted 1 line
include/trace/irq_event_types.h +1 -0
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The right solution is to change this tracepoint to TRACE_EVENT() format. Jason, do you have time to do that?

Ingo

maintainer
#6 lore raw
In reply to Mathieu Desnoyers
Quoted 23 lines · Mathieu Desnoyers
Quoted 22 lines · * Jason Baron ([email protected]) wrote:

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +0 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
Quoted 16 lines

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 52

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

-- Steve

#7 lore raw
Quoted 43 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 23 lines · Mathieu Desnoyers
Quoted 22 lines · * Jason Baron ([email protected]) wrote:

introduce softirq entry/exit tracepoints. These are useful for augmenting existing tracers, and to figure out softirq frequencies and timings.

---

 include/trace/irq_event_types.h |   12 ++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +0 -0
index 214bb92..38b4bdd 100644
@@ -40,4 +40,16 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
Quoted 16 lines

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 52

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+TRACE_FORMAT(irq_softirq_entry,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])
+	);
+
+TRACE_FORMAT(irq_softirq_exit,
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+	TP_ARGS(h, vec),
+	TP_FMT("softirq=%d action=%s", h - vec, softirq_to_name[h-vec])

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

Quoted 5 lines

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

-- Steve

By doing so, you are removing the ability to use the TP_FMT information to perform high-speed system-wide tracing. I thought the goal was to create a unified buffering, but sadly I don't see the high-speed requirements being part of that plan.

Mathieu

Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
maintainer
#8 lore raw
Quoted 10 lines · Mathieu Desnoyers
Quoted 10 lines
Quoted 6 lines

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

Quoted 7 lines
Quoted 2 lines

-- Steve

By doing so, you are removing the ability to use the TP_FMT information to perform high-speed system-wide tracing. I thought the goal was to create a unified buffering, but sadly I don't see the high-speed requirements being part of that plan.

TP_FMT has nothing to do with the unified buffering. The unified buffer does not even know about it. But if you want high-speed event tracing, that is what the TRACE_EVENT was created for.

The TRACE_FORMAT was made for things that will be recording string information anyway, and recording a string into the buffer via memcpy or a sprintf format (binary printk) doesn't make much difference.

Then trace points for entry and exit does not fall into that category, and should be represented by a TRACE_EVENT instead.

-- Steve

maintainer
#9 lore raw
Quoted 15 lines · Steven Rostedt
Quoted 13 lines · Mathieu Desnoyers
Quoted 12 lines
Quoted 6 lines

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

-- Steve

Quoted 8 lines
Quoted 4 lines

By doing so, you are removing the ability to use the TP_FMT information to perform high-speed system-wide tracing. I thought the goal was to create a unified buffering, but sadly I don't see the high-speed requirements being part of that plan.

TP_FMT has nothing to do with the unified buffering. The unified buffer does not even know about it. But if you want high-speed event tracing, that is what the TRACE_EVENT was created for.

Here's an example:

The "event tracing" uses the format field to show those events for the hook in the sched switching, and wake ups.

The wake up tracer on the other hand, does not care about the format, it only cares about having a hook where a a task is woken up, and where it gets scheduled in, and perhaps events in between. But it uses its own formatting to do the output.

-- Steve

#10 lore raw
Quoted 32 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 15 lines · Steven Rostedt
Quoted 13 lines · Mathieu Desnoyers
Quoted 12 lines
Quoted 6 lines

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

-- Steve

Quoted 8 lines
Quoted 4 lines

By doing so, you are removing the ability to use the TP_FMT information to perform high-speed system-wide tracing. I thought the goal was to create a unified buffering, but sadly I don't see the high-speed requirements being part of that plan.

TP_FMT has nothing to do with the unified buffering. The unified buffer does not even know about it. But if you want high-speed event tracing, that is what the TRACE_EVENT was created for.

Here's an example:

The "event tracing" uses the format field to show those events for the hook in the sched switching, and wake ups.

Quoted 7 lines

The wake up tracer on the other hand, does not care about the format, it only cares about having a hook where a a task is woken up, and where it gets scheduled in, and perhaps events in between. But it uses its own formatting to do the output.

-- Steve

If I understand you correctly, the format string is only useful to the text-output tracer ? Why can't it be used to identify both text and binary events ?

And remember that from my perspective, information is only useful if available for system-wide tracing. Specialized tracers come as a subset of system-wide tracing anyway when the latter is implemented with the proper hooks.

Mathieu

Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#11 lore raw
In reply to Steven Rostedt
Quoted 20 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 10 lines · Mathieu Desnoyers
Quoted 10 lines
Quoted 6 lines

The softirq tracepoints are a good idea indeed (I have similar ones in the LTTng tree). My main concern is about the fact that you output the softirq name in plain text to the trace buffers. I would rather prefer to save only the softirq (h-vec) into the trace and dump the mapping (h-vec) to name only once, so we can save precious trace bytes.

The TP_FMT is only used by those tracers that want to use it. Any tracer can still hook directly to the trace point and do what every they want.

Quoted 7 lines
Quoted 2 lines

-- Steve

By doing so, you are removing the ability to use the TP_FMT information to perform high-speed system-wide tracing. I thought the goal was to create a unified buffering, but sadly I don't see the high-speed requirements being part of that plan.

Quoted 8 lines

TP_FMT has nothing to do with the unified buffering. The unified buffer does not even know about it. But if you want high-speed event tracing, that is what the TRACE_EVENT was created for.

The TRACE_FORMAT was made for things that will be recording string information anyway, and recording a string into the buffer via memcpy or a sprintf format (binary printk) doesn't make much difference.

Are you saying that dynamically parsing a format string in a binary printk has the same performance impact as a memcpy ? I would be very interested to see your benchmarks.

Mathieu

Quoted 5 lines

Then trace points for entry and exit does not fall into that category, and should be represented by a TRACE_EVENT instead.

-- Steve

Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#12 lore raw
In reply to Jason Baron

hi,

ok, below is a re-spun patch 2/2 which converts to the TRACE_EVENT format.

thanks,

-Jason

---

 include/trace/irq_event_types.h |   36 ++++++++++++++++++++++++++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +36 -0
index 214bb92..de1f2a9 100644
@@ -40,4 +40,40 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_EVENT(softirq_action_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);
+	),
+
+	TP_printk("softirq entry: %s", __entry->softirq_name)
+);
+
+TRACE_EVENT(softirq_action_exit,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);
+	),
+
+	TP_printk("softirq exit: %s", __entry->softirq_name)
+);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index 8f3ae57..5e96c77 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -185,6 +186,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(softirq_action_entry);
+DEFINE_TRACE(softirq_action_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -211,8 +215,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_softirq_action_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_softirq_action_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
maintainer
#13 lore raw
Quoted 4 lines · Jason Baron

hi,

ok, below is a re-spun patch 2/2 which converts to the TRACE_EVENT format.

Thanks, some comments though.

Quoted 26 lines

thanks,

-Jason

---

 include/trace/irq_event_types.h |   36 ++++++++++++++++++++++++++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +3 -0
index 214bb92..de1f2a9 100644
@@ -40,4 +40,40 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_EVENT(softirq_action_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 55

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);

memcpy isn't fast ;-)

What you want is this:

	TP_STRUCT__entry(
		__field(	int,	vec	)
	),

	TP_fast_assign(
		__entry->vec = h - vec;

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 58

Quoted 3 lines
include/trace/irq_event_types.h +3 -0
+	),
+
+	TP_printk("softirq entry: %s", __entry->softirq_name)
	TP_printk("softirq entry: %s", softirq_to_name[__entry->vec])
Quoted 8 lines
include/trace/irq_event_types.h +8 -0
+);
+
+TRACE_EVENT(softirq_action_exit,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 76

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);
+	),
+
+	TP_printk("softirq exit: %s", __entry->softirq_name)

And do the same here.

-- Steve

Quoted 37 lines
include/trace/irq_event_types.h +2 -0
+);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index 8f3ae57..5e96c77 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -185,6 +186,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(softirq_action_entry);
+DEFINE_TRACE(softirq_action_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -211,8 +215,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_softirq_action_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_softirq_action_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
#14 lore raw
Quoted 33 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 4 lines · Jason Baron

hi,

ok, below is a re-spun patch 2/2 which converts to the TRACE_EVENT format.

Thanks, some comments though.

Quoted 23 lines

thanks,

-Jason

---

 include/trace/irq_event_types.h |   36 ++++++++++++++++++++++++++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +0 -0
index 214bb92..de1f2a9 100644
@@ -40,4 +40,40 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
Quoted 16 lines

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 55

Quoted 13 lines
include/trace/irq_event_types.h +13 -0
+TRACE_EVENT(softirq_action_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);

memcpy isn't fast ;-)

When given a constant size, memcpy is inlined by the compiler and turned into a simple mov instruction. That shouldn't change a thing.

Mathieu

Quoted 76 lines

What you want is this:

	TP_STRUCT__entry(
		__field(	int,	vec	)
	),

	TP_fast_assign(
		__entry->vec = h - vec;

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 58

Quoted 3 lines
include/trace/irq_event_types.h +3 -0
+	),
+
+	TP_printk("softirq entry: %s", __entry->softirq_name)
	TP_printk("softirq entry: %s", softirq_to_name[__entry->vec])
Quoted 8 lines
include/trace/irq_event_types.h +8 -0
+);
+
+TRACE_EVENT(softirq_action_exit,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+

include/trace/irq_event_types.h TRACE_EVENT(irq_handler_exit, · line 76

Quoted 10 lines
include/trace/irq_event_types.h +10 -0
+	TP_STRUCT__entry(
+		__array(	char,	softirq_name,	MAX_SOFTIRQ_NAME_LEN )
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->softirq_name, softirq_to_name[h-vec],
+			MAX_SOFTIRQ_NAME_LEN);
+	),
+
+	TP_printk("softirq exit: %s", __entry->softirq_name)

And do the same here.

-- Steve

Quoted 37 lines
include/trace/irq_event_types.h +2 -0
+);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index 8f3ae57..5e96c77 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -185,6 +186,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(softirq_action_entry);
+DEFINE_TRACE(softirq_action_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -211,8 +215,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_softirq_action_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_softirq_action_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#15 lore raw
In reply to Steven Rostedt
Quoted 10 lines · Steven Rostedt

memcpy isn't fast ;-)

What you want is this:

	TP_STRUCT__entry(
		__field(	int,	vec	)
	),

	TP_fast_assign(
		__entry->vec = h - vec;

definitely simplifies things! ok, re-spun patch again.

use TRACE_EVENT to record the softirq vector number in the trace and then use the new softirq_to_name array to output the softirq vector name.

---

 include/trace/irq_event_types.h |   34 ++++++++++++++++++++++++++++++++++
 kernel/softirq.c                |    7 ++++++-
 2 files changed, 40 insertions(+), 1 deletions(-)
include/trace/irq_event_types.h +34 -0
index 214bb92..acb8217 100644
@@ -40,4 +40,38 @@ TRACE_EVENT(irq_handler_exit,
 		  __entry->irq, __entry->ret ? "handled" : "unhandled")
 );
 
+TRACE_EVENT(softirq_action_entry,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__field(	int,	vec	)
+	),
+
+	TP_fast_assign(
+		__entry->vec = h - vec;
+	),
+
+	TP_printk("softirq entry: %s", softirq_to_name[__entry->vec])
+);
+
+TRACE_EVENT(softirq_action_exit,
+
+	TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+	TP_ARGS(h, vec),
+
+	TP_STRUCT__entry(
+		__field(	int,	vec	)
+	),
+
+	TP_fast_assign(
+		__entry->vec = h - vec;
+	),
+
+	TP_printk("softirq exit: %s", softirq_to_name[__entry->vec])
+);
+
 #undef TRACE_SYSTEM
kernel/softirq.c +6 -1
index 8f3ae57..5e96c77 100644
@@ -24,6 +24,7 @@
 #include <linux/ftrace.h>
 #include <linux/smp.h>
 #include <linux/tick.h>
+#include <trace/irq.h>
 
 #include <asm/irq.h>
 /*
@@ -185,6 +186,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
  */
 #define MAX_SOFTIRQ_RESTART 10
 
+DEFINE_TRACE(softirq_action_entry);
+DEFINE_TRACE(softirq_action_exit);
+
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
@@ -211,8 +215,9 @@ restart:
 		if (pending & 1) {
 			int prev_count = preempt_count();
 
+			trace_softirq_action_entry(h, softirq_vec);
 			h->action(h);
-
+			trace_softirq_action_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
 				printk(KERN_ERR "huh, entered softirq %td %s %p"
 				       "with preempt_count %08x,"