lkml.org 
[lkml]   [2010]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 01/11] tracing: Add lock_class_init event
Date
Add a lock_class_init event that brings informations about a
new lock class that gets created.

This event is required for the following plans:

- We want to get rid of the lock name copy from each high freq
lock events.
- But we want to be able to retrieve it from post-processing
- We also want to be able to map the lock instances to their
corresponding lock classes. Instrumenting the locks can
make sense in both class and instance level, depending on
the desired level of details.

This new event will make us able to map a lock class to its name.
It is also planned to drop the name from the other lock events
but to keep the lock instance id and to add the lock class id
to the lock_acquire event (which marks the beginning of a lock
scenario).

With such layout, we can basically retrieve the lock instance,
class and name from every locking sequence.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
---
include/trace/events/lock.h | 24 ++++++++++++++++++++++++
kernel/lockdep.c | 4 ++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/lock.h b/include/trace/events/lock.h
index 5c1dcfc..90af03c 100644
--- a/include/trace/events/lock.h
+++ b/include/trace/events/lock.h
@@ -9,6 +9,30 @@

#ifdef CONFIG_LOCKDEP

+TRACE_EVENT(lock_class_init,
+
+ TP_PROTO(struct lock_class *class),
+
+ TP_ARGS(class),
+
+ TP_STRUCT__entry(
+ __string(class_name, class->name)
+ __field(void *, class_id)
+ ),
+
+ /*
+ * The pointer to the class name is shared between a lock instance
+ * (lockdep_map) and its lock class. So we can use the name pointer
+ * as a class id and as a link between an instance and its class.
+ */
+ TP_fast_assign(
+ __assign_str(class_name, class->name);
+ __entry->class_id = (void *)class->name;
+ ),
+
+ TP_printk("%p %s", __entry->class_id, __get_str(class_name))
+);
+
TRACE_EVENT(lock_acquire,

TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 5feaddc..43758dd 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -757,6 +757,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
dump_stack();
return NULL;
}
+
class = lock_classes + nr_lock_classes++;
debug_atomic_inc(&nr_unused_locks);
class->key = key;
@@ -766,6 +767,9 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
INIT_LIST_HEAD(&class->locks_before);
INIT_LIST_HEAD(&class->locks_after);
class->name_version = count_matching_names(class);
+
+ trace_lock_class_init(class);
+
/*
* We use RCU's safe list-add method to make
* parallel walking of the hash-list safe:
--
1.6.2.3


\
 
 \ /
  Last update: 2010-02-03 10:17    [W:0.211 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site