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>
This commit is contained in:
parent
b55ce203a8
commit
e3dc9f898e
@ -985,7 +985,7 @@ __kprobe_trace_func(struct trace_kprobe *tk, struct pt_regs *regs,
|
||||
struct ring_buffer *buffer;
|
||||
int size, dsize, pc;
|
||||
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);
|
||||
|
||||
@ -1033,7 +1033,7 @@ __kretprobe_trace_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
|
||||
struct ring_buffer *buffer;
|
||||
int size, pc, dsize;
|
||||
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);
|
||||
|
||||
@ -1163,7 +1163,7 @@ static int kretprobe_event_define_fields(struct trace_event_call *event_call)
|
||||
static int
|
||||
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 hlist_head *head;
|
||||
int size, __size, dsize;
|
||||
@ -1213,7 +1213,7 @@ static void
|
||||
kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri,
|
||||
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 hlist_head *head;
|
||||
int size, __size, dsize;
|
||||
@ -1348,9 +1348,10 @@ static struct trace_event_functions kprobe_funcs = {
|
||||
.trace = print_kprobe_event
|
||||
};
|
||||
|
||||
static inline void init_trace_event_call(struct trace_kprobe *tk,
|
||||
struct trace_event_call *call)
|
||||
static inline void init_trace_event_call(struct trace_kprobe *tk)
|
||||
{
|
||||
struct trace_event_call *call = trace_probe_event_call(&tk->tp);
|
||||
|
||||
if (trace_kprobe_is_return(tk)) {
|
||||
call->event.funcs = &kretprobe_funcs;
|
||||
call->class->define_fields = kretprobe_event_define_fields;
|
||||
@ -1366,7 +1367,7 @@ static inline void init_trace_event_call(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);
|
||||
}
|
||||
@ -1403,7 +1404,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
|
||||
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) {
|
||||
ret = -ENOMEM;
|
||||
@ -1414,7 +1415,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
return &tk->tp.call;
|
||||
return trace_probe_event_call(&tk->tp);
|
||||
error:
|
||||
free_trace_kprobe(tk);
|
||||
return ERR_PTR(ret);
|
||||
@ -1447,7 +1448,7 @@ static __init void enable_boot_kprobe_events(void)
|
||||
mutex_lock(&event_mutex);
|
||||
for_each_trace_kprobe(tk, pos) {
|
||||
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);
|
||||
}
|
||||
mutex_unlock(&event_mutex);
|
||||
@ -1523,7 +1524,7 @@ find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr)
|
||||
struct trace_event_file *file;
|
||||
|
||||
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 NULL;
|
||||
|
@ -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)
|
||||
{
|
||||
struct trace_event_call *call = trace_probe_event_call(tp);
|
||||
int len;
|
||||
char *print_fmt;
|
||||
|
||||
@ -855,7 +856,7 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, bool is_return)
|
||||
|
||||
/* Second: actually write the @print_fmt */
|
||||
__set_print_fmt(tp, print_fmt, len + 1, is_return);
|
||||
tp->call.print_fmt = print_fmt;
|
||||
call->print_fmt = print_fmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -888,31 +889,34 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,
|
||||
|
||||
void trace_probe_cleanup(struct trace_probe *tp)
|
||||
{
|
||||
struct trace_event_call *call = trace_probe_event_call(tp);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tp->nr_args; i++)
|
||||
traceprobe_free_probe_arg(&tp->args[i]);
|
||||
|
||||
kfree(tp->call.class->system);
|
||||
kfree(tp->call.name);
|
||||
kfree(tp->call.print_fmt);
|
||||
kfree(call->class->system);
|
||||
kfree(call->name);
|
||||
kfree(call->print_fmt);
|
||||
}
|
||||
|
||||
int trace_probe_init(struct trace_probe *tp, const char *event,
|
||||
const char *group)
|
||||
{
|
||||
struct trace_event_call *call = trace_probe_event_call(tp);
|
||||
|
||||
if (!event || !group)
|
||||
return -EINVAL;
|
||||
|
||||
tp->call.class = &tp->class;
|
||||
tp->call.name = kstrdup(event, GFP_KERNEL);
|
||||
if (!tp->call.name)
|
||||
call->class = &tp->class;
|
||||
call->name = kstrdup(event, GFP_KERNEL);
|
||||
if (!call->name)
|
||||
return -ENOMEM;
|
||||
|
||||
tp->class.system = kstrdup(group, GFP_KERNEL);
|
||||
if (!tp->class.system) {
|
||||
kfree(tp->call.name);
|
||||
tp->call.name = NULL;
|
||||
kfree(call->name);
|
||||
call->name = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
INIT_LIST_HEAD(&tp->files);
|
||||
@ -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)
|
||||
{
|
||||
struct trace_event_call *call = &tp->call;
|
||||
struct trace_event_call *call = trace_probe_event_call(tp);
|
||||
int ret;
|
||||
|
||||
ret = register_trace_event(&call->event);
|
||||
|
@ -276,6 +276,12 @@ static inline const char *trace_probe_group_name(struct trace_probe *tp)
|
||||
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)
|
||||
{
|
||||
/* tp->event is unregistered in trace_remove_event_call() */
|
||||
|
@ -821,7 +821,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,
|
||||
struct ring_buffer *buffer;
|
||||
void *data;
|
||||
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);
|
||||
|
||||
@ -1113,7 +1113,7 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
|
||||
unsigned long func, struct pt_regs *regs,
|
||||
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 hlist_head *head;
|
||||
void *data;
|
||||
@ -1316,9 +1316,10 @@ static struct trace_event_functions uprobe_funcs = {
|
||||
.trace = print_uprobe_event
|
||||
};
|
||||
|
||||
static inline void init_trace_event_call(struct trace_uprobe *tu,
|
||||
struct trace_event_call *call)
|
||||
static inline void init_trace_event_call(struct trace_uprobe *tu)
|
||||
{
|
||||
struct trace_event_call *call = trace_probe_event_call(&tu->tp);
|
||||
|
||||
call->event.funcs = &uprobe_funcs;
|
||||
call->class->define_fields = uprobe_event_define_fields;
|
||||
|
||||
@ -1329,7 +1330,7 @@ static inline void init_trace_event_call(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);
|
||||
}
|
||||
@ -1376,14 +1377,14 @@ create_local_trace_uprobe(char *name, unsigned long offs,
|
||||
tu->path = path;
|
||||
tu->ref_ctr_offset = ref_ctr_offset;
|
||||
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) {
|
||||
ret = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
return &tu->tp.call;
|
||||
return trace_probe_event_call(&tu->tp);
|
||||
error:
|
||||
free_trace_uprobe(tu);
|
||||
return ERR_PTR(ret);
|
||||
|
Loading…
Reference in New Issue
Block a user