aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/trace/events.c4
-rw-r--r--kernel/trace/trace_events.c48
-rw-r--r--kernel/trace/trace_events.h2
3 files changed, 54 insertions, 0 deletions
diff --git a/kernel/trace/events.c b/kernel/trace/events.c
index 46e27ad2487e..4e4e45860c58 100644
--- a/kernel/trace/events.c
+++ b/kernel/trace/events.c
@@ -2,6 +2,10 @@
2 * This is the place to register all trace points as events. 2 * This is the place to register all trace points as events.
3 */ 3 */
4 4
5/* someday this needs to go in a generic header */
6#define __STR(x) #x
7#define STR(x) __STR(x)
8
5#include <trace/trace_events.h> 9#include <trace/trace_events.h>
6 10
7#include "trace_events.h" 11#include "trace_events.h"
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 "
diff --git a/kernel/trace/trace_events.h b/kernel/trace/trace_events.h
index deb95e5006c8..b015d7b19878 100644
--- a/kernel/trace/trace_events.h
+++ b/kernel/trace/trace_events.h
@@ -7,6 +7,7 @@
7 7
8struct ftrace_event_call { 8struct ftrace_event_call {
9 char *name; 9 char *name;
10 char *system;
10 struct dentry *dir; 11 struct dentry *dir;
11 int enabled; 12 int enabled;
12 int (*regfunc)(void); 13 int (*regfunc)(void);
@@ -44,6 +45,7 @@ static struct ftrace_event_call __used \
44__attribute__((__aligned__(4))) \ 45__attribute__((__aligned__(4))) \
45__attribute__((section("_ftrace_events"))) event_##call = { \ 46__attribute__((section("_ftrace_events"))) event_##call = { \
46 .name = #call, \ 47 .name = #call, \
48 .system = STR(TRACE_SYSTEM), \
47 .regfunc = ftrace_reg_event_##call, \ 49 .regfunc = ftrace_reg_event_##call, \
48 .unregfunc = ftrace_unreg_event_##call, \ 50 .unregfunc = ftrace_unreg_event_##call, \
49} 51}