diff options
author | Steven Rostedt <srostedt@redhat.com> | 2008-11-05 16:05:44 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-06 01:51:03 -0500 |
commit | 9036990d462e09366f7297a2d1da6582c3e6b1d3 (patch) | |
tree | e110393aad12177cb17fa68cb3fefb18ae2f1037 /kernel/trace/trace_sched_switch.c | |
parent | 0f04870148ecb825133bc2733f473b1c5773ac0b (diff) |
ftrace: restructure tracing start/stop infrastructure
Impact: change where tracing is started up and stopped
Currently, when a new tracer is selected via echo'ing a tracer name into
the current_tracer file, the startup is only done if tracing_enabled is
set to one. If tracing_enabled is changed to zero (by echo'ing 0 into
the tracing_enabled file) a full shutdown is performed.
The full startup and shutdown of a tracer can be expensive and the
user can lose out traces when echo'ing in 0 to the tracing_enabled file,
because the process takes too long. There can also be places that
the user would like to start and stop the tracer several times and
doing the full startup and shutdown of a tracer might be too expensive.
This patch performs the full startup and shutdown when a tracer is
selected. It also adds a way to do a quick start or stop of a tracer.
The quick version is just a flag that prevents the tracing from
taking place, but the overhead of the code is still there.
For example, the startup of a tracer may enable tracepoints, or enable
the function tracer. The stop and start will just set a flag to
have the tracer ignore the calls when the tracepoint or function trace
is called. The overhead of the tracer may still be present when
the tracer is stopped, but no tracing will occur. Setting the tracer
to the 'nop' tracer (or any other tracer) will perform the shutdown
of the tracer which will disable the tracepoint or disable the
function tracer.
The tracing_enabled file will simply start or stop tracing.
This change is all internal. The end result for the user should be the same
as before. If tracing_enabled is not set, no trace will happen.
If tracing_enabled is set, then the trace will happen. The tracing_enabled
variable is static between tracers. Enabling tracing_enabled and
going to another tracer will keep tracing_enabled enabled. Same
is true with disabling tracing_enabled.
This patch will now provide a fast start/stop method to the users
for enabling or disabling tracing.
Note: There were two methods to the struct tracer that were never
used: The methods start and stop. These were to be used as a hook
to the reading of the trace output, but ended up not being
necessary. These two methods are now used to enable the start
and stop of each tracer, in case the tracer needs to do more than
just not write into the buffer. For example, the irqsoff tracer
must stop recording max latencies when tracing is stopped.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_sched_switch.c')
-rw-r--r-- | kernel/trace/trace_sched_switch.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c index 888944d3409..91c699be8c8 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c | |||
@@ -186,11 +186,24 @@ static void sched_switch_trace_ctrl_update(struct trace_array *tr) | |||
186 | stop_sched_trace(tr); | 186 | stop_sched_trace(tr); |
187 | } | 187 | } |
188 | 188 | ||
189 | static void sched_switch_trace_start(struct trace_array *tr) | ||
190 | { | ||
191 | sched_switch_reset(tr); | ||
192 | tracing_start_sched_switch(); | ||
193 | } | ||
194 | |||
195 | static void sched_switch_trace_stop(struct trace_array *tr) | ||
196 | { | ||
197 | tracing_stop_sched_switch(); | ||
198 | } | ||
199 | |||
189 | struct tracer sched_switch_trace __read_mostly = | 200 | struct tracer sched_switch_trace __read_mostly = |
190 | { | 201 | { |
191 | .name = "sched_switch", | 202 | .name = "sched_switch", |
192 | .init = sched_switch_trace_init, | 203 | .init = sched_switch_trace_init, |
193 | .reset = sched_switch_trace_reset, | 204 | .reset = sched_switch_trace_reset, |
205 | .start = sched_switch_trace_start, | ||
206 | .stop = sched_switch_trace_stop, | ||
194 | .ctrl_update = sched_switch_trace_ctrl_update, | 207 | .ctrl_update = sched_switch_trace_ctrl_update, |
195 | #ifdef CONFIG_FTRACE_SELFTEST | 208 | #ifdef CONFIG_FTRACE_SELFTEST |
196 | .selftest = trace_selftest_startup_sched_switch, | 209 | .selftest = trace_selftest_startup_sched_switch, |