2008-05-13 03:20:42 +08:00
|
|
|
/*
|
|
|
|
* trace context switch
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Steven Rostedt <srostedt@redhat.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/ftrace.h>
|
2009-04-15 07:39:12 +08:00
|
|
|
#include <trace/events/sched.h>
|
2008-05-13 03:20:42 +08:00
|
|
|
|
|
|
|
#include "trace.h"
|
|
|
|
|
|
|
|
static struct trace_array *ctx_trace;
|
|
|
|
static int __read_mostly tracer_enabled;
|
2008-10-31 20:28:58 +08:00
|
|
|
static int sched_ref;
|
|
|
|
static DEFINE_MUTEX(sched_register_mutex);
|
2009-03-18 07:59:53 +08:00
|
|
|
static int sched_stopped;
|
2008-05-13 03:20:42 +08:00
|
|
|
|
2009-07-30 00:00:29 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
tracing_sched_switch_trace(struct trace_array *tr,
|
|
|
|
struct task_struct *prev,
|
|
|
|
struct task_struct *next,
|
|
|
|
unsigned long flags, int pc)
|
|
|
|
{
|
|
|
|
struct ftrace_event_call *call = &event_context_switch;
|
2009-09-03 02:17:06 +08:00
|
|
|
struct ring_buffer *buffer = tr->buffer;
|
2009-07-30 00:00:29 +08:00
|
|
|
struct ring_buffer_event *event;
|
|
|
|
struct ctx_switch_entry *entry;
|
|
|
|
|
2009-09-03 02:17:06 +08:00
|
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_CTX,
|
2009-07-30 00:00:29 +08:00
|
|
|
sizeof(*entry), flags, pc);
|
|
|
|
if (!event)
|
|
|
|
return;
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
|
|
entry->prev_pid = prev->pid;
|
|
|
|
entry->prev_prio = prev->prio;
|
|
|
|
entry->prev_state = prev->state;
|
|
|
|
entry->next_pid = next->pid;
|
|
|
|
entry->next_prio = next->prio;
|
|
|
|
entry->next_state = next->state;
|
|
|
|
entry->next_cpu = task_cpu(next);
|
|
|
|
|
2009-09-03 02:17:06 +08:00
|
|
|
if (!filter_check_discard(call, entry, buffer, event))
|
|
|
|
trace_buffer_unlock_commit(buffer, event, flags, pc);
|
2009-07-30 00:00:29 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:51 +08:00
|
|
|
static void
|
2008-07-19 00:16:17 +08:00
|
|
|
probe_sched_switch(struct rq *__rq, struct task_struct *prev,
|
2008-05-13 03:21:10 +08:00
|
|
|
struct task_struct *next)
|
2008-05-13 03:20:42 +08:00
|
|
|
{
|
|
|
|
struct trace_array_cpu *data;
|
|
|
|
unsigned long flags;
|
|
|
|
int cpu;
|
2008-10-02 01:14:09 +08:00
|
|
|
int pc;
|
2008-05-13 03:20:42 +08:00
|
|
|
|
2009-03-31 15:26:14 +08:00
|
|
|
if (unlikely(!sched_ref))
|
2008-07-19 00:16:17 +08:00
|
|
|
return;
|
|
|
|
|
2008-05-22 23:49:22 +08:00
|
|
|
tracing_record_cmdline(prev);
|
|
|
|
tracing_record_cmdline(next);
|
|
|
|
|
2009-03-31 15:26:14 +08:00
|
|
|
if (!tracer_enabled || sched_stopped)
|
2008-05-13 03:20:42 +08:00
|
|
|
return;
|
|
|
|
|
2008-10-02 01:14:09 +08:00
|
|
|
pc = preempt_count();
|
2008-05-13 03:20:44 +08:00
|
|
|
local_irq_save(flags);
|
2008-05-13 03:20:42 +08:00
|
|
|
cpu = raw_smp_processor_id();
|
2008-07-19 00:16:17 +08:00
|
|
|
data = ctx_trace->data[cpu];
|
2008-05-13 03:20:42 +08:00
|
|
|
|
2008-10-04 14:01:00 +08:00
|
|
|
if (likely(!atomic_read(&data->disabled)))
|
2009-02-05 14:13:37 +08:00
|
|
|
tracing_sched_switch_trace(ctx_trace, prev, next, flags, pc);
|
2008-05-13 03:20:42 +08:00
|
|
|
|
2008-05-13 03:20:44 +08:00
|
|
|
local_irq_restore(flags);
|
2008-05-13 03:20:42 +08:00
|
|
|
}
|
|
|
|
|
2009-07-30 00:00:29 +08:00
|
|
|
void
|
|
|
|
tracing_sched_wakeup_trace(struct trace_array *tr,
|
|
|
|
struct task_struct *wakee,
|
|
|
|
struct task_struct *curr,
|
|
|
|
unsigned long flags, int pc)
|
|
|
|
{
|
|
|
|
struct ftrace_event_call *call = &event_wakeup;
|
|
|
|
struct ring_buffer_event *event;
|
|
|
|
struct ctx_switch_entry *entry;
|
2009-09-03 02:17:06 +08:00
|
|
|
struct ring_buffer *buffer = tr->buffer;
|
2009-07-30 00:00:29 +08:00
|
|
|
|
2009-09-03 02:17:06 +08:00
|
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_WAKE,
|
2009-07-30 00:00:29 +08:00
|
|
|
sizeof(*entry), flags, pc);
|
|
|
|
if (!event)
|
|
|
|
return;
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
|
|
entry->prev_pid = curr->pid;
|
|
|
|
entry->prev_prio = curr->prio;
|
|
|
|
entry->prev_state = curr->state;
|
|
|
|
entry->next_pid = wakee->pid;
|
|
|
|
entry->next_prio = wakee->prio;
|
|
|
|
entry->next_state = wakee->state;
|
|
|
|
entry->next_cpu = task_cpu(wakee);
|
|
|
|
|
2009-09-03 02:17:06 +08:00
|
|
|
if (!filter_check_discard(call, entry, buffer, event))
|
|
|
|
ring_buffer_unlock_commit(buffer, event);
|
|
|
|
ftrace_trace_stack(tr->buffer, flags, 6, pc);
|
|
|
|
ftrace_trace_userstack(tr->buffer, flags, pc);
|
2009-07-30 00:00:29 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:52 +08:00
|
|
|
static void
|
2008-12-16 15:07:03 +08:00
|
|
|
probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success)
|
2008-05-13 03:20:51 +08:00
|
|
|
{
|
|
|
|
struct trace_array_cpu *data;
|
|
|
|
unsigned long flags;
|
2008-10-02 01:14:09 +08:00
|
|
|
int cpu, pc;
|
2008-05-13 03:20:51 +08:00
|
|
|
|
2009-03-31 15:26:14 +08:00
|
|
|
if (unlikely(!sched_ref))
|
2008-05-13 03:20:51 +08:00
|
|
|
return;
|
|
|
|
|
2008-07-19 00:16:17 +08:00
|
|
|
tracing_record_cmdline(current);
|
2008-05-13 03:20:53 +08:00
|
|
|
|
2009-03-31 15:26:14 +08:00
|
|
|
if (!tracer_enabled || sched_stopped)
|
2009-03-31 15:24:51 +08:00
|
|
|
return;
|
|
|
|
|
2009-03-31 15:26:14 +08:00
|
|
|
pc = preempt_count();
|
2008-05-13 03:20:51 +08:00
|
|
|
local_irq_save(flags);
|
|
|
|
cpu = raw_smp_processor_id();
|
2008-07-19 00:16:17 +08:00
|
|
|
data = ctx_trace->data[cpu];
|
2008-05-13 03:20:51 +08:00
|
|
|
|
2008-10-04 14:01:00 +08:00
|
|
|
if (likely(!atomic_read(&data->disabled)))
|
2009-02-05 14:13:37 +08:00
|
|
|
tracing_sched_wakeup_trace(ctx_trace, wakee, current,
|
2008-10-02 01:14:09 +08:00
|
|
|
flags, pc);
|
2008-05-13 03:20:51 +08:00
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:10 +08:00
|
|
|
static int tracing_sched_register(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2008-07-19 00:16:17 +08:00
|
|
|
ret = register_trace_sched_wakeup(probe_sched_wakeup);
|
2008-05-13 03:21:10 +08:00
|
|
|
if (ret) {
|
2008-07-19 00:16:17 +08:00
|
|
|
pr_info("wakeup trace: Couldn't activate tracepoint"
|
2008-05-13 03:21:10 +08:00
|
|
|
" probe to kernel_sched_wakeup\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-19 00:16:17 +08:00
|
|
|
ret = register_trace_sched_wakeup_new(probe_sched_wakeup);
|
2008-05-13 03:21:10 +08:00
|
|
|
if (ret) {
|
2008-07-19 00:16:17 +08:00
|
|
|
pr_info("wakeup trace: Couldn't activate tracepoint"
|
2008-05-13 03:21:10 +08:00
|
|
|
" probe to kernel_sched_wakeup_new\n");
|
|
|
|
goto fail_deprobe;
|
|
|
|
}
|
|
|
|
|
2008-07-19 00:16:17 +08:00
|
|
|
ret = register_trace_sched_switch(probe_sched_switch);
|
2008-05-13 03:21:10 +08:00
|
|
|
if (ret) {
|
2008-07-19 00:16:17 +08:00
|
|
|
pr_info("sched trace: Couldn't activate tracepoint"
|
2009-02-17 14:10:02 +08:00
|
|
|
" probe to kernel_sched_switch\n");
|
2008-05-13 03:21:10 +08:00
|
|
|
goto fail_deprobe_wake_new;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
fail_deprobe_wake_new:
|
2008-07-19 00:16:17 +08:00
|
|
|
unregister_trace_sched_wakeup_new(probe_sched_wakeup);
|
2008-05-13 03:21:10 +08:00
|
|
|
fail_deprobe:
|
2008-07-19 00:16:17 +08:00
|
|
|
unregister_trace_sched_wakeup(probe_sched_wakeup);
|
2008-05-13 03:21:10 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tracing_sched_unregister(void)
|
|
|
|
{
|
2008-07-19 00:16:17 +08:00
|
|
|
unregister_trace_sched_switch(probe_sched_switch);
|
|
|
|
unregister_trace_sched_wakeup_new(probe_sched_wakeup);
|
|
|
|
unregister_trace_sched_wakeup(probe_sched_wakeup);
|
2008-05-13 03:21:10 +08:00
|
|
|
}
|
|
|
|
|
2008-05-22 16:37:48 +08:00
|
|
|
static void tracing_start_sched_switch(void)
|
2008-05-13 03:21:10 +08:00
|
|
|
{
|
2008-10-31 20:28:58 +08:00
|
|
|
mutex_lock(&sched_register_mutex);
|
2008-11-08 11:36:02 +08:00
|
|
|
if (!(sched_ref++))
|
2008-05-13 03:21:10 +08:00
|
|
|
tracing_sched_register();
|
2008-10-31 20:28:58 +08:00
|
|
|
mutex_unlock(&sched_register_mutex);
|
2008-05-13 03:21:10 +08:00
|
|
|
}
|
|
|
|
|
2008-05-22 16:37:48 +08:00
|
|
|
static void tracing_stop_sched_switch(void)
|
2008-05-13 03:21:10 +08:00
|
|
|
{
|
2008-10-31 20:28:58 +08:00
|
|
|
mutex_lock(&sched_register_mutex);
|
2008-11-08 11:36:02 +08:00
|
|
|
if (!(--sched_ref))
|
2008-05-13 03:21:10 +08:00
|
|
|
tracing_sched_unregister();
|
2008-10-31 20:28:58 +08:00
|
|
|
mutex_unlock(&sched_register_mutex);
|
2008-05-13 03:21:10 +08:00
|
|
|
}
|
|
|
|
|
2008-05-22 23:49:22 +08:00
|
|
|
void tracing_start_cmdline_record(void)
|
|
|
|
{
|
|
|
|
tracing_start_sched_switch();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tracing_stop_cmdline_record(void)
|
|
|
|
{
|
|
|
|
tracing_stop_sched_switch();
|
|
|
|
}
|
|
|
|
|
2008-11-08 11:36:02 +08:00
|
|
|
/**
|
2008-11-08 11:36:02 +08:00
|
|
|
* tracing_start_sched_switch_record - start tracing context switches
|
|
|
|
*
|
|
|
|
* Turns on context switch tracing for a tracer.
|
|
|
|
*/
|
|
|
|
void tracing_start_sched_switch_record(void)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx_trace)) {
|
|
|
|
WARN_ON(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tracing_start_sched_switch();
|
|
|
|
|
|
|
|
mutex_lock(&sched_register_mutex);
|
|
|
|
tracer_enabled++;
|
|
|
|
mutex_unlock(&sched_register_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tracing_stop_sched_switch_record - start tracing context switches
|
|
|
|
*
|
|
|
|
* Turns off context switch tracing for a tracer.
|
|
|
|
*/
|
|
|
|
void tracing_stop_sched_switch_record(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&sched_register_mutex);
|
|
|
|
tracer_enabled--;
|
|
|
|
WARN_ON(tracer_enabled < 0);
|
|
|
|
mutex_unlock(&sched_register_mutex);
|
|
|
|
|
|
|
|
tracing_stop_sched_switch();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tracing_sched_switch_assign_trace - assign a trace array for ctx switch
|
2008-11-08 11:36:02 +08:00
|
|
|
* @tr: trace array pointer to assign
|
|
|
|
*
|
|
|
|
* Some tracers might want to record the context switches in their
|
|
|
|
* trace. This function lets those tracers assign the trace array
|
|
|
|
* to use.
|
|
|
|
*/
|
2008-11-08 11:36:02 +08:00
|
|
|
void tracing_sched_switch_assign_trace(struct trace_array *tr)
|
2008-11-08 11:36:02 +08:00
|
|
|
{
|
|
|
|
ctx_trace = tr;
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:51 +08:00
|
|
|
static void stop_sched_trace(struct trace_array *tr)
|
2008-05-13 03:20:42 +08:00
|
|
|
{
|
2008-11-08 11:36:02 +08:00
|
|
|
tracing_stop_sched_switch_record();
|
2008-05-13 03:20:42 +08:00
|
|
|
}
|
|
|
|
|
2008-11-16 12:57:26 +08:00
|
|
|
static int sched_switch_trace_init(struct trace_array *tr)
|
2008-05-13 03:20:42 +08:00
|
|
|
{
|
|
|
|
ctx_trace = tr;
|
2009-03-18 07:59:53 +08:00
|
|
|
tracing_reset_online_cpus(tr);
|
2009-02-06 04:02:00 +08:00
|
|
|
tracing_start_sched_switch_record();
|
2008-11-16 12:57:26 +08:00
|
|
|
return 0;
|
2008-05-13 03:20:42 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:51 +08:00
|
|
|
static void sched_switch_trace_reset(struct trace_array *tr)
|
2008-05-13 03:20:42 +08:00
|
|
|
{
|
2008-11-08 11:36:02 +08:00
|
|
|
if (sched_ref)
|
2008-05-13 03:20:42 +08:00
|
|
|
stop_sched_trace(tr);
|
|
|
|
}
|
|
|
|
|
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>
2008-11-06 05:05:44 +08:00
|
|
|
static void sched_switch_trace_start(struct trace_array *tr)
|
|
|
|
{
|
2009-03-18 07:59:53 +08:00
|
|
|
sched_stopped = 0;
|
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>
2008-11-06 05:05:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sched_switch_trace_stop(struct trace_array *tr)
|
|
|
|
{
|
2009-03-18 07:59:53 +08:00
|
|
|
sched_stopped = 1;
|
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>
2008-11-06 05:05:44 +08:00
|
|
|
}
|
|
|
|
|
2008-11-08 11:36:02 +08:00
|
|
|
static struct tracer sched_switch_trace __read_mostly =
|
2008-05-13 03:20:42 +08:00
|
|
|
{
|
|
|
|
.name = "sched_switch",
|
|
|
|
.init = sched_switch_trace_init,
|
|
|
|
.reset = sched_switch_trace_reset,
|
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>
2008-11-06 05:05:44 +08:00
|
|
|
.start = sched_switch_trace_start,
|
|
|
|
.stop = sched_switch_trace_stop,
|
2009-02-11 09:25:00 +08:00
|
|
|
.wait_pipe = poll_wait_pipe,
|
2008-05-13 03:20:44 +08:00
|
|
|
#ifdef CONFIG_FTRACE_SELFTEST
|
|
|
|
.selftest = trace_selftest_startup_sched_switch,
|
|
|
|
#endif
|
2008-05-13 03:20:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
__init static int init_sched_switch_trace(void)
|
|
|
|
{
|
|
|
|
return register_tracer(&sched_switch_trace);
|
|
|
|
}
|
|
|
|
device_initcall(init_sched_switch_trace);
|
2008-12-19 08:09:51 +08:00
|
|
|
|