]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
tracing: add subsystem level to trace events
authorSteven Rostedt <srostedt@redhat.com>
Sat, 28 Feb 2009 02:33:02 +0000 (21:33 -0500)
committerSteven Rostedt <srostedt@redhat.com>
Sat, 28 Feb 2009 07:59:43 +0000 (02:59 -0500)
If a trace point header defines TRACE_SYSTEM, then it will add the
following trace points into that event system.

If include/trace/irq_event_types.h has:

 #define TRACE_SYSTEM irq

at the top and

 #undef TRACE_SYSTEM

at the bottom, then a directory "irq" will be created in the
/debug/tracing/events directory. Inside that directory will contain the
two trace points that are defined in include/trace/irq_event_types.h.

Only adding the above to irq and not to sched, we get:

 # ls /debug/tracing/events/
irq                     sched_process_exit  sched_signal_send  sched_wakeup_new
sched_kthread_stop      sched_process_fork  sched_switch
sched_kthread_stop_ret  sched_process_free  sched_wait_task
sched_migrate_task      sched_process_wait  sched_wakeup

 # ls /debug/tracing/events/irq
irq_handler_entry  irq_handler_exit

If we add #define TRACE_SYSTEM sched to the trace/sched_event_types.h
then the rest of the trace events will be put in a sched directory
within the events directory.

I've been playing with this idea of the subsystem for a while, but
recently Tom Zanussi posted some patches to lkml that included this
method. Tom's approach was clean and got me to finally put some effort
to clean up the event trace points.

Thanks to Tom Zanussi for demonstrating how nice the subsystem
method is.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/events.c
kernel/trace/trace_events.c
kernel/trace/trace_events.h

index 46e27ad2487ef4e52eec9cdf0a6708e490f1b34e..4e4e45860c58d2afc59a1f7e985d5cc1cbdd08da 100644 (file)
@@ -2,6 +2,10 @@
  * This is the place to register all trace points as events.
  */
 
+/* someday this needs to go in a generic header */
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
 #include <trace/trace_events.h>
 
 #include "trace_events.h"
index 3bcb9df93342db11769249fbb07248619cf9fa95..19332200c457409040f787c0df7e7ed06ead92c6 100644 (file)
@@ -345,11 +345,59 @@ static struct dentry *event_trace_events_dir(void)
        return d_events;
 }
 
+struct event_subsystem {
+       struct list_head        list;
+       const char              *name;
+       struct dentry           *entry;
+};
+
+static LIST_HEAD(event_subsystems);
+
+static struct dentry *
+event_subsystem_dir(const char *name, struct dentry *d_events)
+{
+       struct event_subsystem *system;
+
+       /* First see if we did not already create this dir */
+       list_for_each_entry(system, &event_subsystems, list) {
+               if (strcmp(system->name, name) == 0)
+                       return system->entry;
+       }
+
+       /* need to create new entry */
+       system = kmalloc(sizeof(*system), GFP_KERNEL);
+       if (!system) {
+               pr_warning("No memory to create event subsystem %s\n",
+                          name);
+               return d_events;
+       }
+
+       system->entry = debugfs_create_dir(name, d_events);
+       if (!system->entry) {
+               pr_warning("Could not create event subsystem %s\n",
+                          name);
+               kfree(system);
+               return d_events;
+       }
+
+       system->name = name;
+       list_add(&system->list, &event_subsystems);
+
+       return system->entry;
+}
+
 static int
 event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
 {
        struct dentry *entry;
 
+       /*
+        * If the trace point header did not define TRACE_SYSTEM
+        * then the system would be called "TRACE_SYSTEM".
+        */
+       if (strcmp(call->system, "TRACE_SYSTEM") != 0)
+               d_events = event_subsystem_dir(call->system, d_events);
+
        call->dir = debugfs_create_dir(call->name, d_events);
        if (!call->dir) {
                pr_warning("Could not create debugfs "
index deb95e5006c80e707ea8b32e71ab8832706feb04..b015d7b19878ac8caf037c2712e40725cea65bba 100644 (file)
@@ -7,6 +7,7 @@
 
 struct ftrace_event_call {
        char            *name;
+       char            *system;
        struct dentry   *dir;
        int             enabled;
        int             (*regfunc)(void);
@@ -44,6 +45,7 @@ static struct ftrace_event_call __used                                        \
 __attribute__((__aligned__(4)))                                                \
 __attribute__((section("_ftrace_events"))) event_##call = {            \
        .name                   = #call,                                \
+       .system                 = STR(TRACE_SYSTEM),                    \
        .regfunc                = ftrace_reg_event_##call,              \
        .unregfunc              = ftrace_unreg_event_##call,            \
 }