aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2019-05-31 11:17:57 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-07-16 15:14:47 -0400
commite3dc9f898ef9c6a1a96378517573ee2d04d0abcc (patch)
tree262ce067fc6f2c093026ba9286fa6bc7f12e1cd3
parentb55ce203a8f327b623688c8fb551ac3f9781edea (diff)
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>
-rw-r--r--kernel/trace/trace_kprobe.c23
-rw-r--r--kernel/trace/trace_probe.c24
-rw-r--r--kernel/trace/trace_probe.h6
-rw-r--r--kernel/trace/trace_uprobe.c15
4 files changed, 40 insertions, 28 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 3cf8cee4f276..62362ad1ad98 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -985,7 +985,7 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs,
985 struct ring_buffer *buffer; 985 struct ring_buffer *buffer;
986 int size, dsize, pc; 986 int size, dsize, pc;
987 unsigned long irq_flags; 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 WARN_ON(call != trace_file->event_call); 990 WARN_ON(call != trace_file->event_call);
991 991
@@ -1033,7 +1033,7 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
1033 struct ring_buffer *buffer; 1033 struct ring_buffer *buffer;
1034 int size, pc, dsize; 1034 int size, pc, dsize;
1035 unsigned long irq_flags; 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 WARN_ON(call != trace_file->event_call); 1038 WARN_ON(call != trace_file->event_call);
1039 1039
@@ -1163,7 +1163,7 @@ static int kretprobe_event_define_fields(struct trace_event_call *event_call)
1163static int 1163static int
1164kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) 1164kprobe_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 struct kprobe_trace_entry_head *entry; 1167 struct kprobe_trace_entry_head *entry;
1168 struct hlist_head *head; 1168 struct hlist_head *head;
1169 int size, __size, dsize; 1169 int size, __size, dsize;
@@ -1213,7 +1213,7 @@ static void
1213kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, 1213kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
1214 struct pt_regs *regs) 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 struct kretprobe_trace_entry_head *entry; 1217 struct kretprobe_trace_entry_head *entry;
1218 struct hlist_head *head; 1218 struct hlist_head *head;
1219 int size, __size, dsize; 1219 int size, __size, dsize;
@@ -1348,9 +1348,10 @@ static struct trace_event_functions kprobe_funcs = {
1348 .trace = print_kprobe_event 1348 .trace = print_kprobe_event
1349}; 1349};
1350 1350
1351static inline void init_trace_event_call(struct trace_kprobe *tk, 1351static inline void init_trace_event_call(struct trace_kprobe *tk)
1352 struct trace_event_call *call)
1353{ 1352{
1353 struct trace_event_call *call = trace_probe_event_call(&tk->tp);
1354
1354 if (trace_kprobe_is_return(tk)) { 1355 if (trace_kprobe_is_return(tk)) {
1355 call->event.funcs = &kretprobe_funcs; 1356 call->event.funcs = &kretprobe_funcs;
1356 call->class->define_fields = kretprobe_event_define_fields; 1357 call->class->define_fields = kretprobe_event_define_fields;
@@ -1366,7 +1367,7 @@ static inline void init_trace_event_call(struct trace_kprobe *tk,
1366 1367
1367static int register_kprobe_event(struct trace_kprobe *tk) 1368static int register_kprobe_event(struct trace_kprobe *tk)
1368{ 1369{
1369 init_trace_event_call(tk, &tk->tp.call); 1370 init_trace_event_call(tk);
1370 1371
1371 return trace_probe_register_event_call(&tk->tp); 1372 return trace_probe_register_event_call(&tk->tp);
1372} 1373}
@@ -1403,7 +1404,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
1403 return ERR_CAST(tk); 1404 return ERR_CAST(tk);
1404 } 1405 }
1405 1406
1406 init_trace_event_call(tk, &tk->tp.call); 1407 init_trace_event_call(tk);
1407 1408
1408 if (traceprobe_set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) { 1409 if (traceprobe_set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) {
1409 ret = -ENOMEM; 1410 ret = -ENOMEM;
@@ -1414,7 +1415,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
1414 if (ret < 0) 1415 if (ret < 0)
1415 goto error; 1416 goto error;
1416 1417
1417 return &tk->tp.call; 1418 return trace_probe_event_call(&tk->tp);
1418error: 1419error:
1419 free_trace_kprobe(tk); 1420 free_trace_kprobe(tk);
1420 return ERR_PTR(ret); 1421 return ERR_PTR(ret);
@@ -1447,7 +1448,7 @@ static __init void enable_boot_kprobe_events(void)
1447 mutex_lock(&event_mutex); 1448 mutex_lock(&event_mutex);
1448 for_each_trace_kprobe(tk, pos) { 1449 for_each_trace_kprobe(tk, pos) {
1449 list_for_each_entry(file, &tr->events, list) 1450 list_for_each_entry(file, &tr->events, list)
1450 if (file->event_call == &tk->tp.call) 1451 if (file->event_call == trace_probe_event_call(&tk->tp))
1451 trace_event_enable_disable(file, 1, 0); 1452 trace_event_enable_disable(file, 1, 0);
1452 } 1453 }
1453 mutex_unlock(&event_mutex); 1454 mutex_unlock(&event_mutex);
@@ -1523,7 +1524,7 @@ find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr)
1523 struct trace_event_file *file; 1524 struct trace_event_file *file;
1524 1525
1525 list_for_each_entry(file, &tr->events, list) 1526 list_for_each_entry(file, &tr->events, list)
1526 if (file->event_call == &tk->tp.call) 1527 if (file->event_call == trace_probe_event_call(&tk->tp))
1527 return file; 1528 return file;
1528 1529
1529 return NULL; 1530 return NULL;
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 323a11ad1dad..dbef0d135075 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -844,6 +844,7 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len,
844 844
845int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return) 845int 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 int len; 848 int len;
848 char *print_fmt; 849 char *print_fmt;
849 850
@@ -855,7 +856,7 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return)
855 856
856 /* Second: actually write the @print_fmt */ 857 /* Second: actually write the @print_fmt */
857 __set_print_fmt(tp, print_fmt, len + 1, is_return); 858 __set_print_fmt(tp, print_fmt, len + 1, is_return);
858 tp->call.print_fmt = print_fmt; 859 call->print_fmt = print_fmt;
859 860
860 return 0; 861 return 0;
861} 862}
@@ -888,31 +889,34 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,
888 889
889void trace_probe_cleanup(struct trace_probe *tp) 890void trace_probe_cleanup(struct trace_probe *tp)
890{ 891{
892 struct trace_event_call *call = trace_probe_event_call(tp);
891 int i; 893 int i;
892 894
893 for (i = 0; i < tp->nr_args; i++) 895 for (i = 0; i < tp->nr_args; i++)
894 traceprobe_free_probe_arg(&tp->args[i]); 896 traceprobe_free_probe_arg(&tp->args[i]);
895 897
896 kfree(tp->call.class->system); 898 kfree(call->class->system);
897 kfree(tp->call.name); 899 kfree(call->name);
898 kfree(tp->call.print_fmt); 900 kfree(call->print_fmt);
899} 901}
900 902
901int trace_probe_init(struct trace_probe *tp, const char *event, 903int trace_probe_init(struct trace_probe *tp, const char *event,
902 const char *group) 904 const char *group)
903{ 905{
906 struct trace_event_call *call = trace_probe_event_call(tp);
907
904 if (!event || !group) 908 if (!event || !group)
905 return -EINVAL; 909 return -EINVAL;
906 910
907 tp->call.class = &tp->class; 911 call->class = &tp->class;
908 tp->call.name = kstrdup(event, GFP_KERNEL); 912 call->name = kstrdup(event, GFP_KERNEL);
909 if (!tp->call.name) 913 if (!call->name)
910 return -ENOMEM; 914 return -ENOMEM;
911 915
912 tp->class.system = kstrdup(group, GFP_KERNEL); 916 tp->class.system = kstrdup(group, GFP_KERNEL);
913 if (!tp->class.system) { 917 if (!tp->class.system) {
914 kfree(tp->call.name); 918 kfree(call->name);
915 tp->call.name = NULL; 919 call->name = NULL;
916 return -ENOMEM; 920 return -ENOMEM;
917 } 921 }
918 INIT_LIST_HEAD(&tp->files); 922 INIT_LIST_HEAD(&tp->files);
@@ -923,7 +927,7 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
923 927
924int trace_probe_register_event_call(struct trace_probe *tp) 928int trace_probe_register_event_call(struct trace_probe *tp)
925{ 929{
926 struct trace_event_call *call = &tp->call; 930 struct trace_event_call *call = trace_probe_event_call(tp);
927 int ret; 931 int ret;
928 932
929 ret = register_trace_event(&call->event); 933 ret = register_trace_event(&call->event);
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 67424cb5d5d6..6c33d4aa36c3 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -276,6 +276,12 @@ static inline const char *trace_probe_group_name(struct trace_probe *tp)
276 return tp->call.class->system; 276 return tp->call.class->system;
277} 277}
278 278
279static inline struct trace_event_call *
280 trace_probe_event_call(struct trace_probe *tp)
281{
282 return &tp->call;
283}
284
279static inline int trace_probe_unregister_event_call(struct trace_probe *tp) 285static inline int trace_probe_unregister_event_call(struct trace_probe *tp)
280{ 286{
281 /* tp->event is unregistered in trace_remove_event_call() */ 287 /* tp->event is unregistered in trace_remove_event_call() */
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 09fdba3ee9d9..7fb9353b47d9 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -821,7 +821,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,
821 struct ring_buffer *buffer; 821 struct ring_buffer *buffer;
822 void *data; 822 void *data;
823 int size, esize; 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 WARN_ON(call != trace_file->event_call); 826 WARN_ON(call != trace_file->event_call);
827 827
@@ -1113,7 +1113,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
1113 unsigned long func, struct pt_regs *regs, 1113 unsigned long func, struct pt_regs *regs,
1114 struct uprobe_cpu_buffer *ucb, int dsize) 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 struct uprobe_trace_entry_head *entry; 1117 struct uprobe_trace_entry_head *entry;
1118 struct hlist_head *head; 1118 struct hlist_head *head;
1119 void *data; 1119 void *data;
@@ -1316,9 +1316,10 @@ static struct trace_event_functions uprobe_funcs = {
1316 .trace = print_uprobe_event 1316 .trace = print_uprobe_event
1317}; 1317};
1318 1318
1319static inline void init_trace_event_call(struct trace_uprobe *tu, 1319static inline void init_trace_event_call(struct trace_uprobe *tu)
1320 struct trace_event_call *call)
1321{ 1320{
1321 struct trace_event_call *call = trace_probe_event_call(&tu->tp);
1322
1322 call->event.funcs = &uprobe_funcs; 1323 call->event.funcs = &uprobe_funcs;
1323 call->class->define_fields = uprobe_event_define_fields; 1324 call->class->define_fields = uprobe_event_define_fields;
1324 1325
@@ -1329,7 +1330,7 @@ static inline void init_trace_event_call(struct trace_uprobe *tu,
1329 1330
1330static int register_uprobe_event(struct trace_uprobe *tu) 1331static int register_uprobe_event(struct trace_uprobe *tu)
1331{ 1332{
1332 init_trace_event_call(tu, &tu->tp.call); 1333 init_trace_event_call(tu);
1333 1334
1334 return trace_probe_register_event_call(&tu->tp); 1335 return trace_probe_register_event_call(&tu->tp);
1335} 1336}
@@ -1376,14 +1377,14 @@ create_local_trace_uprobe(char *name, unsigned long offs,
1376 tu->path = path; 1377 tu->path = path;
1377 tu->ref_ctr_offset = ref_ctr_offset; 1378 tu->ref_ctr_offset = ref_ctr_offset;
1378 tu->filename = kstrdup(name, GFP_KERNEL); 1379 tu->filename = kstrdup(name, GFP_KERNEL);
1379 init_trace_event_call(tu, &tu->tp.call); 1380 init_trace_event_call(tu);
1380 1381
1381 if (traceprobe_set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) { 1382 if (traceprobe_set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) {
1382 ret = -ENOMEM; 1383 ret = -ENOMEM;
1383 goto error; 1384 goto error;
1384 } 1385 }
1385 1386
1386 return &tu->tp.call; 1387 return trace_probe_event_call(&tu->tp);
1387error: 1388error:
1388 free_trace_uprobe(tu); 1389 free_trace_uprobe(tu);
1389 return ERR_PTR(ret); 1390 return ERR_PTR(ret);