Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175445
b: refs/heads/master
c: a63ce5b
h: refs/heads/master
i:
  175443: 76306e7
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Dec 9, 2009
1 parent 3a0fe8b commit 9094b39
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 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: 29bf4a5e3fed3dde3eb629a0cb1762c1e9217458
refs/heads/master: a63ce5b306855bccdacba95c03bfc293316c8ae3
1 change: 1 addition & 0 deletions trunk/include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct trace_iterator {
/* The below is zeroed out in pipe_read */
struct trace_seq seq;
struct trace_entry *ent;
int leftover;
int cpu;
u64 ts;

Expand Down
5 changes: 3 additions & 2 deletions trunk/include/linux/trace_seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
__attribute__ ((format (printf, 2, 0)));
extern int
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary);
extern void trace_print_seq(struct seq_file *m, struct trace_seq *s);
extern int trace_print_seq(struct seq_file *m, struct trace_seq *s);
extern ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
size_t cnt);
extern int trace_seq_puts(struct trace_seq *s, const char *str);
Expand All @@ -55,8 +55,9 @@ trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
return 0;
}

static inline void trace_print_seq(struct seq_file *m, struct trace_seq *s)
static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
{
return 0;
}
static inline ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf,
size_t cnt)
Expand Down
35 changes: 32 additions & 3 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,8 @@ static void *s_next(struct seq_file *m, void *v, loff_t *pos)
int i = (int)*pos;
void *ent;

WARN_ON_ONCE(iter->leftover);

(*pos)++;

/* can't go backwards */
Expand Down Expand Up @@ -1614,8 +1616,16 @@ static void *s_start(struct seq_file *m, loff_t *pos)
;

} else {
l = *pos - 1;
p = s_next(m, p, &l);
/*
* If we overflowed the seq_file before, then we want
* to just reuse the trace_seq buffer again.
*/
if (iter->leftover)
p = iter;
else {
l = *pos - 1;
p = s_next(m, p, &l);
}
}

trace_event_read_lock();
Expand Down Expand Up @@ -1923,6 +1933,7 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
static int s_show(struct seq_file *m, void *v)
{
struct trace_iterator *iter = v;
int ret;

if (iter->ent == NULL) {
if (iter->tr) {
Expand All @@ -1942,9 +1953,27 @@ static int s_show(struct seq_file *m, void *v)
if (!(trace_flags & TRACE_ITER_VERBOSE))
print_func_help_header(m);
}
} else if (iter->leftover) {
/*
* If we filled the seq_file buffer earlier, we
* want to just show it now.
*/
ret = trace_print_seq(m, &iter->seq);

/* ret should this time be zero, but you never know */
iter->leftover = ret;

} else {
print_trace_line(iter);
trace_print_seq(m, &iter->seq);
ret = trace_print_seq(m, &iter->seq);
/*
* If we overflow the seq_file buffer, then it will
* ask us for this data again at start up.
* Use that instead.
* ret is 0 if seq_file write succeeded.
* -1 otherwise.
*/
iter->leftover = ret;
}

return 0;
Expand Down
14 changes: 11 additions & 3 deletions trunk/kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;

static int next_event_type = __TRACE_LAST_TYPE + 1;

void trace_print_seq(struct seq_file *m, struct trace_seq *s)
int trace_print_seq(struct seq_file *m, struct trace_seq *s)
{
int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len;
int ret;

ret = seq_write(m, s->buffer, len);

seq_write(m, s->buffer, len);
/*
* Only reset this buffer if we successfully wrote to the
* seq_file buffer.
*/
if (!ret)
trace_seq_init(s);

trace_seq_init(s);
return ret;
}

enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter)
Expand Down

0 comments on commit 9094b39

Please sign in to comment.