Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146026
b: refs/heads/master
c: 9ea21c1
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Apr 17, 2009
1 parent 88afbe7 commit 93604a8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 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: 69abe6a5d18a9394baa325bab8f57748b037c517
refs/heads/master: 9ea21c1ecdb35ecdcac5fd9d95f62a1f6a7ffec0
78 changes: 72 additions & 6 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ static __init void event_test_stuff(void)
* For every trace event defined, we will test each trace point separately,
* and then by groups, and finally all trace points.
*/
static __init int event_trace_self_tests(void)
static __init void event_trace_self_tests(void)
{
struct ftrace_event_call *call;
struct event_subsystem *system;
Expand Down Expand Up @@ -1071,7 +1071,7 @@ static __init int event_trace_self_tests(void)
sysname = kstrdup(system->name, GFP_KERNEL);
if (WARN_ON(!sysname)) {
pr_warning("Can't allocate memory, giving up!\n");
return 0;
return;
}
ret = ftrace_set_clr_event(sysname, 1);
kfree(sysname);
Expand All @@ -1086,7 +1086,7 @@ static __init int event_trace_self_tests(void)
sysname = kstrdup(system->name, GFP_KERNEL);
if (WARN_ON(!sysname)) {
pr_warning("Can't allocate memory, giving up!\n");
return 0;
return;
}
ret = ftrace_set_clr_event(sysname, 0);
kfree(sysname);
Expand All @@ -1106,14 +1106,14 @@ static __init int event_trace_self_tests(void)
sysname = kmalloc(4, GFP_KERNEL);
if (WARN_ON(!sysname)) {
pr_warning("Can't allocate memory, giving up!\n");
return 0;
return;
}
memcpy(sysname, "*:*", 4);
ret = ftrace_set_clr_event(sysname, 1);
if (WARN_ON_ONCE(ret)) {
kfree(sysname);
pr_warning("error enabling all events\n");
return 0;
return;
}

event_test_stuff();
Expand All @@ -1125,10 +1125,76 @@ static __init int event_trace_self_tests(void)

if (WARN_ON_ONCE(ret)) {
pr_warning("error disabling all events\n");
return 0;
return;
}

pr_cont("OK\n");
}

#ifdef CONFIG_FUNCTION_TRACER

static DEFINE_PER_CPU(atomic_t, test_event_disable);

static void
function_test_events_call(unsigned long ip, unsigned long parent_ip)
{
struct ring_buffer_event *event;
struct ftrace_entry *entry;
unsigned long flags;
long disabled;
int resched;
int cpu;
int pc;

pc = preempt_count();
resched = ftrace_preempt_disable();
cpu = raw_smp_processor_id();
disabled = atomic_inc_return(&per_cpu(test_event_disable, cpu));

if (disabled != 1)
goto out;

local_save_flags(flags);

event = trace_current_buffer_lock_reserve(TRACE_FN, sizeof(*entry),
flags, pc);
if (!event)
goto out;
entry = ring_buffer_event_data(event);
entry->ip = ip;
entry->parent_ip = parent_ip;

trace_current_buffer_unlock_commit(event, flags, pc);

out:
atomic_dec(&per_cpu(test_event_disable, cpu));
ftrace_preempt_enable(resched);
}

static struct ftrace_ops trace_ops __initdata =
{
.func = function_test_events_call,
};

static __init void event_trace_self_test_with_function(void)
{
register_ftrace_function(&trace_ops);
pr_info("Running tests again, along with the function tracer\n");
event_trace_self_tests();
unregister_ftrace_function(&trace_ops);
}
#else
static __init void event_trace_self_test_with_function(void)
{
}
#endif

static __init int event_trace_self_tests_init(void)
{

event_trace_self_tests();

event_trace_self_test_with_function();

return 0;
}
Expand Down

0 comments on commit 93604a8

Please sign in to comment.