Commit e3dc9f89 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

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@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent b55ce203
...@@ -985,7 +985,7 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs, ...@@ -985,7 +985,7 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs,
struct ring_buffer *buffer; struct ring_buffer *buffer;
int size, dsize, pc; int size, dsize, pc;
unsigned long irq_flags; unsigned long irq_flags;
struct trace_event_call *call = &tk->tp.call; struct trace_event_call *call = trace_probe_event_call(&tk->tp);
WARN_ON(call != trace_file->event_call); WARN_ON(call != trace_file->event_call);
...@@ -1033,7 +1033,7 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, ...@@ -1033,7 +1033,7 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
struct ring_buffer *buffer; struct ring_buffer *buffer;
int size, pc, dsize; int size, pc, dsize;
unsigned long irq_flags; unsigned long irq_flags;
struct trace_event_call *call = &tk->tp.call; struct trace_event_call *call = trace_probe_event_call(&tk->tp);
WARN_ON(call != trace_file->event_call); WARN_ON(call != trace_file->event_call);
...@@ -1163,7 +1163,7 @@ static int kretprobe_event_define_fields(struct trace_event_call *event_call) ...@@ -1163,7 +1163,7 @@ static int kretprobe_event_define_fields(struct trace_event_call *event_call)
static int static int
kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs)
{ {
struct trace_event_call *call = &tk->tp.call; struct trace_event_call *call = trace_probe_event_call(&tk->tp);
struct kprobe_trace_entry_head *entry; struct kprobe_trace_entry_head *entry;
struct hlist_head *head; struct hlist_head *head;
int size, __size, dsize; int size, __size, dsize;
...@@ -1213,7 +1213,7 @@ static void ...@@ -1213,7 +1213,7 @@ static void
kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
struct pt_regs *regs) struct pt_regs *regs)
{ {
struct trace_event_call *call = &tk->tp.call; struct trace_event_call *call = trace_probe_event_call(&tk->tp);
struct kretprobe_trace_entry_head *entry; struct kretprobe_trace_entry_head *entry;
struct hlist_head *head; struct hlist_head *head;
int size, __size, dsize; int size, __size, dsize;
...@@ -1348,9 +1348,10 @@ static struct trace_event_functions kprobe_funcs = { ...@@ -1348,9 +1348,10 @@ static struct trace_event_functions kprobe_funcs = {
.trace = print_kprobe_event .trace = print_kprobe_event
}; };
static inline void init_trace_event_call(struct trace_kprobe *tk, static inline void init_trace_event_call(struct trace_kprobe *tk)
struct trace_event_call *call)
{ {
struct trace_event_call *call = trace_probe_event_call(&tk->tp);
if (trace_kprobe_is_return(tk)) { if (trace_kprobe_is_return(tk)) {
call->event.funcs = &kretprobe_funcs; call->event.funcs = &kretprobe_funcs;
call->class->define_fields = kretprobe_event_define_fields; call->class->define_fields = kretprobe_event_define_fields;
...@@ -1366,7 +1367,7 @@ static inline void init_trace_event_call(struct trace_kprobe *tk, ...@@ -1366,7 +1367,7 @@ static inline void init_trace_event_call(struct trace_kprobe *tk,
static int register_kprobe_event(struct trace_kprobe *tk) static int register_kprobe_event(struct trace_kprobe *tk)
{ {
init_trace_event_call(tk, &tk->tp.call); init_trace_event_call(tk);
return trace_probe_register_event_call(&tk->tp); return trace_probe_register_event_call(&tk->tp);
} }
...@@ -1403,7 +1404,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs, ...@@ -1403,7 +1404,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
return ERR_CAST(tk); return ERR_CAST(tk);
} }
init_trace_event_call(tk, &tk->tp.call); init_trace_event_call(tk);
if (traceprobe_set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) { if (traceprobe_set_print_fmt(&tk->tp, trace_kprobe_is_return(tk)) < 0) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -1414,7 +1415,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs, ...@@ -1414,7 +1415,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
if (ret < 0) if (ret < 0)
goto error; goto error;
return &tk->tp.call; return trace_probe_event_call(&tk->tp);
error: error:
free_trace_kprobe(tk); free_trace_kprobe(tk);
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1447,7 +1448,7 @@ static __init void enable_boot_kprobe_events(void) ...@@ -1447,7 +1448,7 @@ static __init void enable_boot_kprobe_events(void)
mutex_lock(&event_mutex); mutex_lock(&event_mutex);
for_each_trace_kprobe(tk, pos) { for_each_trace_kprobe(tk, pos) {
list_for_each_entry(file, &tr->events, list) list_for_each_entry(file, &tr->events, list)
if (file->event_call == &tk->tp.call) if (file->event_call == trace_probe_event_call(&tk->tp))
trace_event_enable_disable(file, 1, 0); trace_event_enable_disable(file, 1, 0);
} }
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
...@@ -1523,7 +1524,7 @@ find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr) ...@@ -1523,7 +1524,7 @@ find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr)
struct trace_event_file *file; struct trace_event_file *file;
list_for_each_entry(file, &tr->events, list) list_for_each_entry(file, &tr->events, list)
if (file->event_call == &tk->tp.call) if (file->event_call == trace_probe_event_call(&tk->tp))
return file; return file;
return NULL; return NULL;
......
...@@ -844,6 +844,7 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, ...@@ -844,6 +844,7 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len,
int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return) int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return)
{ {
struct trace_event_call *call = trace_probe_event_call(tp);
int len; int len;
char *print_fmt; char *print_fmt;
...@@ -855,7 +856,7 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return) ...@@ -855,7 +856,7 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return)
/* Second: actually write the @print_fmt */ /* Second: actually write the @print_fmt */
__set_print_fmt(tp, print_fmt, len + 1, is_return); __set_print_fmt(tp, print_fmt, len + 1, is_return);
tp->call.print_fmt = print_fmt; call->print_fmt = print_fmt;
return 0; return 0;
} }
...@@ -888,31 +889,34 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call, ...@@ -888,31 +889,34 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,
void trace_probe_cleanup(struct trace_probe *tp) void trace_probe_cleanup(struct trace_probe *tp)
{ {
struct trace_event_call *call = trace_probe_event_call(tp);
int i; int i;
for (i = 0; i < tp->nr_args; i++) for (i = 0; i < tp->nr_args; i++)
traceprobe_free_probe_arg(&tp->args[i]); traceprobe_free_probe_arg(&tp->args[i]);
kfree(tp->call.class->system); kfree(call->class->system);
kfree(tp->call.name); kfree(call->name);
kfree(tp->call.print_fmt); kfree(call->print_fmt);
} }
int trace_probe_init(struct trace_probe *tp, const char *event, int trace_probe_init(struct trace_probe *tp, const char *event,
const char *group) const char *group)
{ {
struct trace_event_call *call = trace_probe_event_call(tp);
if (!event || !group) if (!event || !group)
return -EINVAL; return -EINVAL;
tp->call.class = &tp->class; call->class = &tp->class;
tp->call.name = kstrdup(event, GFP_KERNEL); call->name = kstrdup(event, GFP_KERNEL);
if (!tp->call.name) if (!call->name)
return -ENOMEM; return -ENOMEM;
tp->class.system = kstrdup(group, GFP_KERNEL); tp->class.system = kstrdup(group, GFP_KERNEL);
if (!tp->class.system) { if (!tp->class.system) {
kfree(tp->call.name); kfree(call->name);
tp->call.name = NULL; call->name = NULL;
return -ENOMEM; return -ENOMEM;
} }
INIT_LIST_HEAD(&tp->files); INIT_LIST_HEAD(&tp->files);
...@@ -923,7 +927,7 @@ int trace_probe_init(struct trace_probe *tp, const char *event, ...@@ -923,7 +927,7 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
int trace_probe_register_event_call(struct trace_probe *tp) int trace_probe_register_event_call(struct trace_probe *tp)
{ {
struct trace_event_call *call = &tp->call; struct trace_event_call *call = trace_probe_event_call(tp);
int ret; int ret;
ret = register_trace_event(&call->event); ret = register_trace_event(&call->event);
......
...@@ -276,6 +276,12 @@ static inline const char *trace_probe_group_name(struct trace_probe *tp) ...@@ -276,6 +276,12 @@ static inline const char *trace_probe_group_name(struct trace_probe *tp)
return tp->call.class->system; return tp->call.class->system;
} }
static inline struct trace_event_call *
trace_probe_event_call(struct trace_probe *tp)
{
return &tp->call;
}
static inline int trace_probe_unregister_event_call(struct trace_probe *tp) static inline int trace_probe_unregister_event_call(struct trace_probe *tp)
{ {
/* tp->event is unregistered in trace_remove_event_call() */ /* tp->event is unregistered in trace_remove_event_call() */
......
...@@ -821,7 +821,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu, ...@@ -821,7 +821,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,
struct ring_buffer *buffer; struct ring_buffer *buffer;
void *data; void *data;
int size, esize; int size, esize;
struct trace_event_call *call = &tu->tp.call; struct trace_event_call *call = trace_probe_event_call(&tu->tp);
WARN_ON(call != trace_file->event_call); WARN_ON(call != trace_file->event_call);
...@@ -1113,7 +1113,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu, ...@@ -1113,7 +1113,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
unsigned long func, struct pt_regs *regs, unsigned long func, struct pt_regs *regs,
struct uprobe_cpu_buffer *ucb, int dsize) struct uprobe_cpu_buffer *ucb, int dsize)
{ {
struct trace_event_call *call = &tu->tp.call; struct trace_event_call *call = trace_probe_event_call(&tu->tp);
struct uprobe_trace_entry_head *entry; struct uprobe_trace_entry_head *entry;
struct hlist_head *head; struct hlist_head *head;
void *data; void *data;
...@@ -1316,9 +1316,10 @@ static struct trace_event_functions uprobe_funcs = { ...@@ -1316,9 +1316,10 @@ static struct trace_event_functions uprobe_funcs = {
.trace = print_uprobe_event .trace = print_uprobe_event
}; };
static inline void init_trace_event_call(struct trace_uprobe *tu, static inline void init_trace_event_call(struct trace_uprobe *tu)
struct trace_event_call *call)
{ {
struct trace_event_call *call = trace_probe_event_call(&tu->tp);
call->event.funcs = &uprobe_funcs; call->event.funcs = &uprobe_funcs;
call->class->define_fields = uprobe_event_define_fields; call->class->define_fields = uprobe_event_define_fields;
...@@ -1329,7 +1330,7 @@ static inline void init_trace_event_call(struct trace_uprobe *tu, ...@@ -1329,7 +1330,7 @@ static inline void init_trace_event_call(struct trace_uprobe *tu,
static int register_uprobe_event(struct trace_uprobe *tu) static int register_uprobe_event(struct trace_uprobe *tu)
{ {
init_trace_event_call(tu, &tu->tp.call); init_trace_event_call(tu);
return trace_probe_register_event_call(&tu->tp); return trace_probe_register_event_call(&tu->tp);
} }
...@@ -1376,14 +1377,14 @@ create_local_trace_uprobe(char *name, unsigned long offs, ...@@ -1376,14 +1377,14 @@ create_local_trace_uprobe(char *name, unsigned long offs,
tu->path = path; tu->path = path;
tu->ref_ctr_offset = ref_ctr_offset; tu->ref_ctr_offset = ref_ctr_offset;
tu->filename = kstrdup(name, GFP_KERNEL); tu->filename = kstrdup(name, GFP_KERNEL);
init_trace_event_call(tu, &tu->tp.call); init_trace_event_call(tu);
if (traceprobe_set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) { if (traceprobe_set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
} }
return &tu->tp.call; return trace_probe_event_call(&tu->tp);
error: error:
free_trace_uprobe(tu); free_trace_uprobe(tu);
return ERR_PTR(ret); return ERR_PTR(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment