]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> |
2 | Subject: LTTng instrumentation - irq | |
3 | ||
4 | Original patch header: | |
5 | LTTng instrumentation - irq | |
6 | ||
7 | Instrumentation of IRQ related events : irq, softirq, tasklet entry and exit and | |
8 | softirq "raise" events. | |
9 | ||
10 | It allows tracers to perform latency analysis on those various types of | |
11 | interrupts and to detect interrupts with max/min/avg duration. It helps | |
12 | detecting driver or hardware problems which cause an ISR to take ages to | |
13 | execute. It has been shown to be the case with bogus hardware causing an mmio | |
14 | read to take a few milliseconds. | |
15 | ||
16 | Those tracepoints are used by LTTng. | |
17 | ||
18 | About the performance impact of tracepoints (which is comparable to markers), | |
19 | even without immediate values optimizations, tests done by Hideo Aoki on ia64 | |
20 | show no regression. His test case was using hackbench on a kernel where | |
21 | scheduler instrumentation (about 5 events in code scheduler code) was added. | |
22 | See the "Tracepoints" patch header for performance result detail. | |
23 | ||
24 | Changelog: | |
25 | - Add retval as irq_exit argument. | |
26 | ||
27 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | |
28 | CC: Thomas Gleixner <tglx@linutronix.de> | |
29 | CC: Russell King <rmk+lkml@arm.linux.org.uk> | |
30 | CC: Masami Hiramatsu <mhiramat@redhat.com> | |
31 | CC: 'Peter Zijlstra' <peterz@infradead.org> | |
32 | CC: "Frank Ch. Eigler" <fche@redhat.com> | |
33 | CC: 'Ingo Molnar' <mingo@elte.hu> | |
34 | CC: 'Hideo AOKI' <haoki@redhat.com> | |
35 | CC: Takashi Nishiie <t-nishiie@np.css.fujitsu.com> | |
36 | CC: 'Steven Rostedt' <rostedt@goodmis.org> | |
37 | CC: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> | |
38 | ||
39 | Acked-by: Jan Blunck <jblunck@suse.de> | |
40 | --- | |
41 | --- | |
42 | include/trace/irq.h | 36 ++++++++++++++++++++++++++++++++++++ | |
43 | kernel/irq/handle.c | 6 ++++++ | |
44 | kernel/softirq.c | 8 ++++++++ | |
45 | 3 files changed, 50 insertions(+) | |
46 | ||
47 | --- /dev/null | |
48 | +++ b/include/trace/irq.h | |
49 | @@ -0,0 +1,36 @@ | |
50 | +#ifndef _TRACE_IRQ_H | |
51 | +#define _TRACE_IRQ_H | |
52 | + | |
53 | +#include <linux/kdebug.h> | |
54 | +#include <linux/interrupt.h> | |
55 | +#include <linux/tracepoint.h> | |
56 | + | |
57 | +DEFINE_TRACE(irq_entry, | |
58 | + TPPROTO(unsigned int id, struct pt_regs *regs), | |
59 | + TPARGS(id, regs)); | |
60 | +DEFINE_TRACE(irq_exit, | |
61 | + TPPROTO(irqreturn_t retval), | |
62 | + TPARGS(retval)); | |
63 | +DEFINE_TRACE(irq_softirq_entry, | |
64 | + TPPROTO(struct softirq_action *h, struct softirq_action *softirq_vec), | |
65 | + TPARGS(h, softirq_vec)); | |
66 | +DEFINE_TRACE(irq_softirq_exit, | |
67 | + TPPROTO(struct softirq_action *h, struct softirq_action *softirq_vec), | |
68 | + TPARGS(h, softirq_vec)); | |
69 | +DEFINE_TRACE(irq_softirq_raise, | |
70 | + TPPROTO(unsigned int nr), | |
71 | + TPARGS(nr)); | |
72 | +DEFINE_TRACE(irq_tasklet_low_entry, | |
73 | + TPPROTO(struct tasklet_struct *t), | |
74 | + TPARGS(t)); | |
75 | +DEFINE_TRACE(irq_tasklet_low_exit, | |
76 | + TPPROTO(struct tasklet_struct *t), | |
77 | + TPARGS(t)); | |
78 | +DEFINE_TRACE(irq_tasklet_high_entry, | |
79 | + TPPROTO(struct tasklet_struct *t), | |
80 | + TPARGS(t)); | |
81 | +DEFINE_TRACE(irq_tasklet_high_exit, | |
82 | + TPPROTO(struct tasklet_struct *t), | |
83 | + TPARGS(t)); | |
84 | + | |
85 | +#endif | |
86 | --- a/kernel/irq/handle.c | |
87 | +++ b/kernel/irq/handle.c | |
88 | @@ -15,6 +15,7 @@ | |
89 | #include <linux/random.h> | |
90 | #include <linux/interrupt.h> | |
91 | #include <linux/kernel_stat.h> | |
92 | +#include <trace/irq.h> | |
93 | ||
94 | #include "internals.h" | |
95 | ||
96 | @@ -130,6 +131,9 @@ irqreturn_t handle_IRQ_event(unsigned in | |
97 | { | |
98 | irqreturn_t ret, retval = IRQ_NONE; | |
99 | unsigned int status = 0; | |
100 | + struct pt_regs *regs = get_irq_regs(); | |
101 | + | |
102 | + trace_irq_entry(irq, regs); | |
103 | ||
104 | handle_dynamic_tick(action); | |
105 | ||
106 | @@ -148,6 +152,8 @@ irqreturn_t handle_IRQ_event(unsigned in | |
107 | add_interrupt_randomness(irq); | |
108 | local_irq_disable(); | |
109 | ||
110 | + trace_irq_exit(retval); | |
111 | + | |
112 | return retval; | |
113 | } | |
114 | ||
115 | --- a/kernel/softirq.c | |
116 | +++ b/kernel/softirq.c | |
117 | @@ -21,6 +21,7 @@ | |
118 | #include <linux/rcupdate.h> | |
119 | #include <linux/smp.h> | |
120 | #include <linux/tick.h> | |
121 | +#include <trace/irq.h> | |
122 | ||
123 | #include <asm/irq.h> | |
124 | /* | |
125 | @@ -205,7 +206,9 @@ restart: | |
126 | ||
127 | do { | |
128 | if (pending & 1) { | |
129 | + trace_irq_softirq_entry(h, softirq_vec); | |
130 | h->action(h); | |
131 | + trace_irq_softirq_exit(h, softirq_vec); | |
132 | rcu_bh_qsctr_inc(cpu); | |
133 | } | |
134 | h++; | |
135 | @@ -297,6 +300,7 @@ void irq_exit(void) | |
136 | */ | |
137 | inline void raise_softirq_irqoff(unsigned int nr) | |
138 | { | |
139 | + trace_irq_softirq_raise(nr); | |
140 | __raise_softirq_irqoff(nr); | |
141 | ||
142 | /* | |
143 | @@ -383,7 +387,9 @@ static void tasklet_action(struct softir | |
144 | if (!atomic_read(&t->count)) { | |
145 | if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) | |
146 | BUG(); | |
147 | + trace_irq_tasklet_low_entry(t); | |
148 | t->func(t->data); | |
149 | + trace_irq_tasklet_low_exit(t); | |
150 | tasklet_unlock(t); | |
151 | continue; | |
152 | } | |
153 | @@ -418,7 +424,9 @@ static void tasklet_hi_action(struct sof | |
154 | if (!atomic_read(&t->count)) { | |
155 | if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state)) | |
156 | BUG(); | |
157 | + trace_irq_tasklet_high_entry(t); | |
158 | t->func(t->data); | |
159 | + trace_irq_tasklet_high_exit(t); | |
160 | tasklet_unlock(t); | |
161 | continue; | |
162 | } |