diff options
author | Linyu Yuan <quic_linyyuan@quicinc.com> | 2023-01-30 15:54:09 +0800 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-02-07 12:42:54 -0500 |
commit | a9c4bdd505630469f93f5efedfc7a9ca254996c8 (patch) | |
tree | 92d3d662f25aba71f55da41fa422c8378a2ad0ed /include/trace | |
parent | a2ff84a5d1e65c7d1178f24ecf39fc55283fbd14 (diff) | |
download | linux-rpi-a9c4bdd505630469f93f5efedfc7a9ca254996c8.tar.gz linux-rpi-a9c4bdd505630469f93f5efedfc7a9ca254996c8.tar.bz2 linux-rpi-a9c4bdd505630469f93f5efedfc7a9ca254996c8.zip |
tracing: Acquire buffer from temparary trace sequence
there is one dwc3 trace event declare as below,
DECLARE_EVENT_CLASS(dwc3_log_event,
TP_PROTO(u32 event, struct dwc3 *dwc),
TP_ARGS(event, dwc),
TP_STRUCT__entry(
__field(u32, event)
__field(u32, ep0state)
__dynamic_array(char, str, DWC3_MSG_MAX)
),
TP_fast_assign(
__entry->event = event;
__entry->ep0state = dwc->ep0state;
),
TP_printk("event (%08x): %s", __entry->event,
dwc3_decode_event(__get_str(str), DWC3_MSG_MAX,
__entry->event, __entry->ep0state))
);
the problem is when trace function called, it will allocate up to
DWC3_MSG_MAX bytes from trace event buffer, but never fill the buffer
during fast assignment, it only fill the buffer when output function are
called, so this means if output function are not called, the buffer will
never used.
add __get_buf(len) which acquiree buffer from iter->tmp_seq when trace
output function called, it allow user write string to acquired buffer.
the mentioned dwc3 trace event will changed as below,
DECLARE_EVENT_CLASS(dwc3_log_event,
TP_PROTO(u32 event, struct dwc3 *dwc),
TP_ARGS(event, dwc),
TP_STRUCT__entry(
__field(u32, event)
__field(u32, ep0state)
),
TP_fast_assign(
__entry->event = event;
__entry->ep0state = dwc->ep0state;
),
TP_printk("event (%08x): %s", __entry->event,
dwc3_decode_event(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX,
__entry->event, __entry->ep0state))
);.
Link: https://lore.kernel.org/linux-trace-kernel/1675065249-23368-1-git-send-email-quic_linyyuan@quicinc.com
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'include/trace')
-rw-r--r-- | include/trace/stages/stage3_trace_output.h | 3 | ||||
-rw-r--r-- | include/trace/stages/stage7_class_define.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index 66374df61ed3..c1fb1355d309 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -139,3 +139,6 @@ u64 ____val = (u64)(value); \ (u32) do_div(____val, NSEC_PER_SEC); \ }) + +#undef __get_buf +#define __get_buf(len) trace_seq_acquire(p, (len)) diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8795429f388b..bcb960d16fc0 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -23,6 +23,7 @@ #undef __get_rel_sockaddr #undef __print_array #undef __print_hex_dump +#undef __get_buf /* * The below is not executed in the kernel. It is only what is |