Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323911
b: refs/heads/master
c: 1d787d3
h: refs/heads/master
i:
  323909: 7fb4010
  323907: 2977ff8
  323903: 3e3cd6c
v: v3
  • Loading branch information
Ingo Molnar committed Sep 28, 2012
1 parent 2fdb28a commit c34b61b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aec1930b0f6f281a0ca038cd03aceace3fe0bb61
refs/heads/master: 1d787d37c8ff6612b8151c6dff15bfa7347bcbdf
6 changes: 5 additions & 1 deletion trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME |
TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE |
TRACE_ITER_IRQ_INFO;
TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS;

static int trace_stop_count;
static DEFINE_RAW_SPINLOCK(tracing_start_lock);
Expand Down Expand Up @@ -470,6 +470,7 @@ static const char *trace_options[] = {
"overwrite",
"disable_on_free",
"irq-info",
"markers",
NULL
};

Expand Down Expand Up @@ -3886,6 +3887,9 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
if (tracing_disabled)
return -EINVAL;

if (!(trace_flags & TRACE_ITER_MARKERS))
return -EINVAL;

if (cnt > TRACE_BUF_SIZE)
cnt = TRACE_BUF_SIZE;

Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ enum trace_iterator_flags {
TRACE_ITER_OVERWRITE = 0x200000,
TRACE_ITER_STOP_ON_FREE = 0x400000,
TRACE_ITER_IRQ_INFO = 0x800000,
TRACE_ITER_MARKERS = 0x1000000,
};

/*
Expand Down
108 changes: 72 additions & 36 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,31 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
return 0;
}

static void event_remove(struct ftrace_event_call *call)
{
ftrace_event_enable_disable(call, 0);
if (call->event.funcs)
__unregister_ftrace_event(&call->event);
list_del(&call->list);
}

static int event_init(struct ftrace_event_call *call)
{
int ret = 0;

if (WARN_ON(!call->name))
return -EINVAL;

if (call->class->raw_init) {
ret = call->class->raw_init(call);
if (ret < 0 && ret != -ENOSYS)
pr_warn("Could not initialize trace events/%s\n",
call->name);
}

return ret;
}

static int
__trace_add_event_call(struct ftrace_event_call *call, struct module *mod,
const struct file_operations *id,
Expand All @@ -1209,19 +1234,9 @@ __trace_add_event_call(struct ftrace_event_call *call, struct module *mod,
struct dentry *d_events;
int ret;

/* The linker may leave blanks */
if (!call->name)
return -EINVAL;

if (call->class->raw_init) {
ret = call->class->raw_init(call);
if (ret < 0) {
if (ret != -ENOSYS)
pr_warning("Could not initialize trace events/%s\n",
call->name);
return ret;
}
}
ret = event_init(call);
if (ret < 0)
return ret;

d_events = event_trace_events_dir();
if (!d_events)
Expand Down Expand Up @@ -1272,13 +1287,10 @@ static void remove_subsystem_dir(const char *name)
*/
static void __trace_remove_event_call(struct ftrace_event_call *call)
{
ftrace_event_enable_disable(call, 0);
if (call->event.funcs)
__unregister_ftrace_event(&call->event);
debugfs_remove_recursive(call->dir);
list_del(&call->list);
event_remove(call);
trace_destroy_fields(call);
destroy_preds(call);
debugfs_remove_recursive(call->dir);
remove_subsystem_dir(call->class->system);
}

Expand Down Expand Up @@ -1450,15 +1462,43 @@ static __init int setup_trace_event(char *str)
}
__setup("trace_event=", setup_trace_event);

static __init int event_trace_enable(void)
{
struct ftrace_event_call **iter, *call;
char *buf = bootup_event_buf;
char *token;
int ret;

for_each_event(iter, __start_ftrace_events, __stop_ftrace_events) {

call = *iter;
ret = event_init(call);
if (!ret)
list_add(&call->list, &ftrace_events);
}

while (true) {
token = strsep(&buf, ",");

if (!token)
break;
if (!*token)
continue;

ret = ftrace_set_clr_event(token, 1);
if (ret)
pr_warn("Failed to enable trace event: %s\n", token);
}
return 0;
}

static __init int event_trace_init(void)
{
struct ftrace_event_call **call;
struct ftrace_event_call *call;
struct dentry *d_tracer;
struct dentry *entry;
struct dentry *d_events;
int ret;
char *buf = bootup_event_buf;
char *token;

d_tracer = tracing_init_dentry();
if (!d_tracer)
Expand Down Expand Up @@ -1497,24 +1537,19 @@ static __init int event_trace_init(void)
if (trace_define_common_fields())
pr_warning("tracing: Failed to allocate common fields");

for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
__trace_add_event_call(*call, NULL, &ftrace_event_id_fops,
/*
* Early initialization already enabled ftrace event.
* Now it's only necessary to create the event directory.
*/
list_for_each_entry(call, &ftrace_events, list) {

ret = event_create_dir(call, d_events,
&ftrace_event_id_fops,
&ftrace_enable_fops,
&ftrace_event_filter_fops,
&ftrace_event_format_fops);
}

while (true) {
token = strsep(&buf, ",");

if (!token)
break;
if (!*token)
continue;

ret = ftrace_set_clr_event(token, 1);
if (ret)
pr_warning("Failed to enable trace event: %s\n", token);
if (ret < 0)
event_remove(call);
}

ret = register_module_notifier(&trace_module_nb);
Expand All @@ -1523,6 +1558,7 @@ static __init int event_trace_init(void)

return 0;
}
core_initcall(event_trace_enable);
fs_initcall(event_trace_init);

#ifdef CONFIG_FTRACE_STARTUP_TEST
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/trace/trace_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ int __init init_ftrace_syscalls(void)

return 0;
}
core_initcall(init_ftrace_syscalls);
early_initcall(init_ftrace_syscalls);

#ifdef CONFIG_PERF_EVENTS

Expand Down

0 comments on commit c34b61b

Please sign in to comment.