aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_output.c
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2009-03-06 11:21:47 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-06 11:59:11 -0500
commit1427cdf0592368bdec57276edaf714040ee8744f (patch)
tree4b214ee49643db383328cf53a31959eb0627a167 /kernel/trace/trace_output.c
parent546e5354a6e4ec760ac03ef1148e9a4762abb5f5 (diff)
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>
Diffstat (limited to 'kernel/trace/trace_output.c')
-rw-r--r--kernel/trace/trace_output.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 306fef84c503..4ab71201862e 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -53,6 +53,26 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
53 return len; 53 return len;
54} 54}
55 55
56static int
57trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
58{
59 int len = (PAGE_SIZE - 1) - s->len;
60 int ret;
61
62 if (!len)
63 return 0;
64
65 ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
66
67 /* If we can't write it all, don't bother writing anything */
68 if (ret >= len)
69 return 0;
70
71 s->len += ret;
72
73 return len;
74}
75
56/** 76/**
57 * trace_seq_puts - trace sequence printing of simple string 77 * trace_seq_puts - trace sequence printing of simple string
58 * @s: trace sequence descriptor 78 * @s: trace sequence descriptor
@@ -855,6 +875,60 @@ static struct trace_event trace_print_event = {
855 .raw = trace_print_raw, 875 .raw = trace_print_raw,
856}; 876};
857 877
878/* TRACE_BPRINTK */
879static enum print_line_t
880trace_bprintk_print(struct trace_iterator *iter, int flags)
881{
882 struct trace_entry *entry = iter->ent;
883 struct trace_seq *s = &iter->seq;
884 struct bprintk_entry *field;
885
886 trace_assign_type(field, entry);
887
888 if (!seq_print_ip_sym(s, field->ip, flags))
889 goto partial;
890
891 if (!trace_seq_puts(s, ": "))
892 goto partial;
893
894 if (!trace_seq_bprintf(s, field->fmt, field->buf))
895 goto partial;
896
897 return TRACE_TYPE_HANDLED;
898
899 partial:
900 return TRACE_TYPE_PARTIAL_LINE;
901}
902
903static enum print_line_t
904trace_bprintk_raw(struct trace_iterator *iter, int flags)
905{
906 struct trace_entry *entry = iter->ent;
907 struct trace_seq *s = &iter->seq;
908 struct bprintk_entry *field;
909
910 trace_assign_type(field, entry);
911
912 if (!trace_seq_printf(s, ": %lx : ", field->ip))
913 goto partial;
914
915 if (!trace_seq_bprintf(s, field->fmt, field->buf))
916 goto partial;
917
918 return TRACE_TYPE_HANDLED;
919
920 partial:
921 return TRACE_TYPE_PARTIAL_LINE;
922}
923
924static struct trace_event trace_bprintk_event = {
925 .type = TRACE_BPRINTK,
926 .trace = trace_bprintk_print,
927 .raw = trace_bprintk_raw,
928 .hex = trace_nop_print,
929 .binary = trace_nop_print,
930};
931
858static struct trace_event *events[] __initdata = { 932static struct trace_event *events[] __initdata = {
859 &trace_fn_event, 933 &trace_fn_event,
860 &trace_ctx_event, 934 &trace_ctx_event,
@@ -863,6 +937,7 @@ static struct trace_event *events[] __initdata = {
863 &trace_stack_event, 937 &trace_stack_event,
864 &trace_user_stack_event, 938 &trace_user_stack_event,
865 &trace_print_event, 939 &trace_print_event,
940 &trace_bprintk_event,
866 NULL 941 NULL
867}; 942};
868 943