[PATCH 5/6] trace: Add tracepoints to call function interrupt handlers

From: Vaibhav Nagarnaik
Date: Thu Jul 14 2011 - 17:40:04 EST


Add tracepoints to call function and call function single interrupt
handlers.

This is a part of overall effort to trace all the interrupts happening
in a system to figure out what time is spent in kernel space versus user
space.

Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@xxxxxxxxxx>
---
include/trace/events/irq.h | 73 ++++++++++++++++++++++++++++++++++++++++++++
kernel/smp.c | 5 +++
2 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index a2a0a49..40b19f4 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -384,6 +384,79 @@ DEFINE_EVENT(reschedule_interrupt, reschedule_interrupt_exit,
TP_ARGS(ignore)
);

+DECLARE_EVENT_CLASS(call_function,
+
+ TP_PROTO(unsigned int ignore),
+
+ TP_ARGS(ignore),
+
+ TP_STRUCT__entry(
+ __field( unsigned int, ignore )
+ ),
+
+ TP_fast_assign(
+ __entry->ignore = ignore;
+ ),
+
+ TP_printk("%u", __entry->ignore)
+);
+
+/**
+ * call_function_entry - called immediately after entering the
+ * call function interrupt handler
+ *
+ * When used in combination with the call_function_exit tracepoint
+ * we can determine the call function interrupt handler runtime.
+ */
+DEFINE_EVENT(call_function, call_function_entry,
+
+ TP_PROTO(unsigned int ignore),
+
+ TP_ARGS(ignore)
+);
+
+/**
+ * call_function_exit - called just before the call function interrupt
+ * handler returns
+ *
+ * When used in combination with the call_function_entry tracepoint
+ * we can determine the call function interrupt handler runtime.
+ */
+DEFINE_EVENT(call_function, call_function_exit,
+
+ TP_PROTO(unsigned int ignore),
+
+ TP_ARGS(ignore)
+);
+
+/**
+ * call_function_single_entry - called immediately after entering the
+ * call function single interrupt handler
+ *
+ * When used in combination with the call_function_single_exit tracepoint
+ * we can determine the call function single interrupt handler runtime.
+ */
+DEFINE_EVENT(call_function, call_function_single_entry,
+
+ TP_PROTO(unsigned int ignore),
+
+ TP_ARGS(ignore)
+);
+
+/**
+ * call_function_single_exit - called just before the call function single
+ * interrupt handler returns
+ *
+ * When used in combination with the call_function_single_entry tracepoint
+ * we can determine the call function single interrupt handler runtime.
+ */
+DEFINE_EVENT(call_function, call_function_single_exit,
+
+ TP_PROTO(unsigned int ignore),
+
+ TP_ARGS(ignore)
+);
+
#endif /* _TRACE_IRQ_H */

/* This part must be outside protection */
diff --git a/kernel/smp.c b/kernel/smp.c
index fb67dfa..3c4ce30 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -12,6 +12,7 @@
#include <linux/gfp.h>
#include <linux/smp.h>
#include <linux/cpu.h>
+#include <trace/events/irq.h>

#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
static struct {
@@ -172,6 +173,7 @@ void generic_smp_call_function_interrupt(void)
struct call_function_data *data;
int cpu = smp_processor_id();

+ trace_call_function_entry(0);
/*
* Shouldn't receive this interrupt on a cpu that is not yet online.
*/
@@ -240,6 +242,7 @@ void generic_smp_call_function_interrupt(void)
csd_unlock(&data->csd);
}

+ trace_call_function_exit(0);
}

/*
@@ -252,6 +255,7 @@ void generic_smp_call_function_single_interrupt(void)
unsigned int data_flags;
LIST_HEAD(list);

+ trace_call_function_single_entry(0);
/*
* Shouldn't receive this interrupt on a cpu that is not yet online.
*/
@@ -282,6 +286,7 @@ void generic_smp_call_function_single_interrupt(void)
if (data_flags & CSD_FLAG_LOCK)
csd_unlock(data);
}
+ trace_call_function_single_exit(0);
}

static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_single_data, csd_data);
--
1.7.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/