Lines Matching +full:tp +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0
3 * Fprobe-based tracing events
49 struct trace_probe tp; member
54 return ev->ops == &trace_fprobe_ops; in is_trace_fprobe()
63 * for_each_trace_fprobe - iterate over the trace_fprobe list
73 return tf->fp.exit_handler != NULL; in trace_fprobe_is_return()
78 return tf->tpoint != NULL; in trace_fprobe_is_tracepoint()
83 return tf->symbol ? tf->symbol : "unknown"; in trace_fprobe_symbol()
90 return trace_probe_is_enabled(&tf->tp); in trace_fprobe_is_busy()
104 argc--; argv++; in trace_fprobe_match_command_head()
106 return trace_probe_match_command_args(&tf->tp, argc, argv); in trace_fprobe_match_command_head()
114 if (event[0] != '\0' && strcmp(trace_probe_name(&tf->tp), event)) in trace_fprobe_match()
117 if (system && strcmp(trace_probe_group_name(&tf->tp), system)) in trace_fprobe_match()
125 return fprobe_is_registered(&tf->fp); in trace_fprobe_is_registered()
142 switch (code->op) { in process_fetch_insn()
144 val = regs_get_kernel_stack_nth(regs, code->param); in process_fetch_insn()
154 val = regs_get_kernel_argument(regs, code->param); in process_fetch_insn()
157 val = *(unsigned long *)((unsigned long)edata + code->offset); in process_fetch_insn()
181 struct trace_event_call *call = trace_probe_event_call(&tf->tp); in NOKPROBE_SYMBOL()
185 if (WARN_ON_ONCE(call != trace_file->event_call)) in NOKPROBE_SYMBOL()
191 dsize = __get_data_size(&tf->tp, regs, NULL); in NOKPROBE_SYMBOL()
194 sizeof(*entry) + tf->tp.size + dsize); in NOKPROBE_SYMBOL()
200 entry->ip = entry_ip; in NOKPROBE_SYMBOL()
201 store_trace_args(&entry[1], &tf->tp, regs, NULL, sizeof(*entry), dsize); in NOKPROBE_SYMBOL()
210 struct event_file_link *link; in fentry_trace_func() local
212 trace_probe_for_each_link_rcu(link, &tf->tp) in fentry_trace_func()
213 __fentry_trace_func(tf, entry_ip, regs, link->file); in fentry_trace_func()
224 if (tf->tp.entry_arg) in trace_fprobe_entry_handler()
225 store_trace_entry_data(entry_data, &tf->tp, regs); in trace_fprobe_entry_handler()
238 struct trace_event_call *call = trace_probe_event_call(&tf->tp); in NOKPROBE_SYMBOL()
241 if (WARN_ON_ONCE(call != trace_file->event_call)) in NOKPROBE_SYMBOL()
247 dsize = __get_data_size(&tf->tp, regs, entry_data); in NOKPROBE_SYMBOL()
250 sizeof(*entry) + tf->tp.size + dsize); in NOKPROBE_SYMBOL()
256 entry->func = entry_ip; in NOKPROBE_SYMBOL()
257 entry->ret_ip = ret_ip; in NOKPROBE_SYMBOL()
258 store_trace_args(&entry[1], &tf->tp, regs, entry_data, sizeof(*entry), dsize); in NOKPROBE_SYMBOL()
267 struct event_file_link *link; in fexit_trace_func() local
269 trace_probe_for_each_link_rcu(link, &tf->tp) in fexit_trace_func()
270 __fexit_trace_func(tf, entry_ip, ret_ip, regs, entry_data, link->file); in fexit_trace_func()
279 struct trace_event_call *call = trace_probe_event_call(&tf->tp); in fentry_perf_func()
285 head = this_cpu_ptr(call->perf_events); in fentry_perf_func()
289 dsize = __get_data_size(&tf->tp, regs, NULL); in fentry_perf_func()
290 __size = sizeof(*entry) + tf->tp.size + dsize; in fentry_perf_func()
292 size -= sizeof(u32); in fentry_perf_func()
298 entry->ip = entry_ip; in fentry_perf_func()
300 store_trace_args(&entry[1], &tf->tp, regs, NULL, sizeof(*entry), dsize); in fentry_perf_func()
301 perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs, in fentry_perf_func()
312 struct trace_event_call *call = trace_probe_event_call(&tf->tp); in fexit_perf_func()
318 head = this_cpu_ptr(call->perf_events); in fexit_perf_func()
322 dsize = __get_data_size(&tf->tp, regs, entry_data); in fexit_perf_func()
323 __size = sizeof(*entry) + tf->tp.size + dsize; in fexit_perf_func()
325 size -= sizeof(u32); in fexit_perf_func()
331 entry->func = entry_ip; in fexit_perf_func()
332 entry->ret_ip = ret_ip; in fexit_perf_func()
333 store_trace_args(&entry[1], &tf->tp, regs, entry_data, sizeof(*entry), dsize); in fexit_perf_func()
334 perf_trace_buf_submit(entry, size, rctx, call->event.type, 1, regs, in fexit_perf_func()
347 if (trace_probe_test_flag(&tf->tp, TP_FLAG_TRACE)) in fentry_dispatcher()
350 if (trace_probe_test_flag(&tf->tp, TP_FLAG_PROFILE)) in fentry_dispatcher()
363 if (trace_probe_test_flag(&tf->tp, TP_FLAG_TRACE)) in fexit_dispatcher()
366 if (trace_probe_test_flag(&tf->tp, TP_FLAG_PROFILE)) in fexit_dispatcher()
375 trace_probe_cleanup(&tf->tp); in free_trace_fprobe()
376 kfree(tf->symbol); in free_trace_fprobe()
392 int ret = -ENOMEM; in alloc_trace_fprobe()
394 tf = kzalloc(struct_size(tf, tp.args, nargs), GFP_KERNEL); in alloc_trace_fprobe()
398 tf->symbol = kstrdup(symbol, GFP_KERNEL); in alloc_trace_fprobe()
399 if (!tf->symbol) in alloc_trace_fprobe()
403 tf->fp.exit_handler = fexit_dispatcher; in alloc_trace_fprobe()
405 tf->fp.entry_handler = fentry_dispatcher; in alloc_trace_fprobe()
407 tf->tpoint = tpoint; in alloc_trace_fprobe()
408 tf->fp.nr_maxactive = maxactive; in alloc_trace_fprobe()
410 ret = trace_probe_init(&tf->tp, event, group, false, nargs); in alloc_trace_fprobe()
414 dyn_event_init(&tf->devent, &trace_fprobe_ops); in alloc_trace_fprobe()
428 if (strcmp(trace_probe_name(&tf->tp), event) == 0 && in find_trace_fprobe()
429 strcmp(trace_probe_group_name(&tf->tp), group) == 0) in find_trace_fprobe()
437 enable_fprobe(&tf->fp); in __enable_trace_fprobe()
442 static void __disable_trace_fprobe(struct trace_probe *tp) in __disable_trace_fprobe() argument
446 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) { in __disable_trace_fprobe()
449 disable_fprobe(&tf->fp); in __disable_trace_fprobe()
460 struct trace_probe *tp; in enable_trace_fprobe() local
465 tp = trace_probe_primary_from_call(call); in enable_trace_fprobe()
466 if (WARN_ON_ONCE(!tp)) in enable_trace_fprobe()
467 return -ENODEV; in enable_trace_fprobe()
468 enabled = trace_probe_is_enabled(tp); in enable_trace_fprobe()
472 ret = trace_probe_add_file(tp, file); in enable_trace_fprobe()
476 trace_probe_set_flag(tp, TP_FLAG_PROFILE); in enable_trace_fprobe()
479 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) { in enable_trace_fprobe()
495 struct trace_probe *tp; in disable_trace_fprobe() local
497 tp = trace_probe_primary_from_call(call); in disable_trace_fprobe()
498 if (WARN_ON_ONCE(!tp)) in disable_trace_fprobe()
499 return -ENODEV; in disable_trace_fprobe()
502 if (!trace_probe_get_file_link(tp, file)) in disable_trace_fprobe()
503 return -ENOENT; in disable_trace_fprobe()
504 if (!trace_probe_has_single_file(tp)) in disable_trace_fprobe()
506 trace_probe_clear_flag(tp, TP_FLAG_TRACE); in disable_trace_fprobe()
508 trace_probe_clear_flag(tp, TP_FLAG_PROFILE); in disable_trace_fprobe()
510 if (!trace_probe_is_enabled(tp)) in disable_trace_fprobe()
511 __disable_trace_fprobe(tp); in disable_trace_fprobe()
521 trace_probe_remove_file(tp, file); in disable_trace_fprobe()
532 struct trace_seq *s = &iter->seq; in print_fentry_event()
533 struct trace_probe *tp; in print_fentry_event() local
535 field = (struct fentry_trace_entry_head *)iter->ent; in print_fentry_event()
536 tp = trace_probe_primary_from_call( in print_fentry_event()
538 if (WARN_ON_ONCE(!tp)) in print_fentry_event()
541 trace_seq_printf(s, "%s: (", trace_probe_name(tp)); in print_fentry_event()
543 if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET)) in print_fentry_event()
548 if (trace_probe_print_args(s, tp->args, tp->nr_args, in print_fentry_event()
562 struct trace_seq *s = &iter->seq; in print_fexit_event()
563 struct trace_probe *tp; in print_fexit_event() local
565 field = (struct fexit_trace_entry_head *)iter->ent; in print_fexit_event()
566 tp = trace_probe_primary_from_call( in print_fexit_event()
568 if (WARN_ON_ONCE(!tp)) in print_fexit_event()
571 trace_seq_printf(s, "%s: (", trace_probe_name(tp)); in print_fexit_event()
573 if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET)) in print_fexit_event()
576 trace_seq_puts(s, " <- "); in print_fexit_event()
578 if (!seq_print_ip_sym(s, field->func, flags & ~TRACE_ITER_SYM_OFFSET)) in print_fexit_event()
583 if (trace_probe_print_args(s, tp->args, tp->nr_args, in print_fexit_event()
597 struct trace_probe *tp; in fentry_event_define_fields() local
599 tp = trace_probe_primary_from_call(event_call); in fentry_event_define_fields()
600 if (WARN_ON_ONCE(!tp)) in fentry_event_define_fields()
601 return -ENOENT; in fentry_event_define_fields()
605 return traceprobe_define_arg_fields(event_call, sizeof(field), tp); in fentry_event_define_fields()
612 struct trace_probe *tp; in fexit_event_define_fields() local
614 tp = trace_probe_primary_from_call(event_call); in fexit_event_define_fields()
615 if (WARN_ON_ONCE(!tp)) in fexit_event_define_fields()
616 return -ENOENT; in fexit_event_define_fields()
621 return traceprobe_define_arg_fields(event_call, sizeof(field), tp); in fexit_event_define_fields()
649 struct trace_event_call *call = trace_probe_event_call(&tf->tp); in init_trace_event_call()
652 call->event.funcs = &fexit_funcs; in init_trace_event_call()
653 call->class->fields_array = fexit_fields_array; in init_trace_event_call()
655 call->event.funcs = &fentry_funcs; in init_trace_event_call()
656 call->class->fields_array = fentry_fields_array; in init_trace_event_call()
659 call->flags = TRACE_EVENT_FL_FPROBE; in init_trace_event_call()
660 call->class->reg = fprobe_register; in init_trace_event_call()
667 return trace_probe_register_event_call(&tf->tp); in register_fprobe_event()
672 return trace_probe_unregister_event_call(&tf->tp); in unregister_fprobe_event()
675 /* Internal register function - just handle fprobe and flags */
686 return -EINVAL; in __register_trace_fprobe()
688 for (i = 0; i < tf->tp.nr_args; i++) { in __register_trace_fprobe()
689 ret = traceprobe_update_arg(&tf->tp.args[i]); in __register_trace_fprobe()
694 /* Set/clear disabled flag according to tp->flag */ in __register_trace_fprobe()
695 if (trace_probe_is_enabled(&tf->tp)) in __register_trace_fprobe()
696 tf->fp.flags &= ~FPROBE_FL_DISABLED; in __register_trace_fprobe()
698 tf->fp.flags |= FPROBE_FL_DISABLED; in __register_trace_fprobe()
701 struct tracepoint *tpoint = tf->tpoint; in __register_trace_fprobe()
702 unsigned long ip = (unsigned long)tpoint->probestub; in __register_trace_fprobe()
705 * At first, put __probestub_##TP function on the tracepoint in __register_trace_fprobe()
709 tpoint->probestub, NULL, 0); in __register_trace_fprobe()
712 return register_fprobe_ips(&tf->fp, &ip, 1); in __register_trace_fprobe()
716 return register_fprobe(&tf->fp, tf->symbol, NULL); in __register_trace_fprobe()
719 /* Internal unregister function - just handle fprobe and flags */
723 unregister_fprobe(&tf->fp); in __unregister_trace_fprobe()
724 memset(&tf->fp, 0, sizeof(tf->fp)); in __unregister_trace_fprobe()
726 tracepoint_probe_unregister(tf->tpoint, in __unregister_trace_fprobe()
727 tf->tpoint->probestub, NULL); in __unregister_trace_fprobe()
728 tf->tpoint = NULL; in __unregister_trace_fprobe()
729 tf->mod = NULL; in __unregister_trace_fprobe()
739 if (trace_probe_has_sibling(&tf->tp)) in unregister_trace_fprobe()
743 if (trace_probe_is_enabled(&tf->tp)) in unregister_trace_fprobe()
744 return -EBUSY; in unregister_trace_fprobe()
747 if (trace_event_dyn_busy(trace_probe_event_call(&tf->tp))) in unregister_trace_fprobe()
748 return -EBUSY; in unregister_trace_fprobe()
752 return -EBUSY; in unregister_trace_fprobe()
756 dyn_event_remove(&tf->devent); in unregister_trace_fprobe()
757 trace_probe_unlink(&tf->tp); in unregister_trace_fprobe()
765 struct trace_probe_event *tpe = orig->tp.event; in trace_fprobe_has_same_fprobe()
768 list_for_each_entry(orig, &tpe->probes, tp.list) { in trace_fprobe_has_same_fprobe()
777 for (i = 0; i < orig->tp.nr_args; i++) { in trace_fprobe_has_same_fprobe()
778 if (strcmp(orig->tp.args[i].comm, in trace_fprobe_has_same_fprobe()
779 comp->tp.args[i].comm)) in trace_fprobe_has_same_fprobe()
783 if (i == orig->tp.nr_args) in trace_fprobe_has_same_fprobe()
798 return -EEXIST; in append_trace_fprobe()
800 ret = trace_probe_compare_arg_type(&tf->tp, &to->tp); in append_trace_fprobe()
805 return -EEXIST; in append_trace_fprobe()
810 return -EEXIST; in append_trace_fprobe()
814 ret = trace_probe_append(&tf->tp, &to->tp); in append_trace_fprobe()
820 trace_probe_unlink(&tf->tp); in append_trace_fprobe()
822 dyn_event_add(&tf->devent, trace_probe_event_call(&tf->tp)); in append_trace_fprobe()
835 old_tf = find_trace_fprobe(trace_probe_name(&tf->tp), in register_trace_fprobe()
836 trace_probe_group_name(&tf->tp)); in register_trace_fprobe()
845 if (ret == -EEXIST) { in register_trace_fprobe()
858 dyn_event_add(&tf->devent, trace_probe_event_call(&tf->tp)); in register_trace_fprobe()
878 if (tp_mod->mod == tf->mod) { in __tracepoint_probe_module_cb()
879 tracepoint_probe_unregister(tf->tpoint, in __tracepoint_probe_module_cb()
880 tf->tpoint->probestub, NULL); in __tracepoint_probe_module_cb()
881 tf->tpoint = NULL; in __tracepoint_probe_module_cb()
882 tf->mod = NULL; in __tracepoint_probe_module_cb()
900 static void __find_tracepoint_cb(struct tracepoint *tp, void *priv) in __find_tracepoint_cb() argument
904 if (!data->tpoint && !strcmp(data->tp_name, tp->name)) in __find_tracepoint_cb()
905 data->tpoint = tp; in __find_tracepoint_cb()
927 int len = tmp - argv[1]; in parse_symbol_and_return()
933 return -EINVAL; in parse_symbol_and_return()
939 return -ENOMEM; in parse_symbol_and_return()
950 trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE); in parse_symbol_and_return()
951 return -EINVAL; in parse_symbol_and_return()
964 * - Add fentry probe: in __trace_fprobe_create()
966 * - Add fexit probe: in __trace_fprobe_create()
968 * - Add tracepoint probe: in __trace_fprobe_create()
974 * $stackN : fetch Nth entry of stack (N:0-) in __trace_fprobe_create()
975 * $argN : fetch Nth argument (N:1-) in __trace_fprobe_create()
978 * @SYM[+|-offs] : fetch memory at SYM +|- offs (SYM is a data symbol) in __trace_fprobe_create()
980 * +|-offs(ARG) : fetch memory at ARG +|- offs address. in __trace_fprobe_create()
1004 return -ECANCELED; in __trace_fprobe_create()
1019 len = event - &argv[0][1] - 1; in __trace_fprobe_create()
1022 if (len > MAX_EVENT_NAME_LEN - 1) { in __trace_fprobe_create()
1058 event - argv[0]); in __trace_fprobe_create()
1089 (unsigned long)tpoint->probestub, in __trace_fprobe_create()
1094 argc -= 2; argv += 2; in __trace_fprobe_create()
1107 ret = -E2BIG; in __trace_fprobe_create()
1116 /* This must return -ENOMEM, else there is a bug */ in __trace_fprobe_create()
1117 WARN_ON_ONCE(ret != -ENOMEM); in __trace_fprobe_create()
1122 tf->mod = __module_text_address( in __trace_fprobe_create()
1123 (unsigned long)tf->tpoint->probestub); in __trace_fprobe_create()
1129 ret = traceprobe_parse_probe_arg(&tf->tp, i, argv[i], &ctx); in __trace_fprobe_create()
1131 goto error; /* This can be -ENOMEM */ in __trace_fprobe_create()
1134 if (is_return && tf->tp.entry_arg) { in __trace_fprobe_create()
1135 tf->fp.entry_handler = trace_fprobe_entry_handler; in __trace_fprobe_create()
1136 tf->fp.entry_data_size = traceprobe_get_entry_data_size(&tf->tp); in __trace_fprobe_create()
1139 ret = traceprobe_set_print_fmt(&tf->tp, in __trace_fprobe_create()
1147 if (ret == -EILSEQ) in __trace_fprobe_create()
1149 else if (ret == -ENOENT) in __trace_fprobe_create()
1151 else if (ret != -ENOMEM && ret != -EEXIST) in __trace_fprobe_create()
1164 ret = -EINVAL; in __trace_fprobe_create()
1194 if (trace_fprobe_is_return(tf) && tf->fp.nr_maxactive) in trace_fprobe_show()
1195 seq_printf(m, "%d", tf->fp.nr_maxactive); in trace_fprobe_show()
1196 seq_printf(m, ":%s/%s", trace_probe_group_name(&tf->tp), in trace_fprobe_show()
1197 trace_probe_name(&tf->tp)); in trace_fprobe_show()
1202 for (i = 0; i < tf->tp.nr_args; i++) in trace_fprobe_show()
1203 seq_printf(m, " %s=%s", tf->tp.args[i].name, tf->tp.args[i].comm); in trace_fprobe_show()