aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-05-12 21:21:01 +0200
committerThomas Gleixner <tglx@linutronix.de>2008-05-23 21:56:29 +0200
commit107bad8bef5ab2c3a3bff7648c18c9dc3abdc13b (patch)
tree6a7767e093cf3439efb334f6222b9fd5e1d9eb25 /kernel/trace/trace.c
parentftrace: add logic to record overruns (diff)
downloadlinux-dev-107bad8bef5ab2c3a3bff7648c18c9dc3abdc13b.tar.xz
linux-dev-107bad8bef5ab2c3a3bff7648c18c9dc3abdc13b.zip
ftrace: add trace pipe header pluggin
This patch adds a method for open_pipe and open_read to the pluggins so that they can add a header to the trace pipe call. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index b9126ef46a9e..32f9106d612c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2307,11 +2307,15 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
if (!iter)
return -ENOMEM;
+ mutex_lock(&trace_types_lock);
iter->tr = &global_trace;
iter->trace = current_trace;
-
filp->private_data = iter;
+ if (iter->trace->pipe_open)
+ iter->trace->pipe_open(iter);
+ mutex_unlock(&trace_types_lock);
+
return 0;
}
@@ -2380,13 +2384,24 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
return cnt;
}
+ mutex_lock(&trace_types_lock);
+ if (iter->trace->read) {
+ ret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
+ if (ret) {
+ read = ret;
+ goto out;
+ }
+ }
+
trace_seq_reset(&iter->seq);
start = 0;
while (trace_empty(iter)) {
- if ((filp->f_flags & O_NONBLOCK))
- return -EAGAIN;
+ if ((filp->f_flags & O_NONBLOCK)) {
+ read = -EAGAIN;
+ goto out;
+ }
/*
* This is a make-shift waitqueue. The reason we don't use
@@ -2400,16 +2415,22 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
set_current_state(TASK_INTERRUPTIBLE);
iter->tr->waiter = current;
+ mutex_unlock(&trace_types_lock);
+
/* sleep for one second, and try again. */
schedule_timeout(HZ);
+ mutex_lock(&trace_types_lock);
+
iter->tr->waiter = NULL;
- if (signal_pending(current))
- return -EINTR;
+ if (signal_pending(current)) {
+ read = -EINTR;
+ goto out;
+ }
if (iter->trace != current_trace)
- return 0;
+ goto out;
/*
* We block until we read something and tracing is disabled.
@@ -2428,7 +2449,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
/* stop when tracing is finished */
if (trace_empty(iter))
- return 0;
+ goto out;
if (cnt >= PAGE_SIZE)
cnt = PAGE_SIZE - 1;
@@ -2518,6 +2539,9 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
if (ret)
read = -EFAULT;
+out:
+ mutex_unlock(&trace_types_lock);
+
return read;
}