Message ID | 20230914100302.30274-2-quic_linyyuan@quicinc.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
Series | usb: gadget: reduce usb gadget trace event buffer usage | expand |
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
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) \ \
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(+)