Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing/probe: Add trace_event_call accesses APIs

Add trace_event_call access APIs for trace_probe.
Instead of accessing trace_probe.call directly, use those
accesses by trace_probe_event_call() method. This hides
the relationship of trace_event_call and trace_probe from
trace_kprobe and trace_uprobe.

Link: http://lkml.kernel.org/r/155931587711.28323.8335129014686133120.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
e3dc9f89 b55ce203

+40 -28
+12 -11
kernel/trace/trace_kprobe.c
··· 985 985 struct ring_buffer *buffer; 986 986 int size, dsize, pc; 987 987 unsigned long irq_flags; 988 - struct trace_event_call *call = &tk->tp.call; 988 + struct trace_event_call *call = trace_probe_event_call(&tk->tp); 989 989 990 990 WARN_ON(call != trace_file->event_call); 991 991 ··· 1033 1033 struct ring_buffer *buffer; 1034 1034 int size, pc, dsize; 1035 1035 unsigned long irq_flags; 1036 - struct trace_event_call *call = &tk->tp.call; 1036 + struct trace_event_call *call = trace_probe_event_call(&tk->tp); 1037 1037 1038 1038 WARN_ON(call != trace_file->event_call); 1039 1039 ··· 1163 1163 static int 1164 1164 kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) 1165 1165 { 1166 - struct trace_event_call *call = &tk->tp.call; 1166 + struct trace_event_call *call = trace_probe_event_call(&tk->tp); 1167 1167 struct kprobe_trace_entry_head *entry; 1168 1168 struct hlist_head *head; 1169 1169 int size, __size, dsize; ··· 1213 1213 kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, 1214 1214 struct pt_regs *regs) 1215 1215 { 1216 - struct trace_event_call *call = &tk->tp.call; 1216 + struct trace_event_call *call = trace_probe_event_call(&tk->tp); 1217 1217 struct kretprobe_trace_entry_head *entry; 1218 1218 struct hlist_head *head; 1219 1219 int size, __size, dsize; ··· 1348 1348 .trace = print_kprobe_event 1349 1349 }; 1350 1350 1351 - static inline void init_trace_event_call(struct trace_kprobe *tk, 1352 - struct trace_event_call *call) 1351 + static inline void init_trace_event_call(struct trace_kprobe *tk) 1353 1352 { 1353 + struct trace_event_call *call = trace_probe_event_call(&tk->tp); 1354 + 1354 1355 if (trace_kprobe_is_return(tk)) { 1355 1356 call->event.funcs = &kretprobe_funcs; 1356 1357 call->class->define_fields = kretprobe_event_define_fields; ··· 1367 1366 1368 1367 static int register_kprobe_event(struct trace_kprobe *tk) 1369 1368 { 1370 - init_trace_event_call(tk, &tk->tp.call); 1369 + init_trace_event_call(tk); 1371 1370 1372 1371 return trace_probe_register_event_call(&tk->tp); 1373 1372 } ··· 1404 1403 return ERR_CAST(tk); 1405 1404 } 1406 1405 1407 - init_trace_event_call(tk, &tk->tp.call); 1406 + init_trace_event_call(tk); 1408 1407 1409 1408 if (traceprobe_set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) { 1410 1409 ret = -ENOMEM; ··· 1415 1414 if (ret < 0) 1416 1415 goto error; 1417 1416 1418 - return &tk->tp.call; 1417 + return trace_probe_event_call(&tk->tp); 1419 1418 error: 1420 1419 free_trace_kprobe(tk); 1421 1420 return ERR_PTR(ret); ··· 1448 1447 mutex_lock(&event_mutex); 1449 1448 for_each_trace_kprobe(tk, pos) { 1450 1449 list_for_each_entry(file, &tr->events, list) 1451 - if (file->event_call == &tk->tp.call) 1450 + if (file->event_call == trace_probe_event_call(&tk->tp)) 1452 1451 trace_event_enable_disable(file, 1, 0); 1453 1452 } 1454 1453 mutex_unlock(&event_mutex); ··· 1524 1523 struct trace_event_file *file; 1525 1524 1526 1525 list_for_each_entry(file, &tr->events, list) 1527 - if (file->event_call == &tk->tp.call) 1526 + if (file->event_call == trace_probe_event_call(&tk->tp)) 1528 1527 return file; 1529 1528 1530 1529 return NULL;
+14 -10
kernel/trace/trace_probe.c
··· 844 844 845 845 int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return) 846 846 { 847 + struct trace_event_call *call = trace_probe_event_call(tp); 847 848 int len; 848 849 char *print_fmt; 849 850 ··· 856 855 857 856 /* Second: actually write the @print_fmt */ 858 857 __set_print_fmt(tp, print_fmt, len + 1, is_return); 859 - tp->call.print_fmt = print_fmt; 858 + call->print_fmt = print_fmt; 860 859 861 860 return 0; 862 861 } ··· 889 888 890 889 void trace_probe_cleanup(struct trace_probe *tp) 891 890 { 891 + struct trace_event_call *call = trace_probe_event_call(tp); 892 892 int i; 893 893 894 894 for (i = 0; i < tp->nr_args; i++) 895 895 traceprobe_free_probe_arg(&tp->args[i]); 896 896 897 - kfree(tp->call.class->system); 898 - kfree(tp->call.name); 899 - kfree(tp->call.print_fmt); 897 + kfree(call->class->system); 898 + kfree(call->name); 899 + kfree(call->print_fmt); 900 900 } 901 901 902 902 int trace_probe_init(struct trace_probe *tp, const char *event, 903 903 const char *group) 904 904 { 905 + struct trace_event_call *call = trace_probe_event_call(tp); 906 + 905 907 if (!event || !group) 906 908 return -EINVAL; 907 909 908 - tp->call.class = &tp->class; 909 - tp->call.name = kstrdup(event, GFP_KERNEL); 910 - if (!tp->call.name) 910 + call->class = &tp->class; 911 + call->name = kstrdup(event, GFP_KERNEL); 912 + if (!call->name) 911 913 return -ENOMEM; 912 914 913 915 tp->class.system = kstrdup(group, GFP_KERNEL); 914 916 if (!tp->class.system) { 915 - kfree(tp->call.name); 916 - tp->call.name = NULL; 917 + kfree(call->name); 918 + call->name = NULL; 917 919 return -ENOMEM; 918 920 } 919 921 INIT_LIST_HEAD(&tp->files); ··· 927 923 928 924 int trace_probe_register_event_call(struct trace_probe *tp) 929 925 { 930 - struct trace_event_call *call = &tp->call; 926 + struct trace_event_call *call = trace_probe_event_call(tp); 931 927 int ret; 932 928 933 929 ret = register_trace_event(&call->event);
+6
kernel/trace/trace_probe.h
··· 276 276 return tp->call.class->system; 277 277 } 278 278 279 + static inline struct trace_event_call * 280 + trace_probe_event_call(struct trace_probe *tp) 281 + { 282 + return &tp->call; 283 + } 284 + 279 285 static inline int trace_probe_unregister_event_call(struct trace_probe *tp) 280 286 { 281 287 /* tp->event is unregistered in trace_remove_event_call() */
+8 -7
kernel/trace/trace_uprobe.c
··· 821 821 struct ring_buffer *buffer; 822 822 void *data; 823 823 int size, esize; 824 - struct trace_event_call *call = &tu->tp.call; 824 + struct trace_event_call *call = trace_probe_event_call(&tu->tp); 825 825 826 826 WARN_ON(call != trace_file->event_call); 827 827 ··· 1113 1113 unsigned long func, struct pt_regs *regs, 1114 1114 struct uprobe_cpu_buffer *ucb, int dsize) 1115 1115 { 1116 - struct trace_event_call *call = &tu->tp.call; 1116 + struct trace_event_call *call = trace_probe_event_call(&tu->tp); 1117 1117 struct uprobe_trace_entry_head *entry; 1118 1118 struct hlist_head *head; 1119 1119 void *data; ··· 1316 1316 .trace = print_uprobe_event 1317 1317 }; 1318 1318 1319 - static inline void init_trace_event_call(struct trace_uprobe *tu, 1320 - struct trace_event_call *call) 1319 + static inline void init_trace_event_call(struct trace_uprobe *tu) 1321 1320 { 1321 + struct trace_event_call *call = trace_probe_event_call(&tu->tp); 1322 + 1322 1323 call->event.funcs = &uprobe_funcs; 1323 1324 call->class->define_fields = uprobe_event_define_fields; 1324 1325 ··· 1330 1329 1331 1330 static int register_uprobe_event(struct trace_uprobe *tu) 1332 1331 { 1333 - init_trace_event_call(tu, &tu->tp.call); 1332 + init_trace_event_call(tu); 1334 1333 1335 1334 return trace_probe_register_event_call(&tu->tp); 1336 1335 } ··· 1377 1376 tu->path = path; 1378 1377 tu->ref_ctr_offset = ref_ctr_offset; 1379 1378 tu->filename = kstrdup(name, GFP_KERNEL); 1380 - init_trace_event_call(tu, &tu->tp.call); 1379 + init_trace_event_call(tu); 1381 1380 1382 1381 if (traceprobe_set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) { 1383 1382 ret = -ENOMEM; 1384 1383 goto error; 1385 1384 } 1386 1385 1387 - return &tu->tp.call; 1386 + return trace_probe_event_call(&tu->tp); 1388 1387 error: 1389 1388 free_trace_uprobe(tu); 1390 1389 return ERR_PTR(ret);