Lines Matching refs:tf

215 static bool trace_fprobe_is_return(struct trace_fprobe *tf)
217 return tf->fp.exit_handler != NULL;
220 static bool trace_fprobe_is_tracepoint(struct trace_fprobe *tf)
222 return tf->tprobe;
225 static const char *trace_fprobe_symbol(struct trace_fprobe *tf)
227 return tf->symbol ? tf->symbol : "unknown";
232 struct trace_fprobe *tf = to_trace_fprobe(ev);
234 return trace_probe_is_enabled(&tf->tp);
237 static bool trace_fprobe_match_command_head(struct trace_fprobe *tf,
245 snprintf(buf, sizeof(buf), "%s", trace_fprobe_symbol(tf));
250 return trace_probe_match_command_args(&tf->tp, argc, argv);
256 struct trace_fprobe *tf = to_trace_fprobe(ev);
258 if (event[0] != '\0' && strcmp(trace_probe_name(&tf->tp), event))
261 if (system && strcmp(trace_probe_group_name(&tf->tp), system))
264 return trace_fprobe_match_command_head(tf, argc, argv);
267 static bool trace_fprobe_is_registered(struct trace_fprobe *tf)
269 return fprobe_is_registered(&tf->fp);
320 __fentry_trace_func(struct trace_fprobe *tf, unsigned long entry_ip,
325 struct trace_event_call *call = trace_probe_event_call(&tf->tp);
335 dsize = __get_data_size(&tf->tp, fregs, NULL);
338 sizeof(*entry) + tf->tp.size + dsize);
345 store_trace_args(&entry[1], &tf->tp, fregs, NULL, sizeof(*entry), dsize);
351 fentry_trace_func(struct trace_fprobe *tf, unsigned long entry_ip,
356 trace_probe_for_each_link_rcu(link, &tf->tp)
357 __fentry_trace_func(tf, entry_ip, fregs, link->file);
396 struct trace_fprobe *tf = container_of(fp, struct trace_fprobe, fp);
398 if (tf->tp.entry_arg)
399 store_fprobe_entry_data(entry_data, &tf->tp, fregs);
406 __fexit_trace_func(struct trace_fprobe *tf, unsigned long entry_ip,
412 struct trace_event_call *call = trace_probe_event_call(&tf->tp);
421 dsize = __get_data_size(&tf->tp, fregs, entry_data);
424 sizeof(*entry) + tf->tp.size + dsize);
432 store_trace_args(&entry[1], &tf->tp, fregs, entry_data, sizeof(*entry), dsize);
438 fexit_trace_func(struct trace_fprobe *tf, unsigned long entry_ip,
443 trace_probe_for_each_link_rcu(link, &tf->tp)
444 __fexit_trace_func(tf, entry_ip, ret_ip, fregs, entry_data, link->file);
450 static int fentry_perf_func(struct trace_fprobe *tf, unsigned long entry_ip,
453 struct trace_event_call *call = trace_probe_event_call(&tf->tp);
464 dsize = __get_data_size(&tf->tp, fregs, NULL);
465 __size = sizeof(*entry) + tf->tp.size + dsize;
477 store_trace_args(&entry[1], &tf->tp, fregs, NULL, sizeof(*entry), dsize);
485 fexit_perf_func(struct trace_fprobe *tf, unsigned long entry_ip,
489 struct trace_event_call *call = trace_probe_event_call(&tf->tp);
500 dsize = __get_data_size(&tf->tp, fregs, entry_data);
501 __size = sizeof(*entry) + tf->tp.size + dsize;
513 store_trace_args(&entry[1], &tf->tp, fregs, entry_data, sizeof(*entry), dsize);
524 struct trace_fprobe *tf = container_of(fp, struct trace_fprobe, fp);
527 if (trace_probe_test_flag(&tf->tp, TP_FLAG_TRACE))
528 fentry_trace_func(tf, entry_ip, fregs);
531 if (trace_probe_test_flag(&tf->tp, TP_FLAG_PROFILE))
532 ret = fentry_perf_func(tf, entry_ip, fregs);
542 struct trace_fprobe *tf = container_of(fp, struct trace_fprobe, fp);
544 if (trace_probe_test_flag(&tf->tp, TP_FLAG_TRACE))
545 fexit_trace_func(tf, entry_ip, ret_ip, fregs, entry_data);
547 if (trace_probe_test_flag(&tf->tp, TP_FLAG_PROFILE))
548 fexit_perf_func(tf, entry_ip, ret_ip, fregs, entry_data);
553 static void free_trace_fprobe(struct trace_fprobe *tf)
555 if (tf) {
556 trace_probe_cleanup(&tf->tp);
557 if (tf->tuser)
558 tracepoint_user_put(tf->tuser);
559 kfree(tf->symbol);
560 kfree(tf);
576 struct trace_fprobe *tf __free(free_trace_fprobe) = NULL;
579 tf = kzalloc(struct_size(tf, tp.args, nargs), GFP_KERNEL);
580 if (!tf)
583 tf->symbol = kstrdup(symbol, GFP_KERNEL);
584 if (!tf->symbol)
588 tf->fp.exit_handler = fexit_dispatcher;
590 tf->fp.entry_handler = fentry_dispatcher;
592 tf->tprobe = is_tracepoint;
594 ret = trace_probe_init(&tf->tp, event, group, false, nargs);
598 dyn_event_init(&tf->devent, &trace_fprobe_ops);
599 return_ptr(tf);
606 struct trace_fprobe *tf;
608 for_each_trace_fprobe(tf, pos)
609 if (strcmp(trace_probe_name(&tf->tp), event) == 0 &&
610 strcmp(trace_probe_group_name(&tf->tp), group) == 0)
611 return tf;
736 static inline void init_trace_event_call(struct trace_fprobe *tf)
738 struct trace_event_call *call = trace_probe_event_call(&tf->tp);
740 if (trace_fprobe_is_return(tf)) {
752 static int register_fprobe_event(struct trace_fprobe *tf)
754 init_trace_event_call(tf);
756 return trace_probe_register_event_call(&tf->tp);
759 static int unregister_fprobe_event(struct trace_fprobe *tf)
761 return trace_probe_unregister_event_call(&tf->tp);
764 static int __regsiter_tracepoint_fprobe(struct trace_fprobe *tf)
771 if (WARN_ON_ONCE(tf->tuser))
775 tuser = tracepoint_user_find_get(tf->symbol, &mod);
788 ret = register_fprobe_ips(&tf->fp, &ip, 1);
793 tf->tuser = no_free_ptr(tuser);
798 static int trace_fprobe_verify_target(struct trace_fprobe *tf)
803 if (trace_fprobe_is_tracepoint(tf))
810 ret = fprobe_count_ips_from_filter(tf->symbol, NULL);
815 static int __register_trace_fprobe(struct trace_fprobe *tf)
824 if (trace_fprobe_is_registered(tf))
827 for (i = 0; i < tf->tp.nr_args; i++) {
828 ret = traceprobe_update_arg(&tf->tp.args[i]);
833 tf->fp.flags &= ~FPROBE_FL_DISABLED;
835 if (trace_fprobe_is_tracepoint(tf))
836 return __regsiter_tracepoint_fprobe(tf);
839 return register_fprobe(&tf->fp, tf->symbol, NULL);
843 static void __unregister_trace_fprobe(struct trace_fprobe *tf)
845 if (trace_fprobe_is_registered(tf))
846 unregister_fprobe(&tf->fp);
847 if (tf->tuser) {
848 tracepoint_user_put(tf->tuser);
849 tf->tuser = NULL;
855 static int unregister_trace_fprobe(struct trace_fprobe *tf)
858 if (trace_probe_has_sibling(&tf->tp))
862 if (trace_probe_is_enabled(&tf->tp))
866 if (trace_event_dyn_busy(trace_probe_event_call(&tf->tp)))
870 if (unregister_fprobe_event(tf))
874 __unregister_trace_fprobe(tf);
875 dyn_event_remove(&tf->devent);
876 trace_probe_unlink(&tf->tp);
909 static int append_trace_fprobe_event(struct trace_fprobe *tf, struct trace_fprobe *to)
913 if (trace_fprobe_is_return(tf) != trace_fprobe_is_return(to) ||
914 trace_fprobe_is_tracepoint(tf) != trace_fprobe_is_tracepoint(to)) {
919 ret = trace_probe_compare_arg_type(&tf->tp, &to->tp);
926 if (trace_fprobe_has_same_fprobe(to, tf)) {
933 ret = trace_probe_append(&tf->tp, &to->tp);
937 ret = trace_fprobe_verify_target(tf);
939 trace_probe_unlink(&tf->tp);
941 dyn_event_add(&tf->devent, trace_probe_event_call(&tf->tp));
947 static int register_trace_fprobe_event(struct trace_fprobe *tf)
954 old_tf = find_trace_fprobe(trace_probe_name(&tf->tp),
955 trace_probe_group_name(&tf->tp));
957 return append_trace_fprobe_event(tf, old_tf);
960 ret = register_fprobe_event(tf);
971 ret = trace_fprobe_verify_target(tf);
973 unregister_fprobe_event(tf);
975 dyn_event_add(&tf->devent, trace_probe_event_call(&tf->tp));
1109 struct trace_fprobe *tf;
1117 for_each_trace_fprobe(tf, pos) {
1119 if (!trace_fprobe_is_tracepoint(tf) || !tf->tuser)
1124 tracepoint_user_within_module(tf->tuser, mod)) {
1125 unsigned long ip = tracepoint_user_ip(tf->tuser);
1127 WARN_ON_ONCE(register_fprobe_ips(&tf->fp, &ip, 1));
1136 trace_fprobe_is_registered(tf) &&
1137 !tf->tuser->tpoint) {
1138 unregister_fprobe(&tf->fp);
1237 struct trace_fprobe *tf __free(free_trace_fprobe) = NULL;
1348 tf = alloc_trace_fprobe(group, event, symbol, argc, is_return, is_tracepoint);
1349 if (IS_ERR(tf)) {
1350 ret = PTR_ERR(tf);
1360 ret = traceprobe_parse_probe_arg(&tf->tp, i, argv[i], ctx);
1365 if (is_return && tf->tp.entry_arg) {
1366 tf->fp.entry_handler = trace_fprobe_entry_handler;
1367 tf->fp.entry_data_size = traceprobe_get_entry_data_size(&tf->tp);
1368 if (ALIGN(tf->fp.entry_data_size, sizeof(long)) > MAX_FPROBE_DATA_SIZE) {
1375 ret = traceprobe_set_print_fmt(&tf->tp,
1380 ret = register_trace_fprobe_event(tf);
1392 /* 'tf' is successfully registered. To avoid freeing, assign NULL. */
1393 tf = NULL;
1422 struct trace_fprobe *tf = to_trace_fprobe(ev);
1423 int ret = unregister_trace_fprobe(tf);
1426 free_trace_fprobe(tf);
1432 struct trace_fprobe *tf = to_trace_fprobe(ev);
1435 if (trace_fprobe_is_tracepoint(tf))
1439 seq_printf(m, ":%s/%s", trace_probe_group_name(&tf->tp),
1440 trace_probe_name(&tf->tp));
1442 seq_printf(m, " %s%s", trace_fprobe_symbol(tf),
1443 trace_fprobe_is_return(tf) ? "%return" : "");
1445 for (i = 0; i < tf->tp.nr_args; i++)
1446 seq_printf(m, " %s=%s", tf->tp.args[i].name, tf->tp.args[i].comm);
1460 struct trace_fprobe *tf;
1478 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) {
1479 ret = __register_trace_fprobe(tf);
1495 struct trace_fprobe *tf;
1512 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) {
1513 unregister_fprobe(&tf->fp);