tracing: Pass the trace_array into ftrace_probe_ops functions

Pass the trace_array associated to a ftrace_probe_ops into the probe_ops
func(), init() and free() functions. The trace_array is the descriptor that
describes a tracing instance. This will help create the infrastructure that
will allow having function probes unique to tracing instances.
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 04ec7bb6
...@@ -3791,6 +3791,7 @@ static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip, ...@@ -3791,6 +3791,7 @@ static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct pt_regs *pt_regs) struct ftrace_ops *op, struct pt_regs *pt_regs)
{ {
struct ftrace_probe_ops *probe_ops; struct ftrace_probe_ops *probe_ops;
struct trace_array *tr = op->private;
probe_ops = container_of(op, struct ftrace_probe_ops, ops); probe_ops = container_of(op, struct ftrace_probe_ops, ops);
...@@ -3800,7 +3801,7 @@ static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip, ...@@ -3800,7 +3801,7 @@ static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip,
* on the hash. rcu_read_lock is too dangerous here. * on the hash. rcu_read_lock is too dangerous here.
*/ */
preempt_disable_notrace(); preempt_disable_notrace();
probe_ops->func(ip, parent_ip, probe_ops, NULL); probe_ops->func(ip, parent_ip, tr, probe_ops, NULL);
preempt_enable_notrace(); preempt_enable_notrace();
} }
...@@ -3969,6 +3970,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr, ...@@ -3969,6 +3970,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
ops->ops.func = function_trace_probe_call; ops->ops.func = function_trace_probe_call;
ftrace_ops_init(&ops->ops); ftrace_ops_init(&ops->ops);
INIT_LIST_HEAD(&ops->list); INIT_LIST_HEAD(&ops->list);
ops->ops.private = tr;
} }
mutex_lock(&ops->ops.func_hash->regex_lock); mutex_lock(&ops->ops.func_hash->regex_lock);
...@@ -3997,7 +3999,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr, ...@@ -3997,7 +3999,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
* to give the caller an opportunity to do so. * to give the caller an opportunity to do so.
*/ */
if (ops->init) { if (ops->init) {
ret = ops->init(ops, entry->ip, data); ret = ops->init(ops, tr, entry->ip, data);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
...@@ -4038,7 +4040,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr, ...@@ -4038,7 +4040,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
hlist_for_each_entry(entry, &hash->buckets[i], hlist) { hlist_for_each_entry(entry, &hash->buckets[i], hlist) {
if (ftrace_lookup_ip(old_hash, entry->ip)) if (ftrace_lookup_ip(old_hash, entry->ip))
continue; continue;
ops->free(ops, entry->ip, NULL); ops->free(ops, tr, entry->ip, NULL);
} }
} }
goto out_unlock; goto out_unlock;
...@@ -4055,6 +4057,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4055,6 +4057,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
struct ftrace_hash *hash = NULL; struct ftrace_hash *hash = NULL;
struct hlist_node *tmp; struct hlist_node *tmp;
struct hlist_head hhd; struct hlist_head hhd;
struct trace_array *tr;
char str[KSYM_SYMBOL_LEN]; char str[KSYM_SYMBOL_LEN];
int i, ret; int i, ret;
int size; int size;
...@@ -4062,6 +4065,8 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4062,6 +4065,8 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
if (!(ops->ops.flags & FTRACE_OPS_FL_INITIALIZED)) if (!(ops->ops.flags & FTRACE_OPS_FL_INITIALIZED))
return -EINVAL; return -EINVAL;
tr = ops->ops.private;
if (glob && (strcmp(glob, "*") == 0 || !strlen(glob))) if (glob && (strcmp(glob, "*") == 0 || !strlen(glob)))
func_g.search = NULL; func_g.search = NULL;
else if (glob) { else if (glob) {
...@@ -4139,7 +4144,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4139,7 +4144,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
hlist_for_each_entry_safe(entry, tmp, &hhd, hlist) { hlist_for_each_entry_safe(entry, tmp, &hhd, hlist) {
hlist_del(&entry->hlist); hlist_del(&entry->hlist);
if (ops->free) if (ops->free)
ops->free(ops, entry->ip, NULL); ops->free(ops, tr, entry->ip, NULL);
kfree(entry); kfree(entry);
} }
mutex_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
......
...@@ -6736,14 +6736,16 @@ static const struct file_operations tracing_dyn_info_fops = { ...@@ -6736,14 +6736,16 @@ static const struct file_operations tracing_dyn_info_fops = {
#if defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE) #if defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE)
static void static void
ftrace_snapshot(unsigned long ip, unsigned long parent_ip, ftrace_snapshot(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
tracing_snapshot(); tracing_snapshot();
} }
static void static void
ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip, ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
long *count = NULL; long *count = NULL;
...@@ -6785,8 +6787,8 @@ ftrace_snapshot_print(struct seq_file *m, unsigned long ip, ...@@ -6785,8 +6787,8 @@ ftrace_snapshot_print(struct seq_file *m, unsigned long ip,
} }
static int static int
ftrace_snapshot_init(struct ftrace_probe_ops *ops, unsigned long ip, ftrace_snapshot_init(struct ftrace_probe_ops *ops, struct trace_array *tr,
void *data) unsigned long ip, void *data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
...@@ -6794,8 +6796,8 @@ ftrace_snapshot_init(struct ftrace_probe_ops *ops, unsigned long ip, ...@@ -6794,8 +6796,8 @@ ftrace_snapshot_init(struct ftrace_probe_ops *ops, unsigned long ip,
} }
static void static void
ftrace_snapshot_free(struct ftrace_probe_ops *ops, unsigned long ip, ftrace_snapshot_free(struct ftrace_probe_ops *ops, struct trace_array *tr,
void **_data) unsigned long ip, void **data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
......
...@@ -943,11 +943,14 @@ struct ftrace_probe_ops { ...@@ -943,11 +943,14 @@ struct ftrace_probe_ops {
struct list_head list; struct list_head list;
void (*func)(unsigned long ip, void (*func)(unsigned long ip,
unsigned long parent_ip, unsigned long parent_ip,
struct trace_array *tr,
struct ftrace_probe_ops *ops, struct ftrace_probe_ops *ops,
void **data); void **data);
int (*init)(struct ftrace_probe_ops *ops, int (*init)(struct ftrace_probe_ops *ops,
struct trace_array *tr,
unsigned long ip, void *data); unsigned long ip, void *data);
void (*free)(struct ftrace_probe_ops *ops, void (*free)(struct ftrace_probe_ops *ops,
struct trace_array *tr,
unsigned long ip, void **data); unsigned long ip, void **data);
int (*print)(struct seq_file *m, int (*print)(struct seq_file *m,
unsigned long ip, unsigned long ip,
......
...@@ -2470,7 +2470,8 @@ static void update_event_probe(struct event_probe_data *data) ...@@ -2470,7 +2470,8 @@ static void update_event_probe(struct event_probe_data *data)
static void static void
event_enable_probe(unsigned long ip, unsigned long parent_ip, event_enable_probe(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **_data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **_data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
struct event_probe_data *data; struct event_probe_data *data;
...@@ -2486,7 +2487,8 @@ event_enable_probe(unsigned long ip, unsigned long parent_ip, ...@@ -2486,7 +2487,8 @@ event_enable_probe(unsigned long ip, unsigned long parent_ip,
static void static void
event_enable_count_probe(unsigned long ip, unsigned long parent_ip, event_enable_count_probe(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **_data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **_data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
struct event_probe_data *data; struct event_probe_data *data;
...@@ -2542,8 +2544,8 @@ event_enable_print(struct seq_file *m, unsigned long ip, ...@@ -2542,8 +2544,8 @@ event_enable_print(struct seq_file *m, unsigned long ip,
} }
static int static int
event_enable_init(struct ftrace_probe_ops *ops, unsigned long ip, event_enable_init(struct ftrace_probe_ops *ops, struct trace_array *tr,
void *_data) unsigned long ip, void *_data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
struct event_probe_data *data = _data; struct event_probe_data *data = _data;
...@@ -2559,8 +2561,8 @@ event_enable_init(struct ftrace_probe_ops *ops, unsigned long ip, ...@@ -2559,8 +2561,8 @@ event_enable_init(struct ftrace_probe_ops *ops, unsigned long ip,
} }
static void static void
event_enable_free(struct ftrace_probe_ops *ops, unsigned long ip, event_enable_free(struct ftrace_probe_ops *ops, struct trace_array *tr,
void **_data) unsigned long ip, void **_data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
struct event_probe_data *data; struct event_probe_data *data;
......
...@@ -328,21 +328,24 @@ static void update_traceon_count(struct ftrace_probe_ops *ops, ...@@ -328,21 +328,24 @@ static void update_traceon_count(struct ftrace_probe_ops *ops,
static void static void
ftrace_traceon_count(unsigned long ip, unsigned long parent_ip, ftrace_traceon_count(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
update_traceon_count(ops, ip, 1); update_traceon_count(ops, ip, 1);
} }
static void static void
ftrace_traceoff_count(unsigned long ip, unsigned long parent_ip, ftrace_traceoff_count(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
update_traceon_count(ops, ip, 0); update_traceon_count(ops, ip, 0);
} }
static void static void
ftrace_traceon(unsigned long ip, unsigned long parent_ip, ftrace_traceon(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
if (tracing_is_on()) if (tracing_is_on())
return; return;
...@@ -352,7 +355,8 @@ ftrace_traceon(unsigned long ip, unsigned long parent_ip, ...@@ -352,7 +355,8 @@ ftrace_traceon(unsigned long ip, unsigned long parent_ip,
static void static void
ftrace_traceoff(unsigned long ip, unsigned long parent_ip, ftrace_traceoff(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
if (!tracing_is_on()) if (!tracing_is_on())
return; return;
...@@ -371,14 +375,16 @@ ftrace_traceoff(unsigned long ip, unsigned long parent_ip, ...@@ -371,14 +375,16 @@ ftrace_traceoff(unsigned long ip, unsigned long parent_ip,
static void static void
ftrace_stacktrace(unsigned long ip, unsigned long parent_ip, ftrace_stacktrace(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
trace_dump_stack(STACK_SKIP); trace_dump_stack(STACK_SKIP);
} }
static void static void
ftrace_stacktrace_count(unsigned long ip, unsigned long parent_ip, ftrace_stacktrace_count(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
long *count; long *count;
...@@ -436,7 +442,8 @@ static int update_count(struct ftrace_probe_ops *ops, unsigned long ip) ...@@ -436,7 +442,8 @@ static int update_count(struct ftrace_probe_ops *ops, unsigned long ip)
static void static void
ftrace_dump_probe(unsigned long ip, unsigned long parent_ip, ftrace_dump_probe(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
if (update_count(ops, ip)) if (update_count(ops, ip))
ftrace_dump(DUMP_ALL); ftrace_dump(DUMP_ALL);
...@@ -445,7 +452,8 @@ ftrace_dump_probe(unsigned long ip, unsigned long parent_ip, ...@@ -445,7 +452,8 @@ ftrace_dump_probe(unsigned long ip, unsigned long parent_ip,
/* Only dump the current CPU buffer. */ /* Only dump the current CPU buffer. */
static void static void
ftrace_cpudump_probe(unsigned long ip, unsigned long parent_ip, ftrace_cpudump_probe(unsigned long ip, unsigned long parent_ip,
struct ftrace_probe_ops *ops, void **data) struct trace_array *tr, struct ftrace_probe_ops *ops,
void **data)
{ {
if (update_count(ops, ip)) if (update_count(ops, ip))
ftrace_dump(DUMP_ORIG); ftrace_dump(DUMP_ORIG);
...@@ -473,7 +481,8 @@ ftrace_probe_print(const char *name, struct seq_file *m, ...@@ -473,7 +481,8 @@ ftrace_probe_print(const char *name, struct seq_file *m,
static int static int
ftrace_traceon_print(struct seq_file *m, unsigned long ip, ftrace_traceon_print(struct seq_file *m, unsigned long ip,
struct ftrace_probe_ops *ops, void *data) struct ftrace_probe_ops *ops,
void *data)
{ {
return ftrace_probe_print("traceon", m, ip, ops); return ftrace_probe_print("traceon", m, ip, ops);
} }
...@@ -508,8 +517,8 @@ ftrace_cpudump_print(struct seq_file *m, unsigned long ip, ...@@ -508,8 +517,8 @@ ftrace_cpudump_print(struct seq_file *m, unsigned long ip,
static int static int
ftrace_count_init(struct ftrace_probe_ops *ops, unsigned long ip, ftrace_count_init(struct ftrace_probe_ops *ops, struct trace_array *tr,
void *data) unsigned long ip, void *data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
...@@ -517,8 +526,8 @@ ftrace_count_init(struct ftrace_probe_ops *ops, unsigned long ip, ...@@ -517,8 +526,8 @@ ftrace_count_init(struct ftrace_probe_ops *ops, unsigned long ip,
} }
static void static void
ftrace_count_free(struct ftrace_probe_ops *ops, unsigned long ip, ftrace_count_free(struct ftrace_probe_ops *ops, struct trace_array *tr,
void **_data) unsigned long ip, void **_data)
{ {
struct ftrace_func_mapper *mapper = ops->private_data; struct ftrace_func_mapper *mapper = ops->private_data;
......
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