mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
tracing: infrastructure for supporting binary record
Impact: save on memory for tracing Current tracers are typically using a struct(like struct ftrace_entry, struct ctx_switch_entry, struct special_entr etc...)to record a binary event. These structs can only record a their own kind of events. A new kind of tracer need a new struct and a lot of code too handle it. So we need a generic binary record for events. This infrastructure is for this purpose. [fweisbec@gmail.com: rebase against latest -tip, make it safe while sched tracing as reported by Steven Rostedt] Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <1236356510-8381-3-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
546e5354a6
commit
1427cdf059
7 changed files with 240 additions and 0 deletions
|
@ -53,6 +53,26 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
|
|||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
|
||||
{
|
||||
int len = (PAGE_SIZE - 1) - s->len;
|
||||
int ret;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
|
||||
|
||||
/* If we can't write it all, don't bother writing anything */
|
||||
if (ret >= len)
|
||||
return 0;
|
||||
|
||||
s->len += ret;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* trace_seq_puts - trace sequence printing of simple string
|
||||
* @s: trace sequence descriptor
|
||||
|
@ -855,6 +875,60 @@ static struct trace_event trace_print_event = {
|
|||
.raw = trace_print_raw,
|
||||
};
|
||||
|
||||
/* TRACE_BPRINTK */
|
||||
static enum print_line_t
|
||||
trace_bprintk_print(struct trace_iterator *iter, int flags)
|
||||
{
|
||||
struct trace_entry *entry = iter->ent;
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct bprintk_entry *field;
|
||||
|
||||
trace_assign_type(field, entry);
|
||||
|
||||
if (!seq_print_ip_sym(s, field->ip, flags))
|
||||
goto partial;
|
||||
|
||||
if (!trace_seq_puts(s, ": "))
|
||||
goto partial;
|
||||
|
||||
if (!trace_seq_bprintf(s, field->fmt, field->buf))
|
||||
goto partial;
|
||||
|
||||
return TRACE_TYPE_HANDLED;
|
||||
|
||||
partial:
|
||||
return TRACE_TYPE_PARTIAL_LINE;
|
||||
}
|
||||
|
||||
static enum print_line_t
|
||||
trace_bprintk_raw(struct trace_iterator *iter, int flags)
|
||||
{
|
||||
struct trace_entry *entry = iter->ent;
|
||||
struct trace_seq *s = &iter->seq;
|
||||
struct bprintk_entry *field;
|
||||
|
||||
trace_assign_type(field, entry);
|
||||
|
||||
if (!trace_seq_printf(s, ": %lx : ", field->ip))
|
||||
goto partial;
|
||||
|
||||
if (!trace_seq_bprintf(s, field->fmt, field->buf))
|
||||
goto partial;
|
||||
|
||||
return TRACE_TYPE_HANDLED;
|
||||
|
||||
partial:
|
||||
return TRACE_TYPE_PARTIAL_LINE;
|
||||
}
|
||||
|
||||
static struct trace_event trace_bprintk_event = {
|
||||
.type = TRACE_BPRINTK,
|
||||
.trace = trace_bprintk_print,
|
||||
.raw = trace_bprintk_raw,
|
||||
.hex = trace_nop_print,
|
||||
.binary = trace_nop_print,
|
||||
};
|
||||
|
||||
static struct trace_event *events[] __initdata = {
|
||||
&trace_fn_event,
|
||||
&trace_ctx_event,
|
||||
|
@ -863,6 +937,7 @@ static struct trace_event *events[] __initdata = {
|
|||
&trace_stack_event,
|
||||
&trace_user_stack_event,
|
||||
&trace_print_event,
|
||||
&trace_bprintk_event,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue