[PATCH 03/11] tracing: Inject lock_class_init events on registration

From: Frederic Weisbecker
Date: Wed Feb 03 2010 - 04:14:53 EST


When a user enables the lock_class_init event, automatically
inject the existing mapping of lock_class_id:name that
lockdep have stored.

This will help the user to retrieve the name of the lock
classes from the other lock events, once we'll remove
the name inside.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Hitoshi Mitake <mitake@xxxxxxxxxxxxxxxxxxxxx>
Cc: Li Zefan <lizf@xxxxxxxxxxxxxx>
Cc: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Jens Axboe <jens.axboe@xxxxxxxxxx>
---
include/linux/lockdep.h | 4 ++++
include/trace/events/lock.h | 11 +++++++++--
kernel/lockdep.c | 12 ++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 9ccf0e2..0b662fc 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -323,6 +323,10 @@ extern void lockdep_trace_alloc(gfp_t mask);

#define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(l))

+#ifdef CONFIG_EVENT_TRACING
+extern void lock_class_init_inject_events(void);
+#endif
+
#else /* !LOCKDEP */

static inline void lockdep_off(void)
diff --git a/include/trace/events/lock.h b/include/trace/events/lock.h
index 90af03c..6999f16 100644
--- a/include/trace/events/lock.h
+++ b/include/trace/events/lock.h
@@ -9,7 +9,7 @@

#ifdef CONFIG_LOCKDEP

-TRACE_EVENT(lock_class_init,
+TRACE_EVENT_INJECT(lock_class_init,

TP_PROTO(struct lock_class *class),

@@ -30,7 +30,14 @@ TRACE_EVENT(lock_class_init,
__entry->class_id = (void *)class->name;
),

- TP_printk("%p %s", __entry->class_id, __get_str(class_name))
+ TP_printk("%p %s", __entry->class_id, __get_str(class_name)),
+
+ /*
+ * On activation, we want to send an event for each lock
+ * classes that have been recorded by lockdep, so that we
+ * catch up with the existing class:name mappings.
+ */
+ lock_class_init_inject_events
);

TRACE_EVENT(lock_acquire,
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 43758dd..4d9eef8 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -3813,3 +3813,15 @@ void lockdep_sys_exit(void)
lockdep_print_held_locks(curr);
}
}
+
+
+#ifdef CONFIG_EVENT_TRACING
+void lock_class_init_inject_events(void)
+{
+ struct lock_class *class;
+
+ /* Safe to be taken locklessly as it only moves forward */
+ list_for_each_entry(class, &all_lock_classes, lock_entry)
+ trace_lock_class_init(class);
+}
+#endif
--
1.6.2.3

--
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/