* [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
@ 2023-09-14 10:02 ` Linyu Yuan
2023-09-14 14:29 ` kernel test robot
2023-09-14 10:02 ` [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose Linyu Yuan
` (7 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:02 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
This class almost same as DECLARE_EVENT_CLASS, it allow user add some
init operation before print at output stage.
Add a new macro TP_printk_init(), user can add operation in it.
Also add a new TRACE_EVENT_PRINT_INIT() macro.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
include/linux/tracepoint.h | 22 ++++
include/trace/bpf_probe.h | 4 +
include/trace/perf.h | 43 ++++++++
include/trace/stages/stage3_trace_output.h | 3 +
include/trace/trace_events.h | 118 +++++++++++++++++++++
5 files changed, 190 insertions(+)
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 88c0ba623ee6..3fd42640236a 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -551,6 +551,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
*/
#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
+#define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
#define DEFINE_EVENT(template, name, proto, args) \
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
@@ -576,6 +577,20 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
PARAMS(args), PARAMS(cond))
+#define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
+ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN_PRINT_INIT(name, proto, args, struct, \
+ assign, print, reg, unreg, init) \
+ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_FN_COND_PRINT_INIT(name, proto, args, cond, struct, \
+ assign, print, reg, unreg, init) \
+ DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
+ PARAMS(args), PARAMS(cond))
+#define TRACE_EVENT_CONDITION_PRINT_INIT(name, proto, args, cond, \
+ struct, assign, print, init) \
+ DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
+ PARAMS(args), PARAMS(cond))
+
#define TRACE_EVENT_FLAGS(event, flag)
#define TRACE_EVENT_PERF_PERM(event, expr...)
@@ -595,4 +610,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
#define DEFINE_EVENT_NOP(template, name, proto, args) \
DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
+#define TRACE_EVENT_NOP_PRINT_INIT(name, proto, args, struct, assign, print, init) \
+ DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
+
+#define DECLARE_EVENT_CLASS_NOP_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
+#define DEFINE_EVENT_NOP(template, name, proto, args) \
+ DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args))
+
#endif /* ifdef TRACE_EVENT (see note above) */
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index e609cd7da47e..99b5594a4a8e 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -54,6 +54,10 @@ __bpf_trace_##call(void *__data, proto) \
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+ __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
+
/*
* This part is compiled out, it is only here as a build time check
* to make sure that if the tracepoint handling changes, the
diff --git a/include/trace/perf.h b/include/trace/perf.h
index 2c11181c82e0..bee78e8eef5d 100644
--- a/include/trace/perf.h
+++ b/include/trace/perf.h
@@ -55,6 +55,49 @@ perf_trace_##call(void *__data, proto) \
head, __task); \
}
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+static notrace void \
+perf_trace_##call(void *__data, proto) \
+{ \
+ struct trace_event_call *event_call = __data; \
+ struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
+ struct trace_event_raw_##call *entry; \
+ struct pt_regs *__regs; \
+ u64 __count = 1; \
+ struct task_struct *__task = NULL; \
+ struct hlist_head *head; \
+ int __entry_size; \
+ int __data_size; \
+ int rctx; \
+ \
+ __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
+ \
+ head = this_cpu_ptr(event_call->perf_events); \
+ if (!bpf_prog_array_valid(event_call) && \
+ __builtin_constant_p(!__task) && !__task && \
+ hlist_empty(head)) \
+ return; \
+ \
+ __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
+ sizeof(u64)); \
+ __entry_size -= sizeof(u32); \
+ \
+ entry = perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \
+ if (!entry) \
+ return; \
+ \
+ perf_fetch_caller_regs(__regs); \
+ \
+ tstruct \
+ \
+ { assign; } \
+ \
+ perf_trace_run_bpf_submit(entry, __entry_size, rctx, \
+ event_call, __count, __regs, \
+ head, __task); \
+}
+
/*
* This part is compiled out, it is only here as a build time check
* to make sure that if the tracepoint handling changes, the
diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h
index c1fb1355d309..121425e695f5 100644
--- a/include/trace/stages/stage3_trace_output.h
+++ b/include/trace/stages/stage3_trace_output.h
@@ -142,3 +142,6 @@
#undef __get_buf
#define __get_buf(len) trace_seq_acquire(p, (len))
+
+#undef TP_printk_init
+#define TP_printk_init(args...) args
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index c2f9cabf154d..9a8872544a8b 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -45,6 +45,17 @@
PARAMS(print)); \
DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
+#undef TRACE_EVENT_PRINT_INIT
+#define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
+ DECLARE_EVENT_CLASS_PRINT_INIT(name, \
+ PARAMS(proto), \
+ PARAMS(args), \
+ PARAMS(tstruct), \
+ PARAMS(assign), \
+ PARAMS(print), \
+ PARAMS(init)); \
+ DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
+
#include "stages/stage1_struct_define.h"
#undef DECLARE_EVENT_CLASS
@@ -57,6 +68,16 @@
\
static struct trace_event_class event_class_##name;
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
+ struct trace_event_raw_##name { \
+ struct trace_entry ent; \
+ tstruct \
+ char __data[]; \
+ }; \
+ \
+ static struct trace_event_class event_class_##name;
+
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args) \
static struct trace_event_call __used \
@@ -117,6 +138,12 @@
tstruct; \
};
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+ struct trace_event_data_offsets_##call { \
+ tstruct; \
+ };
+
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, name, proto, args)
@@ -208,6 +235,32 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \
.trace = trace_raw_output_##call, \
};
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+static notrace enum print_line_t \
+trace_raw_output_##call(struct trace_iterator *iter, int flags, \
+ struct trace_event *trace_event) \
+{ \
+ struct trace_seq *s = &iter->seq; \
+ struct trace_seq __maybe_unused *p = &iter->tmp_seq; \
+ struct trace_event_raw_##call *field; \
+ int ret; \
+ \
+ field = (typeof(field))iter->ent; \
+ \
+ ret = trace_raw_output_prep(iter, trace_event); \
+ if (ret != TRACE_TYPE_HANDLED) \
+ return ret; \
+ \
+ init \
+ trace_event_printf(iter, print); \
+ \
+ return trace_handle_return(s); \
+} \
+static struct trace_event_functions trace_event_type_funcs_##call = { \
+ .trace = trace_raw_output_##call, \
+};
+
#undef DEFINE_EVENT_PRINT
#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
static notrace enum print_line_t \
@@ -244,6 +297,12 @@ static struct trace_event_fields trace_event_fields_##call[] = { \
tstruct \
{} };
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, func, print, init) \
+static struct trace_event_fields trace_event_fields_##call[] = { \
+ tstruct \
+ {} };
+
#undef DEFINE_EVENT_PRINT
#define DEFINE_EVENT_PRINT(template, name, proto, args, print)
@@ -265,6 +324,20 @@ static inline notrace int trace_event_get_offsets_##call( \
return __data_size; \
}
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+static inline notrace int trace_event_get_offsets_##call( \
+ struct trace_event_data_offsets_##call *__data_offsets, proto) \
+{ \
+ int __data_size = 0; \
+ int __maybe_unused __item_length; \
+ struct trace_event_raw_##call __maybe_unused *entry; \
+ \
+ tstruct; \
+ \
+ return __data_size; \
+}
+
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
/*
@@ -403,6 +476,37 @@ trace_event_raw_event_##call(void *__data, proto) \
\
trace_event_buffer_commit(&fbuffer); \
}
+
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+ \
+static notrace void \
+trace_event_raw_event_##call(void *__data, proto) \
+{ \
+ struct trace_event_file *trace_file = __data; \
+ struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
+ struct trace_event_buffer fbuffer; \
+ struct trace_event_raw_##call *entry; \
+ int __data_size; \
+ \
+ if (trace_trigger_soft_disabled(trace_file)) \
+ return; \
+ \
+ __data_size = trace_event_get_offsets_##call(&__data_offsets, args); \
+ \
+ entry = trace_event_buffer_reserve(&fbuffer, trace_file, \
+ sizeof(*entry) + __data_size); \
+ \
+ if (!entry) \
+ return; \
+ \
+ tstruct \
+ \
+ { assign; } \
+ \
+ trace_event_buffer_commit(&fbuffer); \
+}
+
/*
* The ftrace_test_probe is compiled out, it is only here as a build time check
* to make sure that if the tracepoint handling changes, the ftrace probe will
@@ -434,6 +538,20 @@ static struct trace_event_class __used __refdata event_class_##call = { \
_TRACE_PERF_INIT(call) \
};
+#undef DECLARE_EVENT_CLASS_PRINT_INIT
+#define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
+_TRACE_PERF_PROTO(call, PARAMS(proto)); \
+static char print_fmt_##call[] = print; \
+static struct trace_event_class __used __refdata event_class_##call = { \
+ .system = TRACE_SYSTEM_STRING, \
+ .fields_array = trace_event_fields_##call, \
+ .fields = LIST_HEAD_INIT(event_class_##call.fields),\
+ .raw_init = trace_event_raw_init, \
+ .probe = trace_event_raw_event_##call, \
+ .reg = trace_event_reg, \
+ _TRACE_PERF_INIT(call) \
+};
+
#undef DEFINE_EVENT
#define DEFINE_EVENT(template, call, proto, args) \
\
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type
2023-09-14 10:02 ` [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type Linyu Yuan
@ 2023-09-14 14:29 ` kernel test robot
0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2023-09-14 14:29 UTC (permalink / raw)
To: Linyu Yuan, Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen,
Pawel Laszczak, Roger Quadros, Alan Stern, Steven Rostedt,
Masami Hiramatsu, Greg Kroah-Hartman
Cc: oe-kbuild-all, linux-usb, linux-trace-kernel, Linyu Yuan
Hi Linyu,
kernel test robot noticed the following build warnings:
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.6-rc1 next-20230914]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Linyu-Yuan/trace-add-new-DECLARE_EVENT_CLASS_PRINT_INIT-class-type/20230914-180924
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link: https://lore.kernel.org/r/20230914100302.30274-2-quic_linyyuan%40quicinc.com
patch subject: [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type
config: arm-defconfig (https://download.01.org/0day-ci/archive/20230914/202309142216.GwM6Q6l0-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230914/202309142216.GwM6Q6l0-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309142216.GwM6Q6l0-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/trace/events/migrate.h:8,
from mm/rmap.c:83:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/tlb.h:62,
from mm/rmap.c:82:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
--
In file included from include/trace/events/net.h:12,
from net/core/net-traces.c:31:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/skb.h:95,
from net/core/net-traces.c:30:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/napi.h:9,
from net/core/net-traces.c:32:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/net.h:319:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/sock.h:10,
from net/core/net-traces.c:33:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/napi.h:44:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/udp.h:9,
from net/core/net-traces.c:34:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/sock.h:338:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/tcp.h:10,
from net/core/net-traces.c:35:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/udp.h:33:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/fib.h:11,
from net/core/net-traces.c:36:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/tcp.h:425:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/qdisc.h:9,
from net/core/net-traces.c:37:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/fib.h:102:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/page_pool.h:9,
from net/core/net-traces.c:48:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/qdisc.h:153:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/neigh.h:9,
from net/core/net-traces.c:51:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/page_pool.h:117:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
--
In file included from include/trace/events/ipi.h:8,
from kernel/sched/core.c:83:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/sched.h:741,
from kernel/sched/core.c:82:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
In file included from include/trace/events/power.h:11,
from kernel/sched/sched.h:72,
from kernel/sched/core.c:86:
>> include/linux/tracepoint.h:554: warning: "DECLARE_EVENT_CLASS_PRINT_INIT" redefined
554 | #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
|
In file included from include/trace/define_trace.h:103,
from include/trace/events/ipi.h:134:
include/trace/perf.h:59: note: this is the location of the previous definition
59 | #define DECLARE_EVENT_CLASS_PRINT_INIT(call, proto, args, tstruct, assign, print, init) \
|
>> include/linux/tracepoint.h:580: warning: "TRACE_EVENT_PRINT_INIT" redefined
580 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
|
In file included from include/trace/define_trace.h:102:
include/trace/trace_events.h:49: note: this is the location of the previous definition
49 | #define TRACE_EVENT_PRINT_INIT(name, proto, args, tstruct, assign, print, init) \
|
vim +/DECLARE_EVENT_CLASS_PRINT_INIT +554 include/linux/tracepoint.h
446
447 #ifndef TRACE_EVENT
448 /*
449 * For use with the TRACE_EVENT macro:
450 *
451 * We define a tracepoint, its arguments, its printk format
452 * and its 'fast binary record' layout.
453 *
454 * Firstly, name your tracepoint via TRACE_EVENT(name : the
455 * 'subsystem_event' notation is fine.
456 *
457 * Think about this whole construct as the
458 * 'trace_sched_switch() function' from now on.
459 *
460 *
461 * TRACE_EVENT(sched_switch,
462 *
463 * *
464 * * A function has a regular function arguments
465 * * prototype, declare it via TP_PROTO():
466 * *
467 *
468 * TP_PROTO(struct rq *rq, struct task_struct *prev,
469 * struct task_struct *next),
470 *
471 * *
472 * * Define the call signature of the 'function'.
473 * * (Design sidenote: we use this instead of a
474 * * TP_PROTO1/TP_PROTO2/TP_PROTO3 ugliness.)
475 * *
476 *
477 * TP_ARGS(rq, prev, next),
478 *
479 * *
480 * * Fast binary tracing: define the trace record via
481 * * TP_STRUCT__entry(). You can think about it like a
482 * * regular C structure local variable definition.
483 * *
484 * * This is how the trace record is structured and will
485 * * be saved into the ring buffer. These are the fields
486 * * that will be exposed to user-space in
487 * * /sys/kernel/tracing/events/<*>/format.
488 * *
489 * * The declared 'local variable' is called '__entry'
490 * *
491 * * __field(pid_t, prev_pid) is equivalent to a standard declaration:
492 * *
493 * * pid_t prev_pid;
494 * *
495 * * __array(char, prev_comm, TASK_COMM_LEN) is equivalent to:
496 * *
497 * * char prev_comm[TASK_COMM_LEN];
498 * *
499 *
500 * TP_STRUCT__entry(
501 * __array( char, prev_comm, TASK_COMM_LEN )
502 * __field( pid_t, prev_pid )
503 * __field( int, prev_prio )
504 * __array( char, next_comm, TASK_COMM_LEN )
505 * __field( pid_t, next_pid )
506 * __field( int, next_prio )
507 * ),
508 *
509 * *
510 * * Assign the entry into the trace record, by embedding
511 * * a full C statement block into TP_fast_assign(). You
512 * * can refer to the trace record as '__entry' -
513 * * otherwise you can put arbitrary C code in here.
514 * *
515 * * Note: this C code will execute every time a trace event
516 * * happens, on an active tracepoint.
517 * *
518 *
519 * TP_fast_assign(
520 * memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
521 * __entry->prev_pid = prev->pid;
522 * __entry->prev_prio = prev->prio;
523 * memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
524 * __entry->next_pid = next->pid;
525 * __entry->next_prio = next->prio;
526 * ),
527 *
528 * *
529 * * Formatted output of a trace record via TP_printk().
530 * * This is how the tracepoint will appear under ftrace
531 * * plugins that make use of this tracepoint.
532 * *
533 * * (raw-binary tracing wont actually perform this step.)
534 * *
535 *
536 * TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
537 * __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
538 * __entry->next_comm, __entry->next_pid, __entry->next_prio),
539 *
540 * );
541 *
542 * This macro construct is thus used for the regular printk format
543 * tracing setup, it is used to construct a function pointer based
544 * tracepoint callback (this is used by programmatic plugins and
545 * can also by used by generic instrumentation like SystemTap), and
546 * it is also used to expose a structured trace record in
547 * /sys/kernel/tracing/events/.
548 *
549 * A set of (un)registration functions can be passed to the variant
550 * TRACE_EVENT_FN to perform any (un)registration work.
551 */
552
553 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
> 554 #define DECLARE_EVENT_CLASS_PRINT_INIT(name, proto, args, tstruct, assign, print, init)
555 #define DEFINE_EVENT(template, name, proto, args) \
556 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
557 #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg)\
558 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
559 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
560 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
561 #define DEFINE_EVENT_CONDITION(template, name, proto, \
562 args, cond) \
563 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
564 PARAMS(args), PARAMS(cond))
565
566 #define TRACE_EVENT(name, proto, args, struct, assign, print) \
567 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
568 #define TRACE_EVENT_FN(name, proto, args, struct, \
569 assign, print, reg, unreg) \
570 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
571 #define TRACE_EVENT_FN_COND(name, proto, args, cond, struct, \
572 assign, print, reg, unreg) \
573 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
574 PARAMS(args), PARAMS(cond))
575 #define TRACE_EVENT_CONDITION(name, proto, args, cond, \
576 struct, assign, print) \
577 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
578 PARAMS(args), PARAMS(cond))
579
> 580 #define TRACE_EVENT_PRINT_INIT(name, proto, args, struct, assign, print, init) \
581 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
582 #define TRACE_EVENT_FN_PRINT_INIT(name, proto, args, struct, \
583 assign, print, reg, unreg, init) \
584 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
585 #define TRACE_EVENT_FN_COND_PRINT_INIT(name, proto, args, cond, struct, \
586 assign, print, reg, unreg, init) \
587 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
588 PARAMS(args), PARAMS(cond))
589 #define TRACE_EVENT_CONDITION_PRINT_INIT(name, proto, args, cond, \
590 struct, assign, print, init) \
591 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
592 PARAMS(args), PARAMS(cond))
593
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
2023-09-14 10:02 ` [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type Linyu Yuan
@ 2023-09-14 10:02 ` Linyu Yuan
2023-09-14 14:54 ` Alan Stern
2023-09-14 10:02 ` [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event Linyu Yuan
` (6 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:02 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Some UDC trace event will save usb udc information, but it use one int
size buffer to save one bit information of usb udc, it is wast trace
buffer.
Add anonymous union which have one u32 member can be used by trace event
during fast assign stage to save more entries with same trace ring buffer
size.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
include/linux/usb/gadget.h | 113 +++++++++++++++++++++++--------------
1 file changed, 72 insertions(+), 41 deletions(-)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 75bda0783395..4894f256df55 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -41,6 +41,7 @@ struct usb_ep;
* @num_sgs: number of SG entries
* @num_mapped_sgs: number of SG entries mapped to DMA (internal)
* @length: Length of that data
+ * @dw1: trace event purpose
* @stream_id: The stream id, when USB3.0 bulk streams are being used
* @is_last: Indicates if this is the last request of a stream_id before
* switching to a different stream (required for DWC3 controllers).
@@ -105,12 +106,17 @@ struct usb_request {
unsigned num_sgs;
unsigned num_mapped_sgs;
- unsigned stream_id:16;
- unsigned is_last:1;
- unsigned no_interrupt:1;
- unsigned zero:1;
- unsigned short_not_ok:1;
- unsigned dma_mapped:1;
+ union {
+ struct {
+ u32 stream_id:16;
+ u32 is_last:1;
+ u32 no_interrupt:1;
+ u32 zero:1;
+ u32 short_not_ok:1;
+ u32 dma_mapped:1;
+ } __packed;
+ u32 dw1;
+ };
void (*complete)(struct usb_ep *ep,
struct usb_request *req);
@@ -163,13 +169,13 @@ struct usb_ep_ops {
* @dir_out:Endpoint supports OUT direction.
*/
struct usb_ep_caps {
- unsigned type_control:1;
- unsigned type_iso:1;
- unsigned type_bulk:1;
- unsigned type_int:1;
- unsigned dir_in:1;
- unsigned dir_out:1;
-};
+ u8 type_control:1;
+ u8 type_iso:1;
+ u8 type_bulk:1;
+ u8 type_int:1;
+ u8 dir_in:1;
+ u8 dir_out:1;
+} __packed;
#define USB_EP_CAPS_TYPE_CONTROL 0x01
#define USB_EP_CAPS_TYPE_ISO 0x02
@@ -199,6 +205,9 @@ struct usb_ep_caps {
* @caps:The structure describing types and directions supported by endpoint.
* @enabled: The current endpoint enabled/disabled state.
* @claimed: True if this endpoint is claimed by a function.
+ * @dw1: trace event purpose
+ * @dw2: trace event purpose
+ * @dw3: trace event purpose
* @maxpacket:The maximum packet size used on this endpoint. The initial
* value can sometimes be reduced (hardware allowing), according to
* the endpoint descriptor used to configure the endpoint.
@@ -228,15 +237,30 @@ struct usb_ep {
const char *name;
const struct usb_ep_ops *ops;
struct list_head ep_list;
- struct usb_ep_caps caps;
- bool claimed;
- bool enabled;
- unsigned maxpacket:16;
- unsigned maxpacket_limit:16;
- unsigned max_streams:16;
- unsigned mult:2;
- unsigned maxburst:5;
- u8 address;
+ union {
+ struct {
+ u32 maxpacket:16;
+ u32 maxpacket_limit:16;
+ } __packed;
+ u32 dw1;
+ };
+ union {
+ struct {
+ u32 max_streams:16;
+ u32 mult:2;
+ u32 maxburst:5;
+ } __packed;
+ u32 dw2;
+ };
+ union {
+ struct {
+ struct usb_ep_caps caps;
+ u8 claimed:1;
+ u8 enabled:1;
+ u8 address;
+ } __packed;
+ u32 dw3;
+ };
const struct usb_endpoint_descriptor *desc;
const struct usb_ss_ep_comp_descriptor *comp_desc;
};
@@ -357,6 +381,7 @@ struct usb_gadget_ops {
* @in_epnum: last used in ep number
* @mA: last set mA value
* @otg_caps: OTG capabilities of this gadget.
+ * @dw1: trace event purpose
* @sg_supported: true if we can handle scatter-gather
* @is_otg: True if the USB device port uses a Mini-AB jack, so that the
* gadget driver must provide a USB OTG descriptor.
@@ -432,25 +457,31 @@ struct usb_gadget {
unsigned mA;
struct usb_otg_caps *otg_caps;
- unsigned sg_supported:1;
- unsigned is_otg:1;
- unsigned is_a_peripheral:1;
- unsigned b_hnp_enable:1;
- unsigned a_hnp_support:1;
- unsigned a_alt_hnp_support:1;
- unsigned hnp_polling_support:1;
- unsigned host_request_flag:1;
- unsigned quirk_ep_out_aligned_size:1;
- unsigned quirk_altset_not_supp:1;
- unsigned quirk_stall_not_supp:1;
- unsigned quirk_zlp_not_supp:1;
- unsigned quirk_avoids_skb_reserve:1;
- unsigned is_selfpowered:1;
- unsigned deactivated:1;
- unsigned connected:1;
- unsigned lpm_capable:1;
- unsigned wakeup_capable:1;
- unsigned wakeup_armed:1;
+ union {
+ struct {
+ u32 sg_supported:1;
+ u32 is_otg:1;
+ u32 is_a_peripheral:1;
+ u32 b_hnp_enable:1;
+ u32 a_hnp_support:1;
+ u32 a_alt_hnp_support:1;
+ u32 hnp_polling_support:1;
+ u32 host_request_flag:1;
+ u32 quirk_ep_out_aligned_size:1;
+ u32 quirk_altset_not_supp:1;
+ u32 quirk_stall_not_supp:1;
+ u32 quirk_zlp_not_supp:1;
+ u32 quirk_avoids_skb_reserve:1;
+ u32 is_selfpowered:1;
+ u32 deactivated:1;
+ u32 connected:1;
+ u32 lpm_capable:1;
+ u32 wakeup_capable:1;
+ u32 wakeup_armed:1;
+ } __packed;
+
+ u32 dw1;
+ };
int irq;
int id_number;
};
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose
2023-09-14 10:02 ` [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose Linyu Yuan
@ 2023-09-14 14:54 ` Alan Stern
2023-09-15 1:02 ` Linyu Yuan
0 siblings, 1 reply; 19+ messages in thread
From: Alan Stern @ 2023-09-14 14:54 UTC (permalink / raw)
To: Linyu Yuan
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman, linux-usb, linux-trace-kernel
You didn't include the version number in the Subject: line. Undoubtedly
Greg's automatic error checker will warn you about this. Unless the
version number is clearly marked for each patch, it's difficult for his
programs to tell which email message contains the most recent version.
On Thu, Sep 14, 2023 at 06:02:56PM +0800, Linyu Yuan wrote:
> Some UDC trace event will save usb udc information, but it use one int
> size buffer to save one bit information of usb udc, it is wast trace
> buffer.
>
> Add anonymous union which have one u32 member can be used by trace event
> during fast assign stage to save more entries with same trace ring buffer
> size.
>
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
And you didn't include the version change information here, below the
"---" line.
Apart from that, this is a _lot_ better than before! I don't know if
Greg will think this change is worth merging, but at least now it's
possible to read the code and understand what's going on.
Alan Stern
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose
2023-09-14 14:54 ` Alan Stern
@ 2023-09-15 1:02 ` Linyu Yuan
2023-09-15 1:51 ` Alan Stern
0 siblings, 1 reply; 19+ messages in thread
From: Linyu Yuan @ 2023-09-15 1:02 UTC (permalink / raw)
To: Alan Stern
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman, linux-usb, linux-trace-kernel
On 9/14/2023 10:54 PM, Alan Stern wrote:
> You didn't include the version number in the Subject: line. Undoubtedly
> Greg's automatic error checker will warn you about this. Unless the
> version number is clearly marked for each patch, it's difficult for his
> programs to tell which email message contains the most recent version.
>
> On Thu, Sep 14, 2023 at 06:02:56PM +0800, Linyu Yuan wrote:
>> Some UDC trace event will save usb udc information, but it use one int
>> size buffer to save one bit information of usb udc, it is wast trace
>> buffer.
>>
>> Add anonymous union which have one u32 member can be used by trace event
>> during fast assign stage to save more entries with same trace ring buffer
>> size.
>>
>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>> ---
> And you didn't include the version change information here, below the
> "---" line.
>
> Apart from that, this is a _lot_ better than before! I don't know if
> Greg will think this change is worth merging, but at least now it's
> possible to read the code and understand what's going on.
according Steven's comment, maybe will always save data in little endian
at trace event
fast assign stage.
it will add definition of bit field back.
>
> Alan Stern
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose
2023-09-15 1:02 ` Linyu Yuan
@ 2023-09-15 1:51 ` Alan Stern
2023-09-15 1:56 ` Linyu Yuan
0 siblings, 1 reply; 19+ messages in thread
From: Alan Stern @ 2023-09-15 1:51 UTC (permalink / raw)
To: Linyu Yuan
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman, linux-usb, linux-trace-kernel
On Fri, Sep 15, 2023 at 09:02:48AM +0800, Linyu Yuan wrote:
>
> On 9/14/2023 10:54 PM, Alan Stern wrote:
> > You didn't include the version number in the Subject: line. Undoubtedly
> > Greg's automatic error checker will warn you about this. Unless the
> > version number is clearly marked for each patch, it's difficult for his
> > programs to tell which email message contains the most recent version.
> >
> > On Thu, Sep 14, 2023 at 06:02:56PM +0800, Linyu Yuan wrote:
> > > Some UDC trace event will save usb udc information, but it use one int
> > > size buffer to save one bit information of usb udc, it is wast trace
> > > buffer.
> > >
> > > Add anonymous union which have one u32 member can be used by trace event
> > > during fast assign stage to save more entries with same trace ring buffer
> > > size.
> > >
> > > Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> > > ---
> > And you didn't include the version change information here, below the
> > "---" line.
> >
> > Apart from that, this is a _lot_ better than before! I don't know if
> > Greg will think this change is worth merging, but at least now it's
> > possible to read the code and understand what's going on.
>
>
> according Steven's comment, maybe will always save data in little endian at
> trace event
>
> fast assign stage.
>
> it will add definition of bit field back.
Yes, that would be even better because you wouldn't have to change the
definition of struct usb_gadget or struct usb_endpoint at all. The fast
assign stage can simply do:
__entry->dw1 = (g->sg_supported << 0) |
(g->is_otg << 1) |
...
and then you can easily access the individual bits in __entry. It
wouldn't be as fast but it would still save a lot of space.
Alan Stern
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose
2023-09-15 1:51 ` Alan Stern
@ 2023-09-15 1:56 ` Linyu Yuan
0 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-15 1:56 UTC (permalink / raw)
To: Alan Stern
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman, linux-usb, linux-trace-kernel
On 9/15/2023 9:51 AM, Alan Stern wrote:
> On Fri, Sep 15, 2023 at 09:02:48AM +0800, Linyu Yuan wrote:
>> On 9/14/2023 10:54 PM, Alan Stern wrote:
>>> You didn't include the version number in the Subject: line. Undoubtedly
>>> Greg's automatic error checker will warn you about this. Unless the
>>> version number is clearly marked for each patch, it's difficult for his
>>> programs to tell which email message contains the most recent version.
>>>
>>> On Thu, Sep 14, 2023 at 06:02:56PM +0800, Linyu Yuan wrote:
>>>> Some UDC trace event will save usb udc information, but it use one int
>>>> size buffer to save one bit information of usb udc, it is wast trace
>>>> buffer.
>>>>
>>>> Add anonymous union which have one u32 member can be used by trace event
>>>> during fast assign stage to save more entries with same trace ring buffer
>>>> size.
>>>>
>>>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>>>> ---
>>> And you didn't include the version change information here, below the
>>> "---" line.
>>>
>>> Apart from that, this is a _lot_ better than before! I don't know if
>>> Greg will think this change is worth merging, but at least now it's
>>> possible to read the code and understand what's going on.
>>
>> according Steven's comment, maybe will always save data in little endian at
>> trace event
>>
>> fast assign stage.
>>
>> it will add definition of bit field back.
> Yes, that would be even better because you wouldn't have to change the
> definition of struct usb_gadget or struct usb_endpoint at all. The fast
> assign stage can simply do:
>
> __entry->dw1 = (g->sg_supported << 0) |
> (g->is_otg << 1) |
> ...
>
> and then you can easily access the individual bits in __entry. It
> wouldn't be as fast but it would still save a lot of space.
how about __entry->dw1 = cpu_to_le32(g->dw1) ?
>
> Alan Stern
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
2023-09-14 10:02 ` [PATCH 1/8] trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type Linyu Yuan
2023-09-14 10:02 ` [PATCH 2/8] usb: gadget: add anonymous definition in some struct for trace purpose Linyu Yuan
@ 2023-09-14 10:02 ` Linyu Yuan
2023-09-14 16:54 ` Steven Rostedt
2023-09-14 10:02 ` [PATCH 4/8] usb: cdns3: " Linyu Yuan
` (5 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:02 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 members into trace event ring buffer and parse it for possible
bit fields.
Use new DECLARE_EVENT_CLASS_PRINT_INIT() class macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/gadget/udc/trace.h | 154 +++++++++++++++------------------
1 file changed, 69 insertions(+), 85 deletions(-)
diff --git a/drivers/usb/gadget/udc/trace.h b/drivers/usb/gadget/udc/trace.h
index a5ed26fbc2da..e1754667f1d2 100644
--- a/drivers/usb/gadget/udc/trace.h
+++ b/drivers/usb/gadget/udc/trace.h
@@ -17,7 +17,7 @@
#include <asm/byteorder.h>
#include <linux/usb/gadget.h>
-DECLARE_EVENT_CLASS(udc_log_gadget,
+DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_gadget,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret),
TP_STRUCT__entry(
@@ -25,20 +25,7 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
__field(enum usb_device_speed, max_speed)
__field(enum usb_device_state, state)
__field(unsigned, mA)
- __field(unsigned, sg_supported)
- __field(unsigned, is_otg)
- __field(unsigned, is_a_peripheral)
- __field(unsigned, b_hnp_enable)
- __field(unsigned, a_hnp_support)
- __field(unsigned, hnp_polling_support)
- __field(unsigned, host_request_flag)
- __field(unsigned, quirk_ep_out_aligned_size)
- __field(unsigned, quirk_altset_not_supp)
- __field(unsigned, quirk_stall_not_supp)
- __field(unsigned, quirk_zlp_not_supp)
- __field(unsigned, is_selfpowered)
- __field(unsigned, deactivated)
- __field(unsigned, connected)
+ __field(u32, gdw1)
__field(int, ret)
),
TP_fast_assign(
@@ -46,39 +33,35 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
__entry->max_speed = g->max_speed;
__entry->state = g->state;
__entry->mA = g->mA;
- __entry->sg_supported = g->sg_supported;
- __entry->is_otg = g->is_otg;
- __entry->is_a_peripheral = g->is_a_peripheral;
- __entry->b_hnp_enable = g->b_hnp_enable;
- __entry->a_hnp_support = g->a_hnp_support;
- __entry->hnp_polling_support = g->hnp_polling_support;
- __entry->host_request_flag = g->host_request_flag;
- __entry->quirk_ep_out_aligned_size = g->quirk_ep_out_aligned_size;
- __entry->quirk_altset_not_supp = g->quirk_altset_not_supp;
- __entry->quirk_stall_not_supp = g->quirk_stall_not_supp;
- __entry->quirk_zlp_not_supp = g->quirk_zlp_not_supp;
- __entry->is_selfpowered = g->is_selfpowered;
- __entry->deactivated = g->deactivated;
- __entry->connected = g->connected;
+ __entry->gdw1 = g->dw1;
__entry->ret = ret;
),
- TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
+ TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
__entry->speed, __entry->max_speed, __entry->state, __entry->mA,
- __entry->sg_supported ? "sg:" : "",
- __entry->is_otg ? "OTG:" : "",
- __entry->is_a_peripheral ? "a_peripheral:" : "",
- __entry->b_hnp_enable ? "b_hnp:" : "",
- __entry->a_hnp_support ? "a_hnp:" : "",
- __entry->hnp_polling_support ? "hnp_poll:" : "",
- __entry->host_request_flag ? "hostreq:" : "",
- __entry->quirk_ep_out_aligned_size ? "out_aligned:" : "",
- __entry->quirk_altset_not_supp ? "no_altset:" : "",
- __entry->quirk_stall_not_supp ? "no_stall:" : "",
- __entry->quirk_zlp_not_supp ? "no_zlp" : "",
- __entry->is_selfpowered ? "self-powered:" : "bus-powered:",
- __entry->deactivated ? "deactivated:" : "activated:",
- __entry->connected ? "connected" : "disconnected",
- __entry->ret)
+ tg.sg_supported ? "sg:" : "",
+ tg.is_otg ? "OTG:" : "",
+ tg.is_a_peripheral ? "a_peripheral:" : "",
+ tg.b_hnp_enable ? "b_hnp:" : "",
+ tg.a_hnp_support ? "a_hnp:" : "",
+ tg.a_alt_hnp_support ? "a_alt_hnp:" : "",
+ tg.hnp_polling_support ? "hnp_poll:" : "",
+ tg.host_request_flag ? "hostreq:" : "",
+ tg.quirk_ep_out_aligned_size ? "out_aligned:" : "",
+ tg.quirk_altset_not_supp ? "no_altset:" : "",
+ tg.quirk_stall_not_supp ? "no_stall:" : "",
+ tg.quirk_zlp_not_supp ? "no_zlp" : "",
+ tg.quirk_avoids_skb_reserve ? "no_skb_reserve" : "",
+ tg.is_selfpowered ? "self-powered:" : "bus-powered:",
+ tg.deactivated ? "deactivated:" : "activated:",
+ tg.connected ? "connected" : "disconnected",
+ tg.lpm_capable ? "lpm-capable" : "",
+ tg.wakeup_capable ? "wakeup-capable" : "",
+ tg.wakeup_armed ? "wakeup-armed" : "",
+ __entry->ret),
+ TP_printk_init(
+ struct usb_gadget tg;
+ tg.dw1 = __entry->gdw1;
+ )
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
@@ -141,38 +124,36 @@ DEFINE_EVENT(udc_log_gadget, usb_gadget_activate,
TP_ARGS(g, ret)
);
-DECLARE_EVENT_CLASS(udc_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_ep,
TP_PROTO(struct usb_ep *ep, int ret),
TP_ARGS(ep, ret),
TP_STRUCT__entry(
- __string(name, ep->name)
- __field(unsigned, maxpacket)
- __field(unsigned, maxpacket_limit)
- __field(unsigned, max_streams)
- __field(unsigned, mult)
- __field(unsigned, maxburst)
- __field(u8, address)
- __field(bool, claimed)
- __field(bool, enabled)
+ __field(u32, edw3)
+ __field(u32, edw1)
+ __field(u32, edw2)
__field(int, ret)
),
TP_fast_assign(
- __assign_str(name, ep->name);
- __entry->maxpacket = ep->maxpacket;
- __entry->maxpacket_limit = ep->maxpacket_limit;
- __entry->max_streams = ep->max_streams;
- __entry->mult = ep->mult;
- __entry->maxburst = ep->maxburst;
- __entry->address = ep->address,
- __entry->claimed = ep->claimed;
- __entry->enabled = ep->enabled;
+ __entry->edw3 = ep->dw3;
+ __entry->edw1 = ep->dw1;
+ __entry->edw2 = ep->dw2;
__entry->ret = ret;
),
TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
- __get_str(name), __entry->maxpacket, __entry->maxpacket_limit,
- __entry->max_streams, __entry->mult, __entry->maxburst,
- __entry->address, __entry->claimed ? "claimed:" : "released:",
- __entry->enabled ? "enabled" : "disabled", ret)
+ __s, te.maxpacket, te.maxpacket_limit,
+ te.max_streams, te.mult, te.maxburst,
+ te.address, te.claimed ? "claimed:" : "released:",
+ te.enabled ? "enabled" : "disabled", ret),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw1 = __entry->edw1;
+ te.dw2 = __entry->edw2;
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit,
@@ -215,44 +196,47 @@ DEFINE_EVENT(udc_log_ep, usb_ep_fifo_flush,
TP_ARGS(ep, ret)
);
-DECLARE_EVENT_CLASS(udc_log_req,
+DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_req,
TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
TP_ARGS(ep, req, ret),
TP_STRUCT__entry(
- __string(name, ep->name)
+ __field(u32, edw3)
__field(unsigned, length)
__field(unsigned, actual)
__field(unsigned, num_sgs)
__field(unsigned, num_mapped_sgs)
- __field(unsigned, stream_id)
- __field(unsigned, no_interrupt)
- __field(unsigned, zero)
- __field(unsigned, short_not_ok)
+ __field(u32, rdw1)
__field(int, status)
__field(int, ret)
__field(struct usb_request *, req)
),
TP_fast_assign(
- __assign_str(name, ep->name);
+ __entry->edw3 = ep->dw3;
__entry->length = req->length;
__entry->actual = req->actual;
__entry->num_sgs = req->num_sgs;
__entry->num_mapped_sgs = req->num_mapped_sgs;
- __entry->stream_id = req->stream_id;
- __entry->no_interrupt = req->no_interrupt;
- __entry->zero = req->zero;
- __entry->short_not_ok = req->short_not_ok;
+ __entry->rdw1 = req->dw1;
__entry->status = req->status;
__entry->ret = ret;
__entry->req = req;
),
TP_printk("%s: req %p length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
- __get_str(name),__entry->req, __entry->actual, __entry->length,
- __entry->num_mapped_sgs, __entry->num_sgs, __entry->stream_id,
- __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "i" : "I",
- __entry->status, __entry->ret
+ __s,__entry->req, __entry->actual, __entry->length,
+ __entry->num_mapped_sgs, __entry->num_sgs, tr.stream_id,
+ tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "i" : "I",
+ __entry->status, __entry->ret),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event
2023-09-14 10:02 ` [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event Linyu Yuan
@ 2023-09-14 16:54 ` Steven Rostedt
2023-09-15 1:11 ` Linyu Yuan
0 siblings, 1 reply; 19+ messages in thread
From: Steven Rostedt @ 2023-09-14 16:54 UTC (permalink / raw)
To: Linyu Yuan
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Masami Hiramatsu, Greg Kroah-Hartman,
linux-usb, linux-trace-kernel
On Thu, 14 Sep 2023 18:02:57 +0800
Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
> Save u32 members into trace event ring buffer and parse it for possible
> bit fields.
>
> Use new DECLARE_EVENT_CLASS_PRINT_INIT() class macro for output stage.
>
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
> drivers/usb/gadget/udc/trace.h | 154 +++++++++++++++------------------
> 1 file changed, 69 insertions(+), 85 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/trace.h b/drivers/usb/gadget/udc/trace.h
> index a5ed26fbc2da..e1754667f1d2 100644
> --- a/drivers/usb/gadget/udc/trace.h
> +++ b/drivers/usb/gadget/udc/trace.h
> @@ -17,7 +17,7 @@
> #include <asm/byteorder.h>
> #include <linux/usb/gadget.h>
>
> -DECLARE_EVENT_CLASS(udc_log_gadget,
> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_gadget,
> TP_PROTO(struct usb_gadget *g, int ret),
> TP_ARGS(g, ret),
> TP_STRUCT__entry(
> @@ -25,20 +25,7 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
> __field(enum usb_device_speed, max_speed)
> __field(enum usb_device_state, state)
> __field(unsigned, mA)
> - __field(unsigned, sg_supported)
> - __field(unsigned, is_otg)
> - __field(unsigned, is_a_peripheral)
> - __field(unsigned, b_hnp_enable)
> - __field(unsigned, a_hnp_support)
> - __field(unsigned, hnp_polling_support)
> - __field(unsigned, host_request_flag)
> - __field(unsigned, quirk_ep_out_aligned_size)
> - __field(unsigned, quirk_altset_not_supp)
> - __field(unsigned, quirk_stall_not_supp)
> - __field(unsigned, quirk_zlp_not_supp)
> - __field(unsigned, is_selfpowered)
> - __field(unsigned, deactivated)
> - __field(unsigned, connected)
> + __field(u32, gdw1)
> __field(int, ret)
> ),
> TP_fast_assign(
> @@ -46,39 +33,35 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
> __entry->max_speed = g->max_speed;
> __entry->state = g->state;
> __entry->mA = g->mA;
> - __entry->sg_supported = g->sg_supported;
> - __entry->is_otg = g->is_otg;
> - __entry->is_a_peripheral = g->is_a_peripheral;
> - __entry->b_hnp_enable = g->b_hnp_enable;
> - __entry->a_hnp_support = g->a_hnp_support;
> - __entry->hnp_polling_support = g->hnp_polling_support;
> - __entry->host_request_flag = g->host_request_flag;
> - __entry->quirk_ep_out_aligned_size = g->quirk_ep_out_aligned_size;
> - __entry->quirk_altset_not_supp = g->quirk_altset_not_supp;
> - __entry->quirk_stall_not_supp = g->quirk_stall_not_supp;
> - __entry->quirk_zlp_not_supp = g->quirk_zlp_not_supp;
> - __entry->is_selfpowered = g->is_selfpowered;
> - __entry->deactivated = g->deactivated;
> - __entry->connected = g->connected;
> + __entry->gdw1 = g->dw1;
> __entry->ret = ret;
> ),
> - TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
> + TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
> __entry->speed, __entry->max_speed, __entry->state, __entry->mA,
> - __entry->sg_supported ? "sg:" : "",
> - __entry->is_otg ? "OTG:" : "",
> - __entry->is_a_peripheral ? "a_peripheral:" : "",
> - __entry->b_hnp_enable ? "b_hnp:" : "",
> - __entry->a_hnp_support ? "a_hnp:" : "",
> - __entry->hnp_polling_support ? "hnp_poll:" : "",
> - __entry->host_request_flag ? "hostreq:" : "",
> - __entry->quirk_ep_out_aligned_size ? "out_aligned:" : "",
> - __entry->quirk_altset_not_supp ? "no_altset:" : "",
> - __entry->quirk_stall_not_supp ? "no_stall:" : "",
> - __entry->quirk_zlp_not_supp ? "no_zlp" : "",
> - __entry->is_selfpowered ? "self-powered:" : "bus-powered:",
> - __entry->deactivated ? "deactivated:" : "activated:",
> - __entry->connected ? "connected" : "disconnected",
> - __entry->ret)
> + tg.sg_supported ? "sg:" : "",
> + tg.is_otg ? "OTG:" : "",
> + tg.is_a_peripheral ? "a_peripheral:" : "",
> + tg.b_hnp_enable ? "b_hnp:" : "",
> + tg.a_hnp_support ? "a_hnp:" : "",
> + tg.a_alt_hnp_support ? "a_alt_hnp:" : "",
> + tg.hnp_polling_support ? "hnp_poll:" : "",
> + tg.host_request_flag ? "hostreq:" : "",
> + tg.quirk_ep_out_aligned_size ? "out_aligned:" : "",
> + tg.quirk_altset_not_supp ? "no_altset:" : "",
> + tg.quirk_stall_not_supp ? "no_stall:" : "",
> + tg.quirk_zlp_not_supp ? "no_zlp" : "",
> + tg.quirk_avoids_skb_reserve ? "no_skb_reserve" : "",
> + tg.is_selfpowered ? "self-powered:" : "bus-powered:",
> + tg.deactivated ? "deactivated:" : "activated:",
> + tg.connected ? "connected" : "disconnected",
> + tg.lpm_capable ? "lpm-capable" : "",
> + tg.wakeup_capable ? "wakeup-capable" : "",
> + tg.wakeup_armed ? "wakeup-armed" : "",
You can accomplish the above using __print_flags(), if you make it into a
bitmask, and that make a macro for each bit.
> + __entry->ret),
> + TP_printk_init(
> + struct usb_gadget tg;
> + tg.dw1 = __entry->gdw1;
> + )
> );
>
> DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
> @@ -141,38 +124,36 @@ DEFINE_EVENT(udc_log_gadget, usb_gadget_activate,
> TP_ARGS(g, ret)
> );
>
> -DECLARE_EVENT_CLASS(udc_log_ep,
> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_ep,
> TP_PROTO(struct usb_ep *ep, int ret),
> TP_ARGS(ep, ret),
> TP_STRUCT__entry(
> - __string(name, ep->name)
> - __field(unsigned, maxpacket)
> - __field(unsigned, maxpacket_limit)
> - __field(unsigned, max_streams)
> - __field(unsigned, mult)
> - __field(unsigned, maxburst)
> - __field(u8, address)
> - __field(bool, claimed)
> - __field(bool, enabled)
> + __field(u32, edw3)
> + __field(u32, edw1)
> + __field(u32, edw2)
> __field(int, ret)
> ),
> TP_fast_assign(
> - __assign_str(name, ep->name);
> - __entry->maxpacket = ep->maxpacket;
> - __entry->maxpacket_limit = ep->maxpacket_limit;
> - __entry->max_streams = ep->max_streams;
> - __entry->mult = ep->mult;
> - __entry->maxburst = ep->maxburst;
> - __entry->address = ep->address,
> - __entry->claimed = ep->claimed;
> - __entry->enabled = ep->enabled;
> + __entry->edw3 = ep->dw3;
> + __entry->edw1 = ep->dw1;
> + __entry->edw2 = ep->dw2;
> __entry->ret = ret;
> ),
> TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
> - __get_str(name), __entry->maxpacket, __entry->maxpacket_limit,
> - __entry->max_streams, __entry->mult, __entry->maxburst,
> - __entry->address, __entry->claimed ? "claimed:" : "released:",
> - __entry->enabled ? "enabled" : "disabled", ret)
> + __s, te.maxpacket, te.maxpacket_limit,
> + te.max_streams, te.mult, te.maxburst,
> + te.address, te.claimed ? "claimed:" : "released:",
> + te.enabled ? "enabled" : "disabled", ret),
> + TP_printk_init(
> + struct usb_ep te;
> + char __s[9];
> + te.dw1 = __entry->edw1;
> + te.dw2 = __entry->edw2;
> + te.dw3 = __entry->edw3;
> + snprintf(__s, 9, "ep%d%s", te.address, \
> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
> + te.caps.dir_in ? "in" : "out");
Note, there's a temp buffer trace_seq 'p' available for use as well. See
both include/trace/events/libata.h and include/trace/events/scsi.h:
const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
#define __parse_status(s) libata_trace_parse_status(p, s)
I think that can be used instead of adding this TP_printk_init().
-- Steve
> + )
> );
>
> DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit,
> @@ -215,44 +196,47 @@ DEFINE_EVENT(udc_log_ep, usb_ep_fifo_flush,
> TP_ARGS(ep, ret)
> );
>
> -DECLARE_EVENT_CLASS(udc_log_req,
> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_req,
> TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
> TP_ARGS(ep, req, ret),
> TP_STRUCT__entry(
> - __string(name, ep->name)
> + __field(u32, edw3)
> __field(unsigned, length)
> __field(unsigned, actual)
> __field(unsigned, num_sgs)
> __field(unsigned, num_mapped_sgs)
> - __field(unsigned, stream_id)
> - __field(unsigned, no_interrupt)
> - __field(unsigned, zero)
> - __field(unsigned, short_not_ok)
> + __field(u32, rdw1)
> __field(int, status)
> __field(int, ret)
> __field(struct usb_request *, req)
> ),
> TP_fast_assign(
> - __assign_str(name, ep->name);
> + __entry->edw3 = ep->dw3;
> __entry->length = req->length;
> __entry->actual = req->actual;
> __entry->num_sgs = req->num_sgs;
> __entry->num_mapped_sgs = req->num_mapped_sgs;
> - __entry->stream_id = req->stream_id;
> - __entry->no_interrupt = req->no_interrupt;
> - __entry->zero = req->zero;
> - __entry->short_not_ok = req->short_not_ok;
> + __entry->rdw1 = req->dw1;
> __entry->status = req->status;
> __entry->ret = ret;
> __entry->req = req;
> ),
> TP_printk("%s: req %p length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
> - __get_str(name),__entry->req, __entry->actual, __entry->length,
> - __entry->num_mapped_sgs, __entry->num_sgs, __entry->stream_id,
> - __entry->zero ? "Z" : "z",
> - __entry->short_not_ok ? "S" : "s",
> - __entry->no_interrupt ? "i" : "I",
> - __entry->status, __entry->ret
> + __s,__entry->req, __entry->actual, __entry->length,
> + __entry->num_mapped_sgs, __entry->num_sgs, tr.stream_id,
> + tr.zero ? "Z" : "z",
> + tr.short_not_ok ? "S" : "s",
> + tr.no_interrupt ? "i" : "I",
> + __entry->status, __entry->ret),
> + TP_printk_init(
> + struct usb_ep te;
> + struct usb_request tr;
> + char __s[9];
> + te.dw3 = __entry->edw3;
> + tr.dw1 = __entry->rdw1;
> + snprintf(__s, 9, "ep%d%s", te.address, \
> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
> + te.caps.dir_in ? "in" : "out");
> )
> );
>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event
2023-09-14 16:54 ` Steven Rostedt
@ 2023-09-15 1:11 ` Linyu Yuan
2023-09-15 2:16 ` Steven Rostedt
0 siblings, 1 reply; 19+ messages in thread
From: Linyu Yuan @ 2023-09-15 1:11 UTC (permalink / raw)
To: Steven Rostedt
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Masami Hiramatsu, Greg Kroah-Hartman,
linux-usb, linux-trace-kernel
On 9/15/2023 12:54 AM, Steven Rostedt wrote:
> On Thu, 14 Sep 2023 18:02:57 +0800
> Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
>
>> Save u32 members into trace event ring buffer and parse it for possible
>> bit fields.
>>
>> Use new DECLARE_EVENT_CLASS_PRINT_INIT() class macro for output stage.
>>
>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>> ---
>> drivers/usb/gadget/udc/trace.h | 154 +++++++++++++++------------------
>> 1 file changed, 69 insertions(+), 85 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/trace.h b/drivers/usb/gadget/udc/trace.h
>> index a5ed26fbc2da..e1754667f1d2 100644
>> --- a/drivers/usb/gadget/udc/trace.h
>> +++ b/drivers/usb/gadget/udc/trace.h
>> @@ -17,7 +17,7 @@
>> #include <asm/byteorder.h>
>> #include <linux/usb/gadget.h>
>>
>> -DECLARE_EVENT_CLASS(udc_log_gadget,
>> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_gadget,
>> TP_PROTO(struct usb_gadget *g, int ret),
>> TP_ARGS(g, ret),
>> TP_STRUCT__entry(
>> @@ -25,20 +25,7 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
>> __field(enum usb_device_speed, max_speed)
>> __field(enum usb_device_state, state)
>> __field(unsigned, mA)
>> - __field(unsigned, sg_supported)
>> - __field(unsigned, is_otg)
>> - __field(unsigned, is_a_peripheral)
>> - __field(unsigned, b_hnp_enable)
>> - __field(unsigned, a_hnp_support)
>> - __field(unsigned, hnp_polling_support)
>> - __field(unsigned, host_request_flag)
>> - __field(unsigned, quirk_ep_out_aligned_size)
>> - __field(unsigned, quirk_altset_not_supp)
>> - __field(unsigned, quirk_stall_not_supp)
>> - __field(unsigned, quirk_zlp_not_supp)
>> - __field(unsigned, is_selfpowered)
>> - __field(unsigned, deactivated)
>> - __field(unsigned, connected)
>> + __field(u32, gdw1)
>> __field(int, ret)
>> ),
>> TP_fast_assign(
>> @@ -46,39 +33,35 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
>> __entry->max_speed = g->max_speed;
>> __entry->state = g->state;
>> __entry->mA = g->mA;
>> - __entry->sg_supported = g->sg_supported;
>> - __entry->is_otg = g->is_otg;
>> - __entry->is_a_peripheral = g->is_a_peripheral;
>> - __entry->b_hnp_enable = g->b_hnp_enable;
>> - __entry->a_hnp_support = g->a_hnp_support;
>> - __entry->hnp_polling_support = g->hnp_polling_support;
>> - __entry->host_request_flag = g->host_request_flag;
>> - __entry->quirk_ep_out_aligned_size = g->quirk_ep_out_aligned_size;
>> - __entry->quirk_altset_not_supp = g->quirk_altset_not_supp;
>> - __entry->quirk_stall_not_supp = g->quirk_stall_not_supp;
>> - __entry->quirk_zlp_not_supp = g->quirk_zlp_not_supp;
>> - __entry->is_selfpowered = g->is_selfpowered;
>> - __entry->deactivated = g->deactivated;
>> - __entry->connected = g->connected;
>> + __entry->gdw1 = g->dw1;
>> __entry->ret = ret;
>> ),
>> - TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
>> + TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
>> __entry->speed, __entry->max_speed, __entry->state, __entry->mA,
>> - __entry->sg_supported ? "sg:" : "",
>> - __entry->is_otg ? "OTG:" : "",
>> - __entry->is_a_peripheral ? "a_peripheral:" : "",
>> - __entry->b_hnp_enable ? "b_hnp:" : "",
>> - __entry->a_hnp_support ? "a_hnp:" : "",
>> - __entry->hnp_polling_support ? "hnp_poll:" : "",
>> - __entry->host_request_flag ? "hostreq:" : "",
>> - __entry->quirk_ep_out_aligned_size ? "out_aligned:" : "",
>> - __entry->quirk_altset_not_supp ? "no_altset:" : "",
>> - __entry->quirk_stall_not_supp ? "no_stall:" : "",
>> - __entry->quirk_zlp_not_supp ? "no_zlp" : "",
>> - __entry->is_selfpowered ? "self-powered:" : "bus-powered:",
>> - __entry->deactivated ? "deactivated:" : "activated:",
>> - __entry->connected ? "connected" : "disconnected",
>> - __entry->ret)
>> + tg.sg_supported ? "sg:" : "",
>> + tg.is_otg ? "OTG:" : "",
>> + tg.is_a_peripheral ? "a_peripheral:" : "",
>> + tg.b_hnp_enable ? "b_hnp:" : "",
>> + tg.a_hnp_support ? "a_hnp:" : "",
>> + tg.a_alt_hnp_support ? "a_alt_hnp:" : "",
>> + tg.hnp_polling_support ? "hnp_poll:" : "",
>> + tg.host_request_flag ? "hostreq:" : "",
>> + tg.quirk_ep_out_aligned_size ? "out_aligned:" : "",
>> + tg.quirk_altset_not_supp ? "no_altset:" : "",
>> + tg.quirk_stall_not_supp ? "no_stall:" : "",
>> + tg.quirk_zlp_not_supp ? "no_zlp" : "",
>> + tg.quirk_avoids_skb_reserve ? "no_skb_reserve" : "",
>> + tg.is_selfpowered ? "self-powered:" : "bus-powered:",
>> + tg.deactivated ? "deactivated:" : "activated:",
>> + tg.connected ? "connected" : "disconnected",
>> + tg.lpm_capable ? "lpm-capable" : "",
>> + tg.wakeup_capable ? "wakeup-capable" : "",
>> + tg.wakeup_armed ? "wakeup-armed" : "",
> You can accomplish the above using __print_flags(), if you make it into a
> bitmask, and that make a macro for each bit.
thanks for suggestion, good idea.
>
>> + __entry->ret),
>> + TP_printk_init(
>> + struct usb_gadget tg;
>> + tg.dw1 = __entry->gdw1;
>> + )
>> );
>>
>> DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
>> @@ -141,38 +124,36 @@ DEFINE_EVENT(udc_log_gadget, usb_gadget_activate,
>> TP_ARGS(g, ret)
>> );
>>
>> -DECLARE_EVENT_CLASS(udc_log_ep,
>> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_ep,
>> TP_PROTO(struct usb_ep *ep, int ret),
>> TP_ARGS(ep, ret),
>> TP_STRUCT__entry(
>> - __string(name, ep->name)
>> - __field(unsigned, maxpacket)
>> - __field(unsigned, maxpacket_limit)
>> - __field(unsigned, max_streams)
>> - __field(unsigned, mult)
>> - __field(unsigned, maxburst)
>> - __field(u8, address)
>> - __field(bool, claimed)
>> - __field(bool, enabled)
>> + __field(u32, edw3)
>> + __field(u32, edw1)
>> + __field(u32, edw2)
>> __field(int, ret)
>> ),
>> TP_fast_assign(
>> - __assign_str(name, ep->name);
>> - __entry->maxpacket = ep->maxpacket;
>> - __entry->maxpacket_limit = ep->maxpacket_limit;
>> - __entry->max_streams = ep->max_streams;
>> - __entry->mult = ep->mult;
>> - __entry->maxburst = ep->maxburst;
>> - __entry->address = ep->address,
>> - __entry->claimed = ep->claimed;
>> - __entry->enabled = ep->enabled;
>> + __entry->edw3 = ep->dw3;
>> + __entry->edw1 = ep->dw1;
>> + __entry->edw2 = ep->dw2;
>> __entry->ret = ret;
>> ),
>> TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
>> - __get_str(name), __entry->maxpacket, __entry->maxpacket_limit,
>> - __entry->max_streams, __entry->mult, __entry->maxburst,
>> - __entry->address, __entry->claimed ? "claimed:" : "released:",
>> - __entry->enabled ? "enabled" : "disabled", ret)
>> + __s, te.maxpacket, te.maxpacket_limit,
>> + te.max_streams, te.mult, te.maxburst,
>> + te.address, te.claimed ? "claimed:" : "released:",
>> + te.enabled ? "enabled" : "disabled", ret),
>> + TP_printk_init(
>> + struct usb_ep te;
>> + char __s[9];
>> + te.dw1 = __entry->edw1;
>> + te.dw2 = __entry->edw2;
>> + te.dw3 = __entry->edw3;
>> + snprintf(__s, 9, "ep%d%s", te.address, \
>> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
>> + te.caps.dir_in ? "in" : "out");
> Note, there's a temp buffer trace_seq 'p' available for use as well. See
> both include/trace/events/libata.h and include/trace/events/scsi.h:
>
> const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
> #define __parse_status(s) libata_trace_parse_status(p, s)
>
> I think that can be used instead of adding this TP_printk_init().
the reason add TP_printk_init() because when i first design some macro
which not
related to tracepoint, it use too much stack.
but i think TP_printk_init() is good as it following most common way
to print.
>
> -- Steve
>
>
>> + )
>> );
>>
>> DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit,
>> @@ -215,44 +196,47 @@ DEFINE_EVENT(udc_log_ep, usb_ep_fifo_flush,
>> TP_ARGS(ep, ret)
>> );
>>
>> -DECLARE_EVENT_CLASS(udc_log_req,
>> +DECLARE_EVENT_CLASS_PRINT_INIT(udc_log_req,
>> TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
>> TP_ARGS(ep, req, ret),
>> TP_STRUCT__entry(
>> - __string(name, ep->name)
>> + __field(u32, edw3)
>> __field(unsigned, length)
>> __field(unsigned, actual)
>> __field(unsigned, num_sgs)
>> __field(unsigned, num_mapped_sgs)
>> - __field(unsigned, stream_id)
>> - __field(unsigned, no_interrupt)
>> - __field(unsigned, zero)
>> - __field(unsigned, short_not_ok)
>> + __field(u32, rdw1)
>> __field(int, status)
>> __field(int, ret)
>> __field(struct usb_request *, req)
>> ),
>> TP_fast_assign(
>> - __assign_str(name, ep->name);
>> + __entry->edw3 = ep->dw3;
>> __entry->length = req->length;
>> __entry->actual = req->actual;
>> __entry->num_sgs = req->num_sgs;
>> __entry->num_mapped_sgs = req->num_mapped_sgs;
>> - __entry->stream_id = req->stream_id;
>> - __entry->no_interrupt = req->no_interrupt;
>> - __entry->zero = req->zero;
>> - __entry->short_not_ok = req->short_not_ok;
>> + __entry->rdw1 = req->dw1;
>> __entry->status = req->status;
>> __entry->ret = ret;
>> __entry->req = req;
>> ),
>> TP_printk("%s: req %p length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
>> - __get_str(name),__entry->req, __entry->actual, __entry->length,
>> - __entry->num_mapped_sgs, __entry->num_sgs, __entry->stream_id,
>> - __entry->zero ? "Z" : "z",
>> - __entry->short_not_ok ? "S" : "s",
>> - __entry->no_interrupt ? "i" : "I",
>> - __entry->status, __entry->ret
>> + __s,__entry->req, __entry->actual, __entry->length,
>> + __entry->num_mapped_sgs, __entry->num_sgs, tr.stream_id,
>> + tr.zero ? "Z" : "z",
>> + tr.short_not_ok ? "S" : "s",
>> + tr.no_interrupt ? "i" : "I",
>> + __entry->status, __entry->ret),
>> + TP_printk_init(
>> + struct usb_ep te;
>> + struct usb_request tr;
>> + char __s[9];
>> + te.dw3 = __entry->edw3;
>> + tr.dw1 = __entry->rdw1;
>> + snprintf(__s, 9, "ep%d%s", te.address, \
>> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
>> + te.caps.dir_in ? "in" : "out");
>> )
>> );
>>
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event
2023-09-15 1:11 ` Linyu Yuan
@ 2023-09-15 2:16 ` Steven Rostedt
2023-09-15 2:25 ` Linyu Yuan
0 siblings, 1 reply; 19+ messages in thread
From: Steven Rostedt @ 2023-09-15 2:16 UTC (permalink / raw)
To: Linyu Yuan
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Masami Hiramatsu, Greg Kroah-Hartman,
linux-usb, linux-trace-kernel
On Fri, 15 Sep 2023 09:11:06 +0800
Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
> >> + snprintf(__s, 9, "ep%d%s", te.address, \
> >> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
> >> + te.caps.dir_in ? "in" : "out");
> > Note, there's a temp buffer trace_seq 'p' available for use as well. See
> > both include/trace/events/libata.h and include/trace/events/scsi.h:
> >
> > const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
> > #define __parse_status(s) libata_trace_parse_status(p, s)
> >
> > I think that can be used instead of adding this TP_printk_init().
>
>
> the reason add TP_printk_init() because when i first design some macro
> which not
>
> related to tracepoint, it use too much stack.
>
Not sure what you mean about 'uses too much stack'. This is called by
the reading code and not some arbitrary location, and the above macros
are done in the same location as your "init" call, so I'm not sure how
that makes a difference on the stack.
>
> but i think TP_printk_init() is good as it following most common way
> to print.
>
I really do not want to add more versions of TRACE_EVENT() that I need
to maintain unless there is a really good reason to do so.
And I really don't want to encourage the use of a "TP_printk_init()"
because that just encourages more use cases that will make it hard for
user space to parse the TP_printk().
-- Steve
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event
2023-09-15 2:16 ` Steven Rostedt
@ 2023-09-15 2:25 ` Linyu Yuan
0 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-15 2:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Masami Hiramatsu, Greg Kroah-Hartman,
linux-usb, linux-trace-kernel
On 9/15/2023 10:16 AM, Steven Rostedt wrote:
> On Fri, 15 Sep 2023 09:11:06 +0800
> Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
>
>>>> + snprintf(__s, 9, "ep%d%s", te.address, \
>>>> + (te.caps.dir_in && te.caps.dir_out) ? "" : \
>>>> + te.caps.dir_in ? "in" : "out");
>>> Note, there's a temp buffer trace_seq 'p' available for use as well. See
>>> both include/trace/events/libata.h and include/trace/events/scsi.h:
>>>
>>> const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
>>> #define __parse_status(s) libata_trace_parse_status(p, s)
>>>
>>> I think that can be used instead of adding this TP_printk_init().
>>
>> the reason add TP_printk_init() because when i first design some macro
>> which not
>>
>> related to tracepoint, it use too much stack.
>>
> Not sure what you mean about 'uses too much stack'. This is called by
> the reading code and not some arbitrary location, and the above macros
> are done in the same location as your "init" call, so I'm not sure how
> that makes a difference on the stack.
>
>> but i think TP_printk_init() is good as it following most common way
>> to print.
>>
> I really do not want to add more versions of TRACE_EVENT() that I need
> to maintain unless there is a really good reason to do so.
>
> And I really don't want to encourage the use of a "TP_printk_init()"
> because that just encourages more use cases that will make it hard for
> user space to parse the TP_printk().
that's true, it is difficult to understand, when i add this new, it
report build issue.
will consider other way for this case without new tracepoint macro.
>
> -- Steve
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/8] usb: cdns3: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (2 preceding siblings ...)
2023-09-14 10:02 ` [PATCH 3/8] usb: udc: trace: reduce buffer usage of trace event Linyu Yuan
@ 2023-09-14 10:02 ` Linyu Yuan
2023-09-14 10:02 ` [PATCH 5/8] usb: dwc3: " Linyu Yuan
` (4 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:02 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 members into trace event ring buffer and parse it for possible
bit information.
Use DECLARE_EVENT_CLASS_PRINT_INIT() related macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/cdns3/cdns3-trace.h | 201 ++++++++++++++++++++++----------
drivers/usb/cdns3/cdnsp-trace.h | 105 +++++++++++------
2 files changed, 209 insertions(+), 97 deletions(-)
diff --git a/drivers/usb/cdns3/cdns3-trace.h b/drivers/usb/cdns3/cdns3-trace.h
index 40db89e3333c..9711d4b48eb6 100644
--- a/drivers/usb/cdns3/cdns3-trace.h
+++ b/drivers/usb/cdns3/cdns3-trace.h
@@ -24,49 +24,73 @@
#define CDNS3_MSG_MAX 500
-TRACE_EVENT(cdns3_halt,
+TRACE_EVENT_PRINT_INIT(cdns3_halt,
TP_PROTO(struct cdns3_endpoint *ep_priv, u8 halt, u8 flush),
TP_ARGS(ep_priv, halt, flush),
TP_STRUCT__entry(
- __string(name, ep_priv->name)
+ __field(u32, edw3)
__field(u8, halt)
__field(u8, flush)
),
TP_fast_assign(
- __assign_str(name, ep_priv->name);
+ __entry->edw3 = ep_priv->endpoint.dw3;
__entry->halt = halt;
__entry->flush = flush;
),
TP_printk("Halt %s for %s: %s", __entry->flush ? " and flush" : "",
- __get_str(name), __entry->halt ? "set" : "cleared")
+ __s, __entry->halt ? "set" : "cleared"),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
-TRACE_EVENT(cdns3_wa1,
+TRACE_EVENT_PRINT_INIT(cdns3_wa1,
TP_PROTO(struct cdns3_endpoint *ep_priv, char *msg),
TP_ARGS(ep_priv, msg),
TP_STRUCT__entry(
- __string(ep_name, ep_priv->name)
+ __field(u32, edw3)
__string(msg, msg)
),
TP_fast_assign(
- __assign_str(ep_name, ep_priv->name);
+ __entry->edw3 = ep_priv->endpoint.dw3;
__assign_str(msg, msg);
),
- TP_printk("WA1: %s %s", __get_str(ep_name), __get_str(msg))
+ TP_printk("WA1: %s %s", __s, __get_str(msg)),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
-TRACE_EVENT(cdns3_wa2,
+TRACE_EVENT_PRINT_INIT(cdns3_wa2,
TP_PROTO(struct cdns3_endpoint *ep_priv, char *msg),
TP_ARGS(ep_priv, msg),
TP_STRUCT__entry(
- __string(ep_name, ep_priv->name)
+ __field(u32, edw3)
__string(msg, msg)
),
TP_fast_assign(
- __assign_str(ep_name, ep_priv->name);
+ __entry->edw3 = ep_priv->endpoint.dw3;
__assign_str(msg, msg);
),
- TP_printk("WA2: %s %s", __get_str(ep_name), __get_str(msg))
+ TP_printk("WA2: %s %s", __s, __get_str(msg)),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DECLARE_EVENT_CLASS(cdns3_log_doorbell,
@@ -114,18 +138,18 @@ DEFINE_EVENT(cdns3_log_usb_irq, cdns3_usb_irq,
TP_ARGS(priv_dev, usb_ists)
);
-DECLARE_EVENT_CLASS(cdns3_log_epx_irq,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_epx_irq,
TP_PROTO(struct cdns3_device *priv_dev, struct cdns3_endpoint *priv_ep),
TP_ARGS(priv_dev, priv_ep),
TP_STRUCT__entry(
- __string(ep_name, priv_ep->name)
+ __field(u32, edw3)
__field(u32, ep_sts)
__field(u32, ep_traddr)
__field(u32, ep_last_sid)
__field(u32, use_streams)
),
TP_fast_assign(
- __assign_str(ep_name, priv_ep->name);
+ __entry->edw3 = priv_ep->endpoint.dw3;
__entry->ep_sts = readl(&priv_dev->regs->ep_sts);
__entry->ep_traddr = readl(&priv_dev->regs->ep_traddr);
__entry->ep_last_sid = priv_ep->last_stream_id;
@@ -133,11 +157,19 @@ DECLARE_EVENT_CLASS(cdns3_log_epx_irq,
),
TP_printk("%s, ep_traddr: %08x ep_last_sid: %08x use_streams: %d",
cdns3_decode_epx_irq(__get_buf(CDNS3_MSG_MAX),
- __get_str(ep_name),
+ __s,
__entry->ep_sts),
__entry->ep_traddr,
__entry->ep_last_sid,
- __entry->use_streams)
+ __entry->use_streams),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdns3_log_epx_irq, cdns3_epx_irq,
@@ -195,51 +227,56 @@ DEFINE_EVENT(cdns3_log_ctrl, cdns3_ctrl_req,
TP_ARGS(ctrl)
);
-DECLARE_EVENT_CLASS(cdns3_log_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_request,
TP_PROTO(struct cdns3_request *req),
TP_ARGS(req),
TP_STRUCT__entry(
- __string(name, req->priv_ep->name)
+ __field(u32, edw3)
__field(struct cdns3_request *, req)
__field(void *, buf)
__field(unsigned int, actual)
__field(unsigned int, length)
__field(int, status)
- __field(int, zero)
- __field(int, short_not_ok)
- __field(int, no_interrupt)
+ __field(u32, rdw1)
__field(int, start_trb)
__field(int, end_trb)
__field(int, flags)
__field(unsigned int, stream_id)
),
TP_fast_assign(
- __assign_str(name, req->priv_ep->name);
+ __entry->edw3 = req->priv_ep->endpoint.dw3;
__entry->req = req;
__entry->buf = req->request.buf;
__entry->actual = req->request.actual;
__entry->length = req->request.length;
__entry->status = req->request.status;
- __entry->zero = req->request.zero;
- __entry->short_not_ok = req->request.short_not_ok;
- __entry->no_interrupt = req->request.no_interrupt;
+ __entry->rdw1 = req->request.dw1;
__entry->start_trb = req->start_trb;
__entry->end_trb = req->end_trb;
__entry->flags = req->flags;
- __entry->stream_id = req->request.stream_id;
),
TP_printk("%s: req: %p, req buff %p, length: %u/%u %s%s%s, status: %d,"
" trb: [start:%d, end:%d], flags:%x SID: %u",
- __get_str(name), __entry->req, __entry->buf, __entry->actual,
+ __s, __entry->req, __entry->buf, __entry->actual,
__entry->length,
- __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "I" : "i",
+ tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "I" : "i",
__entry->status,
__entry->start_trb,
__entry->end_trb,
__entry->flags,
- __entry->stream_id
+ tr.stream_id
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -283,26 +320,34 @@ TRACE_EVENT(cdns3_ep0_queue,
__entry->length)
);
-DECLARE_EVENT_CLASS(cdns3_stream_split_transfer_len,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_stream_split_transfer_len,
TP_PROTO(struct cdns3_request *req),
TP_ARGS(req),
TP_STRUCT__entry(
- __string(name, req->priv_ep->name)
+ __field(u32, edw3)
__field(struct cdns3_request *, req)
__field(unsigned int, length)
__field(unsigned int, actual)
__field(unsigned int, stream_id)
),
TP_fast_assign(
- __assign_str(name, req->priv_ep->name);
+ __entry->edw3 = req->priv_ep->endpoint.dw3;
__entry->req = req;
__entry->actual = req->request.length;
__entry->length = req->request.actual;
__entry->stream_id = req->request.stream_id;
),
TP_printk("%s: req: %p,request length: %u actual length: %u SID: %u",
- __get_str(name), __entry->req, __entry->length,
- __entry->actual, __entry->stream_id)
+ __s, __entry->req, __entry->length,
+ __entry->actual, __entry->stream_id),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdns3_stream_split_transfer_len, cdns3_stream_transfer_split,
@@ -316,11 +361,11 @@ DEFINE_EVENT(cdns3_stream_split_transfer_len,
TP_ARGS(req)
);
-DECLARE_EVENT_CLASS(cdns3_log_aligned_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_aligned_request,
TP_PROTO(struct cdns3_request *priv_req),
TP_ARGS(priv_req),
TP_STRUCT__entry(
- __string(name, priv_req->priv_ep->name)
+ __field(u32, edw3)
__field(struct usb_request *, req)
__field(void *, buf)
__field(dma_addr_t, dma)
@@ -329,7 +374,7 @@ DECLARE_EVENT_CLASS(cdns3_log_aligned_request,
__field(u32, aligned_buf_size)
),
TP_fast_assign(
- __assign_str(name, priv_req->priv_ep->name);
+ __entry->edw3 = priv_req->priv_ep->endpoint.dw3;
__entry->req = &priv_req->request;
__entry->buf = priv_req->request.buf;
__entry->dma = priv_req->request.dma;
@@ -338,9 +383,17 @@ DECLARE_EVENT_CLASS(cdns3_log_aligned_request,
__entry->aligned_buf_size = priv_req->aligned_buf->size;
),
TP_printk("%s: req: %p, req buf %p, dma %pad a_buf %p a_dma %pad, size %d",
- __get_str(name), __entry->req, __entry->buf, &__entry->dma,
+ __s, __entry->req, __entry->buf, &__entry->dma,
__entry->aligned_buf, &__entry->aligned_dma,
__entry->aligned_buf_size
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -354,23 +407,31 @@ DEFINE_EVENT(cdns3_log_aligned_request, cdns3_prepare_aligned_request,
TP_ARGS(req)
);
-DECLARE_EVENT_CLASS(cdns3_log_map_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_map_request,
TP_PROTO(struct cdns3_request *priv_req),
TP_ARGS(priv_req),
TP_STRUCT__entry(
- __string(name, priv_req->priv_ep->name)
+ __field(u32, edw3)
__field(struct usb_request *, req)
__field(void *, buf)
__field(dma_addr_t, dma)
),
TP_fast_assign(
- __assign_str(name, priv_req->priv_ep->name);
+ __entry->edw3 = priv_req->priv_ep->endpoint.dw3;
__entry->req = &priv_req->request;
__entry->buf = priv_req->request.buf;
__entry->dma = priv_req->request.dma;
),
TP_printk("%s: req: %p, req buf %p, dma %p",
- __get_str(name), __entry->req, __entry->buf, &__entry->dma
+ __s, __entry->req, __entry->buf, &__entry->dma
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
DEFINE_EVENT(cdns3_log_map_request, cdns3_map_request,
@@ -382,11 +443,11 @@ DEFINE_EVENT(cdns3_log_map_request, cdns3_mapped_request,
TP_ARGS(req)
);
-DECLARE_EVENT_CLASS(cdns3_log_trb,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_trb,
TP_PROTO(struct cdns3_endpoint *priv_ep, struct cdns3_trb *trb),
TP_ARGS(priv_ep, trb),
TP_STRUCT__entry(
- __string(name, priv_ep->name)
+ __field(u32, edw3)
__field(struct cdns3_trb *, trb)
__field(u32, buffer)
__field(u32, length)
@@ -395,7 +456,7 @@ DECLARE_EVENT_CLASS(cdns3_log_trb,
__field(unsigned int, last_stream_id)
),
TP_fast_assign(
- __assign_str(name, priv_ep->name);
+ __entry->edw3 = priv_ep->endpoint.dw3;
__entry->trb = trb;
__entry->buffer = le32_to_cpu(trb->buffer);
__entry->length = le32_to_cpu(trb->length);
@@ -404,7 +465,7 @@ DECLARE_EVENT_CLASS(cdns3_log_trb,
__entry->last_stream_id = priv_ep->last_stream_id;
),
TP_printk("%s: trb %p, dma buf: 0x%08x, size: %ld, burst: %d ctrl: 0x%08x (%s%s%s%s%s%s%s) SID:%lu LAST_SID:%u",
- __get_str(name), __entry->trb, __entry->buffer,
+ __s, __entry->trb, __entry->buffer,
TRB_LEN(__entry->length),
(u8)TRB_BURST_LEN_GET(__entry->length),
__entry->control,
@@ -417,6 +478,14 @@ DECLARE_EVENT_CLASS(cdns3_log_trb,
TRB_FIELD_TO_TYPE(__entry->control) == TRB_NORMAL ? "Normal" : "LINK",
TRB_FIELD_TO_STREAMID(__entry->control),
__entry->last_stream_id
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -451,28 +520,24 @@ DEFINE_EVENT(cdns3_log_ring, cdns3_ring,
TP_ARGS(priv_ep)
);
-DECLARE_EVENT_CLASS(cdns3_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns3_log_ep,
TP_PROTO(struct cdns3_endpoint *priv_ep),
TP_ARGS(priv_ep),
TP_STRUCT__entry(
- __string(name, priv_ep->name)
- __field(unsigned int, maxpacket)
- __field(unsigned int, maxpacket_limit)
- __field(unsigned int, max_streams)
+ __field(u32, edw3)
+ __field(u32, edw1)
+ __field(u32, edw2)
__field(unsigned int, use_streams)
- __field(unsigned int, maxburst)
__field(unsigned int, flags)
__field(unsigned int, dir)
__field(u8, enqueue)
__field(u8, dequeue)
),
TP_fast_assign(
- __assign_str(name, priv_ep->name);
- __entry->maxpacket = priv_ep->endpoint.maxpacket;
- __entry->maxpacket_limit = priv_ep->endpoint.maxpacket_limit;
- __entry->max_streams = priv_ep->endpoint.max_streams;
+ __entry->edw3 = priv_ep->endpoint.dw3;
+ __entry->edw2 = priv_ep->endpoint.dw2;
+ __entry->edw1 = priv_ep->endpoint.dw1;
__entry->use_streams = priv_ep->use_streams;
- __entry->maxburst = priv_ep->endpoint.maxburst;
__entry->flags = priv_ep->flags;
__entry->dir = priv_ep->dir;
__entry->enqueue = priv_ep->enqueue;
@@ -480,10 +545,10 @@ DECLARE_EVENT_CLASS(cdns3_log_ep,
),
TP_printk("%s: mps: %d/%d. streams: %d, stream enable: %d, burst: %d, "
"enq idx: %d, deq idx: %d, flags %s%s%s%s%s%s%s%s, dir: %s",
- __get_str(name), __entry->maxpacket,
- __entry->maxpacket_limit, __entry->max_streams,
+ __s, te.maxpacket,
+ te.maxpacket_limit, te.max_streams,
__entry->use_streams,
- __entry->maxburst, __entry->enqueue,
+ te.maxburst, __entry->enqueue,
__entry->dequeue,
__entry->flags & EP_ENABLED ? "EN | " : "",
__entry->flags & EP_STALLED ? "STALLED | " : "",
@@ -494,6 +559,16 @@ DECLARE_EVENT_CLASS(cdns3_log_ep,
__entry->flags & EP_RING_FULL ? "RING FULL |" : "",
__entry->flags & EP_CLAIMED ? "CLAIMED " : "",
__entry->dir ? "IN" : "OUT"
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw1 = __entry->edw1;
+ te.dw2 = __entry->edw2;
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
diff --git a/drivers/usb/cdns3/cdnsp-trace.h b/drivers/usb/cdns3/cdnsp-trace.h
index 4b51011eb00b..e749e80a2ee1 100644
--- a/drivers/usb/cdns3/cdnsp-trace.h
+++ b/drivers/usb/cdns3/cdnsp-trace.h
@@ -34,11 +34,11 @@
*/
#define CDNSP_MSG_MAX 500
-DECLARE_EVENT_CLASS(cdnsp_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdnsp_log_ep,
TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
TP_ARGS(pep, stream_id),
TP_STRUCT__entry(
- __string(name, pep->name)
+ __field(u32, edw3)
__field(unsigned int, state)
__field(u32, stream_id)
__field(u8, enabled)
@@ -48,7 +48,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_ep,
__field(u8, drbls_count)
),
TP_fast_assign(
- __assign_str(name, pep->name);
+ __entry->edw3 = pep->endpoint.dw3;
__entry->state = pep->ep_state;
__entry->stream_id = stream_id;
__entry->enabled = pep->ep_state & EP_HAS_STREAMS;
@@ -59,9 +59,17 @@ DECLARE_EVENT_CLASS(cdnsp_log_ep,
),
TP_printk("%s: SID: %08x, ep state: %x, stream: enabled: %d num %d "
"tds %d, first prime: %d drbls %d",
- __get_str(name), __entry->stream_id, __entry->state,
+ __s, __entry->stream_id, __entry->state,
__entry->enabled, __entry->num_streams, __entry->td_count,
- __entry->first_prime_det, __entry->drbls_count)
+ __entry->first_prime_det, __entry->drbls_count),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdnsp_log_ep, cdnsp_tr_drbl,
@@ -291,27 +299,35 @@ DEFINE_EVENT(cdnsp_log_ctrl, cdnsp_ctrl_req,
TP_ARGS(ctrl)
);
-DECLARE_EVENT_CLASS(cdnsp_log_bounce,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdnsp_log_bounce,
TP_PROTO(struct cdnsp_request *preq, u32 new_buf_len, u32 offset,
dma_addr_t dma, unsigned int unalign),
TP_ARGS(preq, new_buf_len, offset, dma, unalign),
TP_STRUCT__entry(
- __string(name, preq->pep->name)
+ __field(u32, edw3)
__field(u32, new_buf_len)
__field(u32, offset)
__field(dma_addr_t, dma)
__field(unsigned int, unalign)
),
TP_fast_assign(
- __assign_str(name, preq->pep->name);
+ __entry->edw3 = preq->pep->endpoint.dw3;
__entry->new_buf_len = new_buf_len;
__entry->offset = offset;
__entry->dma = dma;
__entry->unalign = unalign;
),
TP_printk("%s buf len %d, offset %d, dma %pad, unalign %d",
- __get_str(name), __entry->new_buf_len,
+ __s, __entry->new_buf_len,
__entry->offset, &__entry->dma, __entry->unalign
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -448,11 +464,11 @@ DEFINE_EVENT(cdnsp_log_pdev, cdnsp_setup_addressable_priv_device,
TP_ARGS(vdev)
);
-DECLARE_EVENT_CLASS(cdnsp_log_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdnsp_log_request,
TP_PROTO(struct cdnsp_request *req),
TP_ARGS(req),
TP_STRUCT__entry(
- __string(name, req->pep->name)
+ __field(u32, edw3)
__field(struct usb_request *, request)
__field(struct cdnsp_request *, preq)
__field(void *, buf)
@@ -460,17 +476,14 @@ DECLARE_EVENT_CLASS(cdnsp_log_request,
__field(unsigned int, length)
__field(int, status)
__field(dma_addr_t, dma)
- __field(unsigned int, stream_id)
- __field(unsigned int, zero)
- __field(unsigned int, short_not_ok)
- __field(unsigned int, no_interrupt)
+ __field(u32, rdw1)
__field(struct scatterlist*, sg)
__field(unsigned int, num_sgs)
__field(unsigned int, num_mapped_sgs)
),
TP_fast_assign(
- __assign_str(name, req->pep->name);
+ __entry->edw3 = req->pep->endpoint.dw3;
__entry->request = &req->request;
__entry->preq = req;
__entry->buf = req->request.buf;
@@ -478,10 +491,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_request,
__entry->length = req->request.length;
__entry->status = req->request.status;
__entry->dma = req->request.dma;
- __entry->stream_id = req->request.stream_id;
- __entry->zero = req->request.zero;
- __entry->short_not_ok = req->request.short_not_ok;
- __entry->no_interrupt = req->request.no_interrupt;
+ __entry->rdw1 = req->request.dw1;
__entry->sg = req->request.sg;
__entry->num_sgs = req->request.num_sgs;
__entry->num_mapped_sgs = req->request.num_mapped_sgs;
@@ -489,14 +499,24 @@ DECLARE_EVENT_CLASS(cdnsp_log_request,
TP_printk("%s; req U:%p/P:%p, req buf %p, length %u/%u, status %d, "
"buf dma (%pad), SID %u, %s%s%s, sg %p, num_sg %d,"
" num_m_sg %d",
- __get_str(name), __entry->request, __entry->preq,
+ __s, __entry->request, __entry->preq,
__entry->buf, __entry->actual, __entry->length,
__entry->status, &__entry->dma,
- __entry->stream_id, __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "I" : "i",
+ tr.stream_id, tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "I" : "i",
__entry->sg, __entry->num_sgs, __entry->num_mapped_sgs
- )
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdnsp_log_request, cdnsp_request_enqueue,
@@ -662,11 +682,11 @@ DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_configure_endpoint,
TP_ARGS(ctx)
);
-DECLARE_EVENT_CLASS(cdnsp_log_td_info,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdnsp_log_td_info,
TP_PROTO(struct cdnsp_request *preq),
TP_ARGS(preq),
TP_STRUCT__entry(
- __string(name, preq->pep->name)
+ __field(u32, edw3)
__field(struct usb_request *, request)
__field(struct cdnsp_request *, preq)
__field(union cdnsp_trb *, first_trb)
@@ -674,7 +694,7 @@ DECLARE_EVENT_CLASS(cdnsp_log_td_info,
__field(dma_addr_t, trb_dma)
),
TP_fast_assign(
- __assign_str(name, preq->pep->name);
+ __entry->edw3 = preq->pep->endpoint.dw3;
__entry->request = &preq->request;
__entry->preq = preq;
__entry->first_trb = preq->td.first_trb;
@@ -683,10 +703,18 @@ DECLARE_EVENT_CLASS(cdnsp_log_td_info,
preq->td.first_trb)
),
TP_printk("%s req/preq: %p/%p, first trb %p[vir]/%pad(dma), last trb %p",
- __get_str(name), __entry->request, __entry->preq,
+ __s, __entry->request, __entry->preq,
__entry->first_trb, &__entry->trb_dma,
__entry->last_trb
- )
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdnsp_log_td_info, cdnsp_remove_request_td,
@@ -796,21 +824,30 @@ DEFINE_EVENT(cdnsp_log_portsc, cdnsp_link_state_changed,
TP_ARGS(portnum, portsc)
);
-TRACE_EVENT(cdnsp_stream_number,
+TRACE_EVENT_PRINT_INIT(cdnsp_stream_number,
TP_PROTO(struct cdnsp_ep *pep, int num_stream_ctxs, int num_streams),
TP_ARGS(pep, num_stream_ctxs, num_streams),
TP_STRUCT__entry(
- __string(name, pep->name)
+ __field(u32, edw3)
__field(int, num_stream_ctxs)
__field(int, num_streams)
),
TP_fast_assign(
+ __entry->edw3 = pep->endpoint.dw3;
__entry->num_stream_ctxs = num_stream_ctxs;
__entry->num_streams = num_streams;
),
TP_printk("%s Need %u stream ctx entries for %u stream IDs.",
- __get_str(name), __entry->num_stream_ctxs,
- __entry->num_streams)
+ __s, __entry->num_stream_ctxs,
+ __entry->num_streams),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
#endif /* __CDNSP_TRACE_H */
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 5/8] usb: dwc3: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (3 preceding siblings ...)
2023-09-14 10:02 ` [PATCH 4/8] usb: cdns3: " Linyu Yuan
@ 2023-09-14 10:02 ` Linyu Yuan
2023-09-14 10:03 ` [PATCH 6/8] usb: cdns2: " Linyu Yuan
` (3 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:02 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 members into trace event ring buffer and parse it for possible
bit information.
Use DECLARE_EVENT_CLASS_PRINT_INIT() related macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/dwc3/trace.h | 99 +++++++++++++++++++++++++---------------
1 file changed, 63 insertions(+), 36 deletions(-)
diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
index d2997d17cfbe..3caac180b225 100644
--- a/drivers/usb/dwc3/trace.h
+++ b/drivers/usb/dwc3/trace.h
@@ -98,35 +98,41 @@ DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
TP_ARGS(ctrl)
);
-DECLARE_EVENT_CLASS(dwc3_log_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(dwc3_log_request,
TP_PROTO(struct dwc3_request *req),
TP_ARGS(req),
TP_STRUCT__entry(
- __string(name, req->dep->name)
+ __field(u32, edw3)
__field(struct dwc3_request *, req)
__field(unsigned int, actual)
__field(unsigned int, length)
__field(int, status)
- __field(int, zero)
- __field(int, short_not_ok)
- __field(int, no_interrupt)
+ __field(u32, rdw1)
),
TP_fast_assign(
- __assign_str(name, req->dep->name);
+ __entry->edw3 = req->dep->endpoint.dw3;
__entry->req = req;
__entry->actual = req->request.actual;
__entry->length = req->request.length;
__entry->status = req->request.status;
- __entry->zero = req->request.zero;
- __entry->short_not_ok = req->request.short_not_ok;
- __entry->no_interrupt = req->request.no_interrupt;
+ __entry->rdw1 = req->request.dw1;
),
TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
- __get_str(name), __entry->req, __entry->actual, __entry->length,
- __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "i" : "I",
+ __s, __entry->req, __entry->actual, __entry->length,
+ tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "i" : "I",
__entry->status
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -180,12 +186,12 @@ DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
TP_ARGS(cmd, param, status)
);
-DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
+DECLARE_EVENT_CLASS_PRINT_INIT(dwc3_log_gadget_ep_cmd,
TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
TP_ARGS(dep, cmd, params, cmd_status),
TP_STRUCT__entry(
- __string(name, dep->name)
+ __field(u32, edw3)
__field(unsigned int, cmd)
__field(u32, param0)
__field(u32, param1)
@@ -193,7 +199,7 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
__field(int, cmd_status)
),
TP_fast_assign(
- __assign_str(name, dep->name);
+ __entry->edw3 = dep->endpoint.dw3;
__entry->cmd = cmd;
__entry->param0 = params->param0;
__entry->param1 = params->param1;
@@ -201,10 +207,18 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
__entry->cmd_status = cmd_status;
),
TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s",
- __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
+ __s, dwc3_gadget_ep_cmd_string(__entry->cmd),
__entry->cmd, __entry->param0,
__entry->param1, __entry->param2,
dwc3_ep_cmd_status_string(__entry->cmd_status)
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -214,11 +228,11 @@ DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
TP_ARGS(dep, cmd, params, cmd_status)
);
-DECLARE_EVENT_CLASS(dwc3_log_trb,
+DECLARE_EVENT_CLASS_PRINT_INIT(dwc3_log_trb,
TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
TP_ARGS(dep, trb),
TP_STRUCT__entry(
- __string(name, dep->name)
+ __field(u32, edw3)
__field(struct dwc3_trb *, trb)
__field(u32, bpl)
__field(u32, bph)
@@ -229,7 +243,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
__field(u32, dequeue)
),
TP_fast_assign(
- __assign_str(name, dep->name);
+ __entry->edw3 = dep->endpoint.dw3;
__entry->trb = trb;
__entry->bpl = trb->bpl;
__entry->bph = trb->bph;
@@ -240,7 +254,7 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
__entry->dequeue = dep->trb_dequeue;
),
TP_printk("%s: trb %p (E%d:D%d) buf %08x%08x size %s%d ctrl %08x sofn %08x (%c%c%c%c:%c%c:%s)",
- __get_str(name), __entry->trb, __entry->enqueue,
+ __s, __entry->trb, __entry->enqueue,
__entry->dequeue, __entry->bph, __entry->bpl,
({char *s;
int pcm = ((__entry->size >> 24) & 3) + 1;
@@ -272,7 +286,14 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
__entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
__entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
__entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
- dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
+ dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -286,35 +307,31 @@ DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
TP_ARGS(dep, trb)
);
-DECLARE_EVENT_CLASS(dwc3_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(dwc3_log_ep,
TP_PROTO(struct dwc3_ep *dep),
TP_ARGS(dep),
TP_STRUCT__entry(
- __string(name, dep->name)
- __field(unsigned int, maxpacket)
- __field(unsigned int, maxpacket_limit)
- __field(unsigned int, max_streams)
- __field(unsigned int, maxburst)
+ __field(u32, edw3)
+ __field(u32, edw1)
+ __field(u32, edw2)
__field(unsigned int, flags)
__field(unsigned int, direction)
__field(u8, trb_enqueue)
__field(u8, trb_dequeue)
),
TP_fast_assign(
- __assign_str(name, dep->name);
- __entry->maxpacket = dep->endpoint.maxpacket;
- __entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
- __entry->max_streams = dep->endpoint.max_streams;
- __entry->maxburst = dep->endpoint.maxburst;
+ __entry->edw3 = dep->endpoint.dw3;
+ __entry->edw1 = dep->endpoint.dw1;
+ __entry->edw2 = dep->endpoint.dw2;
__entry->flags = dep->flags;
__entry->direction = dep->direction;
__entry->trb_enqueue = dep->trb_enqueue;
__entry->trb_dequeue = dep->trb_dequeue;
),
TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c",
- __get_str(name), __entry->maxpacket,
- __entry->maxpacket_limit, __entry->max_streams,
- __entry->maxburst, __entry->trb_enqueue,
+ __s, te.maxpacket,
+ te.maxpacket_limit, te.max_streams,
+ te.maxburst, __entry->trb_enqueue,
__entry->trb_dequeue,
__entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
__entry->flags & DWC3_EP_STALL ? 'S' : 's',
@@ -322,6 +339,16 @@ DECLARE_EVENT_CLASS(dwc3_log_ep,
__entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b',
__entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
__entry->direction ? '<' : '>'
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw1 = __entry->edw1;
+ te.dw2 = __entry->edw2;
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 6/8] usb: cdns2: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (4 preceding siblings ...)
2023-09-14 10:02 ` [PATCH 5/8] usb: dwc3: " Linyu Yuan
@ 2023-09-14 10:03 ` Linyu Yuan
2023-09-14 10:03 ` [PATCH 7/8] usb: mtu3: " Linyu Yuan
` (2 subsequent siblings)
8 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:03 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 members into trace event ring buffer and parse it for possible
bit information.
Use DECLARE_EVENT_CLASS_PRINT_INIT() related macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/gadget/udc/cdns2/cdns2-trace.h | 175 ++++++++++++++-------
1 file changed, 121 insertions(+), 54 deletions(-)
diff --git a/drivers/usb/gadget/udc/cdns2/cdns2-trace.h b/drivers/usb/gadget/udc/cdns2/cdns2-trace.h
index 61f241634ea5..f81caa12cb63 100644
--- a/drivers/usb/gadget/udc/cdns2/cdns2-trace.h
+++ b/drivers/usb/gadget/udc/cdns2/cdns2-trace.h
@@ -94,51 +94,74 @@ DEFINE_EVENT(cdns2_log_simple, cdns2_device_state,
TP_ARGS(msg)
);
-TRACE_EVENT(cdns2_ep_halt,
+TRACE_EVENT_PRINT_INIT(cdns2_ep_halt,
TP_PROTO(struct cdns2_endpoint *ep_priv, u8 halt, u8 flush),
TP_ARGS(ep_priv, halt, flush),
TP_STRUCT__entry(
- __string(name, ep_priv->name)
+ __field(u32, edw3)
__field(u8, halt)
__field(u8, flush)
),
TP_fast_assign(
- __assign_str(name, ep_priv->name);
+ __entry->edw3 = ep_priv->endpoint.dw3;
__entry->halt = halt;
__entry->flush = flush;
),
TP_printk("Halt %s for %s: %s", __entry->flush ? " and flush" : "",
- __get_str(name), __entry->halt ? "set" : "cleared")
+ __s, __entry->halt ? "set" : "cleared"),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
-TRACE_EVENT(cdns2_wa1,
+TRACE_EVENT_PRINT_INIT(cdns2_wa1,
TP_PROTO(struct cdns2_endpoint *ep_priv, char *msg),
TP_ARGS(ep_priv, msg),
TP_STRUCT__entry(
- __string(ep_name, ep_priv->name)
+ __field(u32, edw3)
__string(msg, msg)
),
TP_fast_assign(
- __assign_str(ep_name, ep_priv->name);
+ __entry->edw3 = ep_priv->endpoint.dw3;
__assign_str(msg, msg);
),
- TP_printk("WA1: %s %s", __get_str(ep_name), __get_str(msg))
+ TP_printk("WA1: %s %s", __s, __get_str(msg)),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
-DECLARE_EVENT_CLASS(cdns2_log_doorbell,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_doorbell,
TP_PROTO(struct cdns2_endpoint *pep, u32 ep_trbaddr),
TP_ARGS(pep, ep_trbaddr),
TP_STRUCT__entry(
- __string(name, pep->num ? pep->name :
- (pep->dir ? "ep0in" : "ep0out"))
+ __field(u32, edw3)
__field(u32, ep_trbaddr)
),
TP_fast_assign(
- __assign_str(name, pep->name);
+ __entry->edw3 = pep->endpoint.dw3;
__entry->ep_trbaddr = ep_trbaddr;
),
- TP_printk("%s, ep_trbaddr %08x", __get_str(name),
- __entry->ep_trbaddr)
+ TP_printk("%s, ep_trbaddr %08x", __s,
+ __entry->ep_trbaddr),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdns2_log_doorbell, cdns2_doorbell_ep0,
@@ -186,26 +209,34 @@ TRACE_EVENT(cdns2_dma_ep_ists,
__entry->dma_ep_ists >> 16)
);
-DECLARE_EVENT_CLASS(cdns2_log_epx_irq,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_epx_irq,
TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep),
TP_ARGS(pdev, pep),
TP_STRUCT__entry(
- __string(ep_name, pep->name)
+ __field(u32, edw3)
__field(u32, ep_sts)
__field(u32, ep_ists)
__field(u32, ep_traddr)
),
TP_fast_assign(
- __assign_str(ep_name, pep->name);
+ __entry->edw3 = pep->endpoint.dw3;
__entry->ep_sts = readl(&pdev->adma_regs->ep_sts);
__entry->ep_ists = readl(&pdev->adma_regs->ep_ists);
__entry->ep_traddr = readl(&pdev->adma_regs->ep_traddr);
),
TP_printk("%s, ep_traddr: %08x",
cdns2_decode_epx_irq(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX,
- __get_str(ep_name),
+ __s,
__entry->ep_ists, __entry->ep_sts),
- __entry->ep_traddr)
+ __entry->ep_traddr),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdns2_log_epx_irq, cdns2_epx_irq,
@@ -266,11 +297,11 @@ DEFINE_EVENT(cdns2_log_ctrl, cdns2_ctrl_req,
TP_ARGS(ctrl)
);
-DECLARE_EVENT_CLASS(cdns2_log_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_request,
TP_PROTO(struct cdns2_request *preq),
TP_ARGS(preq),
TP_STRUCT__entry(
- __string(name, preq->pep->name)
+ __field(u32, edw3)
__field(struct usb_request *, request)
__field(struct cdns2_request *, preq)
__field(void *, buf)
@@ -278,9 +309,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request,
__field(unsigned int, length)
__field(int, status)
__field(dma_addr_t, dma)
- __field(int, zero)
- __field(int, short_not_ok)
- __field(int, no_interrupt)
+ __field(u32, rdw1)
__field(struct scatterlist*, sg)
__field(unsigned int, num_sgs)
__field(unsigned int, num_mapped_sgs)
@@ -288,7 +317,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request,
__field(int, end_trb)
),
TP_fast_assign(
- __assign_str(name, preq->pep->name);
+ __entry->edw3 = preq->pep->endpoint.dw3;
__entry->request = &preq->request;
__entry->preq = preq;
__entry->buf = preq->request.buf;
@@ -296,9 +325,7 @@ DECLARE_EVENT_CLASS(cdns2_log_request,
__entry->length = preq->request.length;
__entry->status = preq->request.status;
__entry->dma = preq->request.dma;
- __entry->zero = preq->request.zero;
- __entry->short_not_ok = preq->request.short_not_ok;
- __entry->no_interrupt = preq->request.no_interrupt;
+ __entry->rdw1 = preq->request.dw1;
__entry->sg = preq->request.sg;
__entry->num_sgs = preq->request.num_sgs;
__entry->num_mapped_sgs = preq->request.num_mapped_sgs;
@@ -308,15 +335,25 @@ DECLARE_EVENT_CLASS(cdns2_log_request,
TP_printk("%s: req: %p, preq: %p, req buf: %p, length: %u/%u, status: %d,"
"buf dma: (%pad), %s%s%s, sg: %p, num_sgs: %d, num_m_sgs: %d,"
"trb: [start: %d, end: %d]",
- __get_str(name), __entry->request, __entry->preq,
+ __s, __entry->request, __entry->preq,
__entry->buf, __entry->actual, __entry->length,
__entry->status, &__entry->dma,
- __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "I" : "i",
+ tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "I" : "i",
__entry->sg, __entry->num_sgs, __entry->num_mapped_sgs,
__entry->start_trb,
__entry->end_trb
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -370,23 +407,31 @@ TRACE_EVENT(cdns2_ep0_enqueue,
__entry->length)
);
-DECLARE_EVENT_CLASS(cdns2_log_map_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_map_request,
TP_PROTO(struct cdns2_request *priv_req),
TP_ARGS(priv_req),
TP_STRUCT__entry(
- __string(name, priv_req->pep->name)
+ __field(u32, edw3)
__field(struct usb_request *, req)
__field(void *, buf)
__field(dma_addr_t, dma)
),
TP_fast_assign(
- __assign_str(name, priv_req->pep->name);
+ __entry->edw3 = priv_req->pep->endpoint.dw3;
__entry->req = &priv_req->request;
__entry->buf = priv_req->request.buf;
__entry->dma = priv_req->request.dma;
),
TP_printk("%s: req: %p, req buf %p, dma %p",
- __get_str(name), __entry->req, __entry->buf, &__entry->dma
+ __s, __entry->req, __entry->buf, &__entry->dma
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -399,11 +444,11 @@ DEFINE_EVENT(cdns2_log_map_request, cdns2_mapped_request,
TP_ARGS(req)
);
-DECLARE_EVENT_CLASS(cdns2_log_trb,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_trb,
TP_PROTO(struct cdns2_endpoint *pep, struct cdns2_trb *trb),
TP_ARGS(pep, trb),
TP_STRUCT__entry(
- __string(name, pep->name)
+ __field(u32, edw3)
__field(struct cdns2_trb *, trb)
__field(u32, buffer)
__field(u32, length)
@@ -411,7 +456,7 @@ DECLARE_EVENT_CLASS(cdns2_log_trb,
__field(u32, type)
),
TP_fast_assign(
- __assign_str(name, pep->name);
+ __entry->edw3 = pep->endpoint.dw3;
__entry->trb = trb;
__entry->buffer = le32_to_cpu(trb->buffer);
__entry->length = le32_to_cpu(trb->length);
@@ -419,10 +464,18 @@ DECLARE_EVENT_CLASS(cdns2_log_trb,
__entry->type = usb_endpoint_type(pep->endpoint.desc);
),
TP_printk("%s: trb V: %p, dma buf: P: 0x%08x, %s",
- __get_str(name), __entry->trb, __entry->buffer,
+ __s, __entry->trb, __entry->buffer,
cdns2_decode_trb(__get_buf(CDNS2_MSG_MAX), CDNS2_MSG_MAX,
__entry->control, __entry->length,
- __entry->buffer))
+ __entry->buffer)),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
+ )
);
DEFINE_EVENT(cdns2_log_trb, cdns2_queue_trb,
@@ -463,22 +516,20 @@ DEFINE_EVENT(cdns2_log_ring, cdns2_ring,
TP_ARGS(pep)
);
-DECLARE_EVENT_CLASS(cdns2_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_ep,
TP_PROTO(struct cdns2_endpoint *pep),
TP_ARGS(pep),
TP_STRUCT__entry(
- __string(name, pep->name)
- __field(unsigned int, maxpacket)
- __field(unsigned int, maxpacket_limit)
+ __field(u32, edw3)
+ __field(u32, edw1)
__field(unsigned int, flags)
__field(unsigned int, dir)
__field(u8, enqueue)
__field(u8, dequeue)
),
TP_fast_assign(
- __assign_str(name, pep->name);
- __entry->maxpacket = pep->endpoint.maxpacket;
- __entry->maxpacket_limit = pep->endpoint.maxpacket_limit;
+ __entry->edw3 = pep->endpoint.dw3;
+ __entry->edw1 = pep->endpoint.dw1;
__entry->flags = pep->ep_state;
__entry->dir = pep->dir;
__entry->enqueue = pep->ring.enqueue;
@@ -486,14 +537,22 @@ DECLARE_EVENT_CLASS(cdns2_log_ep,
),
TP_printk("%s: mps: %d/%d, enq idx: %d, deq idx: %d, "
"flags: %s%s%s%s, dir: %s",
- __get_str(name), __entry->maxpacket,
- __entry->maxpacket_limit, __entry->enqueue,
+ __s, te.maxpacket,
+ te.maxpacket_limit, __entry->enqueue,
__entry->dequeue,
__entry->flags & EP_ENABLED ? "EN | " : "",
__entry->flags & EP_STALLED ? "STALLED | " : "",
__entry->flags & EP_WEDGE ? "WEDGE | " : "",
__entry->flags & EP_RING_FULL ? "RING FULL |" : "",
__entry->dir ? "IN" : "OUT"
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -555,11 +614,11 @@ DEFINE_EVENT(cdns2_log_request_handled, cdns2_request_handled,
TP_ARGS(priv_req, current_index, handled)
);
-DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config,
+DECLARE_EVENT_CLASS_PRINT_INIT(cdns2_log_epx_reg_config,
TP_PROTO(struct cdns2_device *pdev, struct cdns2_endpoint *pep),
TP_ARGS(pdev, pep),
TP_STRUCT__entry(
- __string(ep_name, pep->name)
+ __field(u32, edw3)
__field(u8, burst_size)
__field(__le16, maxpack_reg)
__field(__u8, con_reg)
@@ -568,7 +627,7 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config,
__field(u32, ep_cfg_reg)
),
TP_fast_assign(
- __assign_str(ep_name, pep->name);
+ __entry->edw3 = pep->endpoint.dw3;
__entry->burst_size = pep->trb_burst_size;
__entry->maxpack_reg = pep->dir ? readw(&pdev->epx_regs->txmaxpack[pep->num - 1]) :
readw(&pdev->epx_regs->rxmaxpack[pep->num - 1]);
@@ -581,9 +640,17 @@ DECLARE_EVENT_CLASS(cdns2_log_epx_reg_config,
TP_printk("%s, maxpack: %d, con: %02x, dma_ep_sel: %08x, dma_ep_sts_en: %08x"
" dma_ep_cfg %08x",
- __get_str(ep_name), __entry->maxpack_reg, __entry->con_reg,
+ __s, __entry->maxpack_reg, __entry->con_reg,
__entry->ep_sel_reg, __entry->ep_sts_en_reg,
__entry->ep_cfg_reg
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 7/8] usb: mtu3: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (5 preceding siblings ...)
2023-09-14 10:03 ` [PATCH 6/8] usb: cdns2: " Linyu Yuan
@ 2023-09-14 10:03 ` Linyu Yuan
2023-09-14 10:03 ` [PATCH 8/8] usb: musb: " Linyu Yuan
2023-09-14 16:42 ` [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Steven Rostedt
8 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:03 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 members into trace event ring buffer and parse it for possible
bit information.
Use DECLARE_EVENT_CLASS_PRINT_INIT() related macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/mtu3/mtu3_trace.h | 76 +++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 26 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3_trace.h b/drivers/usb/mtu3/mtu3_trace.h
index 03d2a9bac27e..22b821771c24 100644
--- a/drivers/usb/mtu3/mtu3_trace.h
+++ b/drivers/usb/mtu3/mtu3_trace.h
@@ -113,35 +113,43 @@ DEFINE_EVENT(mtu3_log_setup, mtu3_handle_setup,
TP_ARGS(setup)
);
-DECLARE_EVENT_CLASS(mtu3_log_request,
+DECLARE_EVENT_CLASS_PRINT_INIT(mtu3_log_request,
TP_PROTO(struct mtu3_request *mreq),
TP_ARGS(mreq),
TP_STRUCT__entry(
- __string(name, mreq->mep->name)
+ __field(u32, edw3)
__field(struct mtu3_request *, mreq)
__field(struct qmu_gpd *, gpd)
__field(unsigned int, actual)
__field(unsigned int, length)
__field(int, status)
- __field(int, zero)
- __field(int, no_interrupt)
+ __field(u32, rdw1)
),
TP_fast_assign(
- __assign_str(name, mreq->mep->name);
+ __entry->edw3 = mreq->mep->ep.dw3;
__entry->mreq = mreq;
__entry->gpd = mreq->gpd;
__entry->actual = mreq->request.actual;
__entry->length = mreq->request.length;
__entry->status = mreq->request.status;
- __entry->zero = mreq->request.zero;
- __entry->no_interrupt = mreq->request.no_interrupt;
+ __entry->rdw1 = mreq->request.dw1;
),
TP_printk("%s: req %p gpd %p len %u/%u %s%s --> %d",
- __get_str(name), __entry->mreq, __entry->gpd,
+ __s, __entry->mreq, __entry->gpd,
__entry->actual, __entry->length,
- __entry->zero ? "Z" : "z",
- __entry->no_interrupt ? "i" : "I",
+ tr.zero ? "Z" : "z",
+ tr.no_interrupt ? "i" : "I",
__entry->status
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ struct usb_request tr;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ tr.dw1 = __entry->rdw1;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -170,11 +178,11 @@ DEFINE_EVENT(mtu3_log_request, mtu3_req_complete,
TP_ARGS(req)
);
-DECLARE_EVENT_CLASS(mtu3_log_gpd,
+DECLARE_EVENT_CLASS_PRINT_INIT(mtu3_log_gpd,
TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
TP_ARGS(mep, gpd),
TP_STRUCT__entry(
- __string(name, mep->name)
+ __field(u32, edw3)
__field(struct qmu_gpd *, gpd)
__field(u32, dw0)
__field(u32, dw1)
@@ -182,7 +190,7 @@ DECLARE_EVENT_CLASS(mtu3_log_gpd,
__field(u32, dw3)
),
TP_fast_assign(
- __assign_str(name, mep->name);
+ __entry->edw3 = mep->ep.dw3;
__entry->gpd = gpd;
__entry->dw0 = le32_to_cpu(gpd->dw0_info);
__entry->dw1 = le32_to_cpu(gpd->next_gpd);
@@ -190,9 +198,17 @@ DECLARE_EVENT_CLASS(mtu3_log_gpd,
__entry->dw3 = le32_to_cpu(gpd->dw3_info);
),
TP_printk("%s: gpd %p - %08x %08x %08x %08x",
- __get_str(name), __entry->gpd,
+ __s, __entry->gpd,
__entry->dw0, __entry->dw1,
__entry->dw2, __entry->dw3
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
@@ -211,41 +227,49 @@ DEFINE_EVENT(mtu3_log_gpd, mtu3_zlp_exp_gpd,
TP_ARGS(mep, gpd)
);
-DECLARE_EVENT_CLASS(mtu3_log_ep,
+DECLARE_EVENT_CLASS_PRINT_INIT(mtu3_log_ep,
TP_PROTO(struct mtu3_ep *mep),
TP_ARGS(mep),
TP_STRUCT__entry(
- __string(name, mep->name)
+ __field(u32, edw3)
__field(unsigned int, type)
__field(unsigned int, slot)
- __field(unsigned int, maxp)
- __field(unsigned int, mult)
- __field(unsigned int, maxburst)
+ __field(u32, edw1)
+ __field(u32, edw2)
__field(unsigned int, flags)
__field(unsigned int, direction)
__field(struct mtu3_gpd_ring *, gpd_ring)
),
TP_fast_assign(
- __assign_str(name, mep->name);
+ __entry->edw3 = mep->ep.dw3;
__entry->type = mep->type;
__entry->slot = mep->slot;
- __entry->maxp = mep->ep.maxpacket;
- __entry->mult = mep->ep.mult;
- __entry->maxburst = mep->ep.maxburst;
+ __entry->edw1 = mep->ep.dw1;
+ __entry->edw2 = mep->ep.dw2;
__entry->flags = mep->flags;
__entry->direction = mep->is_in;
__entry->gpd_ring = &mep->gpd_ring;
),
TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c",
- __get_str(name), usb_ep_type_string(__entry->type),
- __entry->maxp, __entry->slot,
- __entry->mult, __entry->maxburst,
+ __s, usb_ep_type_string(__entry->type),
+ te.maxpacket, __entry->slot,
+ te.mult, te.maxburst,
__entry->gpd_ring, &__entry->gpd_ring->dma,
__entry->flags & MTU3_EP_ENABLED ? 'E' : 'e',
__entry->flags & MTU3_EP_STALL ? 'S' : 's',
__entry->flags & MTU3_EP_WEDGE ? 'W' : 'w',
__entry->flags & MTU3_EP_BUSY ? 'B' : 'b',
__entry->direction ? '<' : '>'
+ ),
+ TP_printk_init(
+ struct usb_ep te;
+ char __s[9];
+ te.dw1 = __entry->edw1;
+ te.dw2 = __entry->edw2;
+ te.dw3 = __entry->edw3;
+ snprintf(__s, 9, "ep%d%s", te.address, \
+ (te.caps.dir_in && te.caps.dir_out) ? "" : \
+ te.caps.dir_in ? "in" : "out");
)
);
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 8/8] usb: musb: trace: reduce buffer usage of trace event
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (6 preceding siblings ...)
2023-09-14 10:03 ` [PATCH 7/8] usb: mtu3: " Linyu Yuan
@ 2023-09-14 10:03 ` Linyu Yuan
2023-09-14 16:42 ` [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Steven Rostedt
8 siblings, 0 replies; 19+ messages in thread
From: Linyu Yuan @ 2023-09-14 10:03 UTC (permalink / raw)
To: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Steven Rostedt, Masami Hiramatsu,
Greg Kroah-Hartman
Cc: linux-usb, linux-trace-kernel, Linyu Yuan
Save u32 member into trace event ring buffer and parse it for possible
bit information.
Use DECLARE_EVENT_CLASS_PRINT_INIT() related macro for output stage.
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
drivers/usb/musb/musb_trace.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h
index f246b14394c4..8add5e81ed8d 100644
--- a/drivers/usb/musb/musb_trace.h
+++ b/drivers/usb/musb/musb_trace.h
@@ -233,7 +233,7 @@ DEFINE_EVENT(musb_urb, musb_urb_deq,
TP_ARGS(musb, urb)
);
-DECLARE_EVENT_CLASS(musb_req,
+DECLARE_EVENT_CLASS_PRINT_INIT(musb_req,
TP_PROTO(struct musb_request *req),
TP_ARGS(req),
TP_STRUCT__entry(
@@ -243,9 +243,7 @@ DECLARE_EVENT_CLASS(musb_req,
__field(int, status)
__field(unsigned int, buf_len)
__field(unsigned int, actual_len)
- __field(unsigned int, zero)
- __field(unsigned int, short_not_ok)
- __field(unsigned int, no_interrupt)
+ __field(u32, rdw1)
),
TP_fast_assign(
__entry->req = &req->request;
@@ -254,18 +252,20 @@ DECLARE_EVENT_CLASS(musb_req,
__entry->status = req->request.status;
__entry->buf_len = req->request.length;
__entry->actual_len = req->request.actual;
- __entry->zero = req->request.zero;
- __entry->short_not_ok = req->request.short_not_ok;
- __entry->no_interrupt = req->request.no_interrupt;
+ __entry->rdw1 = req->request.dw1;
),
TP_printk("%p, ep%d %s, %s%s%s, len %d/%d, status %d",
__entry->req, __entry->epnum,
__entry->is_tx ? "tx/IN" : "rx/OUT",
- __entry->zero ? "Z" : "z",
- __entry->short_not_ok ? "S" : "s",
- __entry->no_interrupt ? "I" : "i",
+ tr.zero ? "Z" : "z",
+ tr.short_not_ok ? "S" : "s",
+ tr.no_interrupt ? "I" : "i",
__entry->actual_len, __entry->buf_len,
__entry->status
+ ),
+ TP_printk_init(
+ struct usb_request tr;
+ tr.dw1 = __entry->rdw1;
)
);
--
2.17.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage
2023-09-14 10:02 [PATCH 0/8] usb: gadget: reduce usb gadget trace event buffer usage Linyu Yuan
` (7 preceding siblings ...)
2023-09-14 10:03 ` [PATCH 8/8] usb: musb: " Linyu Yuan
@ 2023-09-14 16:42 ` Steven Rostedt
8 siblings, 0 replies; 19+ messages in thread
From: Steven Rostedt @ 2023-09-14 16:42 UTC (permalink / raw)
To: Linyu Yuan
Cc: Thinh Nguyen, Chunfeng Yun, Bin Liu, Peter Chen, Pawel Laszczak,
Roger Quadros, Alan Stern, Masami Hiramatsu, Greg Kroah-Hartman,
linux-usb, linux-trace-kernel
On Thu, 14 Sep 2023 18:02:54 +0800
Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
> some trace event use an interger to to save a bit field info of gadget,
> also some trace save endpoint name in string forat, it all can be
> chagned to other way at trace event store phase.
>
> bit field can be replace with a union interger member which include
> multiple bit fields.
>
> ep name stringe can be replace to a interger which contaion number
> and dir info.
>
> to allow trace output stage can get bit info from save interger,
> add DECLARE_EVENT_CLASS_PRINT_INIT() clas which allow user defined
> operation before print.
>
> v1: https://lore.kernel.org/linux-usb/20230911042843.2711-1-quic_linyyuan@quicinc.com/
> v2: fix two compile issues that COMPILE_TEST not covered
> https://lore.kernel.org/linux-usb/20230911112446.1791-1-quic_linyyuan@quicinc.com/
> v3: fix reviewer comments, allow bit fields work on both little and big endian
> https://lore.kernel.org/linux-usb/20230912104455.7737-1-quic_linyyuan@quicinc.com/
> v4: add DECLARE_EVENT_CLASS_PRINT_INIT() new trace class and use it
>
All these changes make it useless for user space. :-(
-- Steve
> Linyu Yuan (8):
> trace: add new DECLARE_EVENT_CLASS_PRINT_INIT class type
> usb: gadget: add anonymous definition in some struct for trace purpose
> usb: udc: trace: reduce buffer usage of trace event
> usb: cdns3: trace: reduce buffer usage of trace event
> usb: dwc3: trace: reduce buffer usage of trace event
> usb: cdns2: trace: reduce buffer usage of trace event
> usb: mtu3: trace: reduce buffer usage of trace event
> usb: musb: trace: reduce buffer usage of trace event
>
> drivers/usb/cdns3/cdns3-trace.h | 201 ++++++++++++++-------
> drivers/usb/cdns3/cdnsp-trace.h | 105 +++++++----
> drivers/usb/dwc3/trace.h | 99 ++++++----
> drivers/usb/gadget/udc/cdns2/cdns2-trace.h | 175 ++++++++++++------
> drivers/usb/gadget/udc/trace.h | 154 +++++++---------
> drivers/usb/mtu3/mtu3_trace.h | 76 +++++---
> drivers/usb/musb/musb_trace.h | 20 +-
> include/linux/tracepoint.h | 22 +++
> include/linux/usb/gadget.h | 113 +++++++-----
> include/trace/bpf_probe.h | 4 +
> include/trace/perf.h | 43 +++++
> include/trace/stages/stage3_trace_output.h | 3 +
> include/trace/trace_events.h | 118 ++++++++++++
> 13 files changed, 784 insertions(+), 349 deletions(-)
>
^ permalink raw reply [flat|nested] 19+ messages in thread