Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100529
b: refs/heads/master
c: 107bad8
h: refs/heads/master
i:
  100527: 7d6a6c4
v: v3
  • Loading branch information
Steven Rostedt authored and Thomas Gleixner committed May 23, 2008
1 parent 5a3747c commit 425206b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 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: 53d0aa773053ab18287781e25d52c5faf9e0e09e
refs/heads/master: 107bad8bef5ab2c3a3bff7648c18c9dc3abdc13b
38 changes: 31 additions & 7 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ struct tracer {
void (*init)(struct trace_array *tr);
void (*reset)(struct trace_array *tr);
void (*open)(struct trace_iterator *iter);
void (*pipe_open)(struct trace_iterator *iter);
void (*close)(struct trace_iterator *iter);
void (*start)(struct trace_iterator *iter);
void (*stop)(struct trace_iterator *iter);
ssize_t (*read)(struct trace_iterator *iter,
struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos);
void (*ctrl_update)(struct trace_array *tr);
#ifdef CONFIG_FTRACE_STARTUP_TEST
int (*selftest)(struct tracer *trace,
Expand All @@ -160,6 +164,7 @@ struct trace_seq {
struct trace_iterator {
struct trace_array *tr;
struct tracer *trace;
void *private;
long last_overrun[NR_CPUS];
long overrun[NR_CPUS];

Expand Down

0 comments on commit 425206b

Please sign in to comment.