Skip to content

Commit

Permalink
tracing/fastboot: use sched switch tracer from boot tracer
Browse files Browse the repository at this point in the history
Impact: enhance boot trace output with scheduling events

Use the sched_switch tracer from the boot tracer.

We also can trace schedule events inside the initcalls.
Sched tracing is disabled after the initcall has finished and
then reenabled before the next one is started.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Nov 4, 2008
1 parent e55f605 commit d7ad44b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3251,6 +3251,8 @@ __init static int tracer_alloc_buffers(void)

register_tracer(&nop_trace);
#ifdef CONFIG_BOOT_TRACER
/* We don't want to launch sched_switch tracer yet */
global_trace.ctrl = 0;
register_tracer(&boot_tracer);
current_trace = &boot_tracer;
current_trace->init(&global_trace);
Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ftrace_entry {
unsigned long parent_ip;
};
extern struct tracer boot_tracer;
extern struct tracer sched_switch_trace; /* Used by the boot tracer */

/*
* Context switch trace entry - which task (and prio) we switched from/to:
Expand Down
6 changes: 6 additions & 0 deletions kernel/trace/trace_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ void start_boot_trace(void)

void enable_boot_trace(void)
{
if (pre_initcalls_finished)
tracing_start_cmdline_record();
}

void disable_boot_trace(void)
{
if (pre_initcalls_finished)
tracing_stop_cmdline_record();
}

void reset_boot_trace(struct trace_array *tr)
Expand All @@ -45,6 +49,8 @@ static void boot_trace_init(struct trace_array *tr)

for_each_cpu_mask(cpu, cpu_possible_map)
tracing_reset(tr, cpu);

sched_switch_trace.init(tr);
}

static void boot_trace_ctrl_update(struct trace_array *tr)
Expand Down
6 changes: 3 additions & 3 deletions kernel/trace/trace_sched_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static void tracing_start_sched_switch(void)
long ref;

mutex_lock(&tracepoint_mutex);
tracer_enabled = 1;
ref = atomic_inc_return(&sched_ref);
if (ref == 1)
tracing_sched_register();
Expand All @@ -138,6 +139,7 @@ static void tracing_stop_sched_switch(void)
long ref;

mutex_lock(&tracepoint_mutex);
tracer_enabled = 0;
ref = atomic_dec_and_test(&sched_ref);
if (ref)
tracing_sched_unregister();
Expand All @@ -158,12 +160,10 @@ static void start_sched_trace(struct trace_array *tr)
{
sched_switch_reset(tr);
tracing_start_cmdline_record();
tracer_enabled = 1;
}

static void stop_sched_trace(struct trace_array *tr)
{
tracer_enabled = 0;
tracing_stop_cmdline_record();
}

Expand All @@ -190,7 +190,7 @@ static void sched_switch_trace_ctrl_update(struct trace_array *tr)
stop_sched_trace(tr);
}

static struct tracer sched_switch_trace __read_mostly =
struct tracer sched_switch_trace __read_mostly =
{
.name = "sched_switch",
.init = sched_switch_trace_init,
Expand Down

0 comments on commit d7ad44b

Please sign in to comment.