Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146024
b: refs/heads/master
c: d1b182a
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Apr 17, 2009
1 parent 7e30cec commit 0f44bf6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e6187007d6c365b551c69ea3df46f06fd1c8bd19
refs/heads/master: d1b182a8d49ed6416325b4e0a1cb0f17cd4e702a
5 changes: 5 additions & 0 deletions trunk/include/linux/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
size_t len, int cpu, int full);

struct trace_seq;

int ring_buffer_print_entry_header(struct trace_seq *s);
int ring_buffer_print_page_header(struct trace_seq *s);

enum ring_buffer_flags {
RB_FL_OVERWRITE = 1 << 0,
};
Expand Down
44 changes: 44 additions & 0 deletions trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@

#include "trace.h"

/*
* The ring buffer header is special. We must manually up keep it.
*/
int ring_buffer_print_entry_header(struct trace_seq *s)
{
int ret;

ret = trace_seq_printf(s, "\ttype : 2 bits\n");
ret = trace_seq_printf(s, "\tlen : 3 bits\n");
ret = trace_seq_printf(s, "\ttime_delta : 27 bits\n");
ret = trace_seq_printf(s, "\tarray : 32 bits\n");
ret = trace_seq_printf(s, "\n");
ret = trace_seq_printf(s, "\tpadding : type == %d\n",
RINGBUF_TYPE_PADDING);
ret = trace_seq_printf(s, "\ttime_extend : type == %d\n",
RINGBUF_TYPE_TIME_EXTEND);
ret = trace_seq_printf(s, "\tdata : type == %d\n",
RINGBUF_TYPE_DATA);

return ret;
}

/*
* The ring buffer is made up of a list of pages. A separate list of pages is
* allocated for each CPU. A writer may only write to a buffer that is
Expand Down Expand Up @@ -340,6 +362,28 @@ static inline int test_time_stamp(u64 delta)

#define BUF_PAGE_SIZE (PAGE_SIZE - BUF_PAGE_HDR_SIZE)

int ring_buffer_print_page_header(struct trace_seq *s)
{
struct buffer_data_page field;
int ret;

ret = trace_seq_printf(s, "\tfield: u64 timestamp;\t"
"offset:0;\tsize:%u;\n",
(unsigned int)sizeof(field.time_stamp));

ret = trace_seq_printf(s, "\tfield: local_t commit;\t"
"offset:%u;\tsize:%u;\n",
(unsigned int)offsetof(typeof(field), commit),
(unsigned int)sizeof(field.commit));

ret = trace_seq_printf(s, "\tfield: char data;\t"
"offset:%u;\tsize:%u;\n",
(unsigned int)offsetof(typeof(field), data),
(unsigned int)BUF_PAGE_SIZE);

return ret;
}

/*
* head_page == tail_page && head == tail then buffer is empty.
*/
Expand Down
38 changes: 38 additions & 0 deletions trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,30 @@ subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
return cnt;
}

static ssize_t
show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
{
int (*func)(struct trace_seq *s) = filp->private_data;
struct trace_seq *s;
int r;

if (*ppos)
return 0;

s = kmalloc(sizeof(*s), GFP_KERNEL);
if (!s)
return -ENOMEM;

trace_seq_init(s);

func(s);
r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);

kfree(s);

return r;
}

static const struct seq_operations show_event_seq_ops = {
.start = t_start,
.next = t_next,
Expand Down Expand Up @@ -667,6 +691,11 @@ static const struct file_operations ftrace_subsystem_filter_fops = {
.write = subsystem_filter_write,
};

static const struct file_operations ftrace_show_header_fops = {
.open = tracing_open_generic,
.read = show_header,
};

static struct dentry *event_trace_events_dir(void)
{
static struct dentry *d_tracer;
Expand Down Expand Up @@ -909,6 +938,15 @@ static __init int event_trace_init(void)
if (!d_events)
return 0;

/* ring buffer internal formats */
trace_create_file("header_page", 0444, d_events,
ring_buffer_print_page_header,
&ftrace_show_header_fops);

trace_create_file("header_event", 0444, d_events,
ring_buffer_print_entry_header,
&ftrace_show_header_fops);

for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
/* The linker may leave blanks */
if (!call->name)
Expand Down

0 comments on commit 0f44bf6

Please sign in to comment.