aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-02-27 21:33:02 -0500
committerSteven Rostedt <srostedt@redhat.com>2009-02-28 02:59:43 -0500
commit6ecc2d1ca39177edb6fbdb7412948b0e9f409d02 (patch)
tree336a12a2f3db016f967717e1cb06e9171a239ce5 /kernel/trace/trace_events.c
parenteb594e45f6979cd10b18d87f7b3f02119e00a108 (diff)
tracing: add subsystem level to trace events
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>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 3bcb9df93342..19332200c457 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -345,11 +345,59 @@ static struct dentry *event_trace_events_dir(void)
345 return d_events; 345 return d_events;
346} 346}
347 347
348struct event_subsystem {
349 struct list_head list;
350 const char *name;
351 struct dentry *entry;
352};
353
354static LIST_HEAD(event_subsystems);
355
356static struct dentry *
357event_subsystem_dir(const char *name, struct dentry *d_events)
358{
359 struct event_subsystem *system;
360
361 /* First see if we did not already create this dir */
362 list_for_each_entry(system, &event_subsystems, list) {
363 if (strcmp(system->name, name) == 0)
364 return system->entry;
365 }
366
367 /* need to create new entry */
368 system = kmalloc(sizeof(*system), GFP_KERNEL);
369 if (!system) {
370 pr_warning("No memory to create event subsystem %s\n",
371 name);
372 return d_events;
373 }
374
375 system->entry = debugfs_create_dir(name, d_events);
376 if (!system->entry) {
377 pr_warning("Could not create event subsystem %s\n",
378 name);
379 kfree(system);
380 return d_events;
381 }
382
383 system->name = name;
384 list_add(&system->list, &event_subsystems);
385
386 return system->entry;
387}
388
348static int 389static int
349event_create_dir(struct ftrace_event_call *call, struct dentry *d_events) 390event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
350{ 391{
351 struct dentry *entry; 392 struct dentry *entry;
352 393
394 /*
395 * If the trace point header did not define TRACE_SYSTEM
396 * then the system would be called "TRACE_SYSTEM".
397 */
398 if (strcmp(call->system, "TRACE_SYSTEM") != 0)
399 d_events = event_subsystem_dir(call->system, d_events);
400
353 call->dir = debugfs_create_dir(call->name, d_events); 401 call->dir = debugfs_create_dir(call->name, d_events);
354 if (!call->dir) { 402 if (!call->dir) {
355 pr_warning("Could not create debugfs " 403 pr_warning("Could not create debugfs "