Skip to contentSkip to conversation

softirq,tracing: enable to trace softirq raise latency

PATCH In review Lai Jiangshan 3 participants 5 messages Nov 5, 2009 – Nov 9, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softirq,tracing: enable to trace softirq raise latency

Add a tracepoint for tracing when softirq action is raised.

It and the existed tracepoints complete softirq's tracepoints:
softirq_raise, softirq_entry and softirq_exit.

And when this tracepoint is used in combination with the softirq_entry tracepoint we can determine the softirq raise latency.

---

include/linux/interrupt.h +8 -1
index 75f3f00..b368d5d 100644
@@ -18,6 +18,7 @@
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <trace/events/irq.h>
 
 /*
  * These correspond to the IORESOURCE_IRQ_* defines in
@@ -372,7 +373,13 @@ asmlinkage void do_softirq(void);
 asmlinkage void __do_softirq(void);
 extern void open_softirq(int nr, void (*action)(struct softirq_action *));
 extern void softirq_init(void);
-#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
+
+static inline void __raise_softirq_irqoff(unsigned int nr)
+{
+	trace_softirq_raise(nr);
+	or_softirq_pending(1UL << nr);
+}
+
 extern void raise_softirq_irqoff(unsigned int nr);
 extern void raise_softirq(unsigned int nr);
 extern void wakeup_softirqd(void);
include/trace/events/irq.h +33 -5
index dcfcd44..799af09 100644
@@ -5,7 +5,9 @@
 #define _TRACE_IRQ_H
 
 #include <linux/tracepoint.h>
-#include <linux/interrupt.h>
+
+struct irqaction;
+struct softirq_action;
 
 #define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
 #define show_softirq_name(val)				\
@@ -83,6 +85,32 @@ TRACE_EVENT(irq_handler_exit,
 );
 
 /**
+ * softirq_raise - called immediately when a softirq is raised
+ * @nr: softirq vector number
+ *
+ * Tracepoint for tracing when softirq action is raised.
+ * Also, when used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise latency.
+ */
+TRACE_EVENT(softirq_raise,
+
+	TP_PROTO(unsigned int nr),
+
+	TP_ARGS(nr),
+
+	TP_STRUCT__entry(
+		__field(	unsigned int,	vec		)
+	),
+
+	TP_fast_assign(
+		__entry->vec	= nr;
+	),
+
+	TP_printk("vec=%d [action=%s]", __entry->vec,
+		  show_softirq_name(__entry->vec))
+);
+
+/**
  * softirq_entry - called immediately before the softirq handler
  * @h: pointer to struct softirq_action
  * @vec: pointer to first struct softirq_action in softirq_vec array
@@ -100,11 +128,11 @@ TRACE_EVENT(softirq_entry,
 	TP_ARGS(h, vec),
 
 	TP_STRUCT__entry(
-		__field(	int,	vec			)
+		__field(	unsigned int,	vec		)
 	),
 
 	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
+		__entry->vec = (unsigned int)(h - vec);
 	),
 
 	TP_printk("vec=%d [action=%s]", __entry->vec,
@@ -129,11 +157,11 @@ TRACE_EVENT(softirq_exit,
 	TP_ARGS(h, vec),
 
 	TP_STRUCT__entry(
-		__field(	int,	vec			)
+		__field(	unsigned int,	vec		)
 	),
 
 	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
+		__entry->vec = (unsigned int)(h - vec);
 	),
 
 	TP_printk("vec=%d [action=%s]", __entry->vec,
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · * Lai Jiangshan ([email protected]) wrote:

Add a tracepoint for tracing when softirq action is raised.

It and the existed tracepoints complete softirq's tracepoints:
softirq_raise, softirq_entry and softirq_exit.

And when this tracepoint is used in combination with the softirq_entry tracepoint we can determine the softirq raise latency.

Hi Lai,

It generally looks good, we have a similar instrumentation point in the LTTng tree, and it's really useful. It's a good idea to instrument __raise_softirq_irqoff rather than just raise_softirq_irqoff: it includes the HI/TASKLET and HRTIMER softirqs.

There is just a small comment which should probably also be changed, please see below, besides that, you have my

Quoted 67 lines

---

include/linux/interrupt.h +8 -1
index 75f3f00..b368d5d 100644
@@ -18,6 +18,7 @@
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <trace/events/irq.h>
 
 /*
  * These correspond to the IORESOURCE_IRQ_* defines in
@@ -372,7 +373,13 @@ asmlinkage void do_softirq(void);
 asmlinkage void __do_softirq(void);
 extern void open_softirq(int nr, void (*action)(struct softirq_action *));
 extern void softirq_init(void);
-#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
+
+static inline void __raise_softirq_irqoff(unsigned int nr)
+{
+	trace_softirq_raise(nr);
+	or_softirq_pending(1UL << nr);
+}
+
 extern void raise_softirq_irqoff(unsigned int nr);
 extern void raise_softirq(unsigned int nr);
 extern void wakeup_softirqd(void);
include/trace/events/irq.h +22 -1
index dcfcd44..799af09 100644
@@ -5,7 +5,9 @@
 #define _TRACE_IRQ_H
 
 #include <linux/tracepoint.h>
-#include <linux/interrupt.h>
+
+struct irqaction;
+struct softirq_action;
 
 #define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
 #define show_softirq_name(val)				\
@@ -83,6 +85,32 @@ TRACE_EVENT(irq_handler_exit,
 );
 
 /**
+ * softirq_raise - called immediately when a softirq is raised
+ * @nr: softirq vector number
+ *
+ * Tracepoint for tracing when softirq action is raised.
+ * Also, when used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise latency.
+ */
+TRACE_EVENT(softirq_raise,
+
+	TP_PROTO(unsigned int nr),
+
+	TP_ARGS(nr),
+
+	TP_STRUCT__entry(
+		__field(	unsigned int,	vec		)
+	),
+
+	TP_fast_assign(
+		__entry->vec	= nr;

include/trace/events/irq.h TRACE_EVENT(irq_handler_exit, · line 116

Quoted 10 lines
include/trace/events/irq.h +7 -0
+	),
+
+	TP_printk("vec=%d [action=%s]", __entry->vec,
+		  show_softirq_name(__entry->vec))
+);
+
+/**
  * softirq_entry - called immediately before the softirq handler
  * @h: pointer to struct softirq_action
  * @vec: pointer to first struct softirq_action in softirq_vec array

Please change this comment to "@vec: softirq vector number" while you are at it. The same probably needs to be done for softirq_exit. @vec are not pointers: these are offsets.

Thanks,

Mathieu

Quoted 29 lines
include/trace/events/irq.h +4 -4
@@ -100,11 +128,11 @@ TRACE_EVENT(softirq_entry,
 	TP_ARGS(h, vec),
 
 	TP_STRUCT__entry(
-		__field(	int,	vec			)
+		__field(	unsigned int,	vec		)
 	),
 
 	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
+		__entry->vec = (unsigned int)(h - vec);
 	),
 
 	TP_printk("vec=%d [action=%s]", __entry->vec,
@@ -129,11 +157,11 @@ TRACE_EVENT(softirq_exit,
 	TP_ARGS(h, vec),
 
 	TP_STRUCT__entry(
-		__field(	int,	vec			)
+		__field(	unsigned int,	vec		)
 	),
 
 	TP_fast_assign(
-		__entry->vec = (int)(h - vec);
+		__entry->vec = (unsigned int)(h - vec);
 	),
 
 	TP_printk("vec=%d [action=%s]", __entry->vec,
Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
#2 lore raw
Quoted 96 lines · Mathieu Desnoyers
Quoted 9 lines · * Lai Jiangshan ([email protected]) wrote:

Add a tracepoint for tracing when softirq action is raised.

It and the existed tracepoints complete softirq's tracepoints:
softirq_raise, softirq_entry and softirq_exit.

And when this tracepoint is used in combination with the softirq_entry tracepoint we can determine the softirq raise latency.

Hi Lai,

It generally looks good, we have a similar instrumentation point in the LTTng tree, and it's really useful. It's a good idea to instrument __raise_softirq_irqoff rather than just raise_softirq_irqoff: it includes the HI/TASKLET and HRTIMER softirqs.

There is just a small comment which should probably also be changed, please see below, besides that, you have my

Quoted 73 lines

---

include/linux/interrupt.h +8 -1
index 75f3f00..b368d5d 100644
@@ -18,6 +18,7 @@
 #include <asm/atomic.h>
 #include <asm/ptrace.h>
 #include <asm/system.h>
+#include <trace/events/irq.h>
 
 /*
  * These correspond to the IORESOURCE_IRQ_* defines in
@@ -372,7 +373,13 @@ asmlinkage void do_softirq(void);
 asmlinkage void __do_softirq(void);
 extern void open_softirq(int nr, void (*action)(struct softirq_action *));
 extern void softirq_init(void);
-#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
+
+static inline void __raise_softirq_irqoff(unsigned int nr)
+{
+	trace_softirq_raise(nr);
+	or_softirq_pending(1UL << nr);
+}
+
 extern void raise_softirq_irqoff(unsigned int nr);
 extern void raise_softirq(unsigned int nr);
 extern void wakeup_softirqd(void);
include/trace/events/irq.h +28 -1
index dcfcd44..799af09 100644
@@ -5,7 +5,9 @@
 #define _TRACE_IRQ_H
 
 #include <linux/tracepoint.h>
-#include <linux/interrupt.h>
+
+struct irqaction;
+struct softirq_action;
 
 #define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
 #define show_softirq_name(val)				\
@@ -83,6 +85,32 @@ TRACE_EVENT(irq_handler_exit,
 );
 
 /**
+ * softirq_raise - called immediately when a softirq is raised
+ * @nr: softirq vector number
+ *
+ * Tracepoint for tracing when softirq action is raised.
+ * Also, when used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise latency.
+ */
+TRACE_EVENT(softirq_raise,
+
+	TP_PROTO(unsigned int nr),
+
+	TP_ARGS(nr),
+
+	TP_STRUCT__entry(
+		__field(	unsigned int,	vec		)
+	),
+
+	TP_fast_assign(
+		__entry->vec	= nr;
+	),
+
+	TP_printk("vec=%d [action=%s]", __entry->vec,
+		  show_softirq_name(__entry->vec))
+);
+
Quoted 9 lines

include/trace/events/irq.h TRACE_EVENT(irq_handler_exit, · line 116

Quoted 4 lines
include/trace/events/irq.h +1 -0
+/**
  * softirq_entry - called immediately before the softirq handler
  * @h: pointer to struct softirq_action
  * @vec: pointer to first struct softirq_action in softirq_vec array

Please change this comment to "@vec: softirq vector number" while you are at it. The same probably needs to be done for softirq_exit. @vec are not pointers: these are offsets.

Thank you for you like it and your comment.

@vec are pointers here. it's softirq_vec. Don't need to change these comments.

Lai

#3 lore raw
Quoted 12 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 10 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

+/**
* softirq_entry - called immediately before the softirq handler
* @h: pointer to struct softirq_action
* @vec: pointer to first struct softirq_action in softirq_vec array

Please change this comment to "@vec: softirq vector number" while you are at it. The same probably needs to be done for softirq_exit. @vec are not pointers: these are offsets.

Quoted 4 lines

Thank you for you like it and your comment.

@vec are pointers here. it's softirq_vec. Don't need to change these comments.

Ah, yes, you're right. I got confused by looking only at the patch context.

Thanks,

Mathieu

Quoted 2 lines

Lai

Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
Acked-by on v1 1/1
#4 lore raw
In reply to Lai Jiangshan
Quoted 11 lines · Lai Jiangshan

Add a tracepoint for tracing when softirq action is raised.

It and the existed tracepoints complete softirq's tracepoints:
softirq_raise, softirq_entry and softirq_exit.

And when this tracepoint is used in combination with the softirq_entry tracepoint we can determine the softirq raise latency.

Looks good!