ftrace: Have unregister_ftrace_function_probe_func() return a value

Currently unregister_ftrace_function_probe_func() is a void function. It
does not give any feedback if an error occurred or no item was found to
remove and nothing was done.

Change it to return status and success if it removed something. Also update
the callers to return that feedback to the user.
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent e16b35dd
...@@ -4102,7 +4102,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, ...@@ -4102,7 +4102,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
return count; return count;
} }
void int
unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
{ {
struct ftrace_ops_hash old_hash_ops; struct ftrace_ops_hash old_hash_ops;
...@@ -4131,7 +4131,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4131,7 +4131,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
/* we do not support '!' for function probes */ /* we do not support '!' for function probes */
if (WARN_ON(not)) if (WARN_ON(not))
return; return -EINVAL;
} }
mutex_lock(&trace_probe_ops.func_hash->regex_lock); mutex_lock(&trace_probe_ops.func_hash->regex_lock);
...@@ -4140,9 +4140,9 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4140,9 +4140,9 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
/* Probes only have filters */ /* Probes only have filters */
old_hash_ops.notrace_hash = NULL; old_hash_ops.notrace_hash = NULL;
ret = -ENOMEM;
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
if (!hash) if (!hash)
/* Hmm, should report this somehow */
goto out_unlock; goto out_unlock;
INIT_LIST_HEAD(&free_list); INIT_LIST_HEAD(&free_list);
...@@ -4173,6 +4173,13 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4173,6 +4173,13 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
list_add(&entry->free_list, &free_list); list_add(&entry->free_list, &free_list);
} }
} }
/* Nothing found? */
if (list_empty(&free_list)) {
ret = -EINVAL;
goto out_unlock;
}
mutex_lock(&ftrace_lock); mutex_lock(&ftrace_lock);
disabled = __disable_ftrace_function_probe(); disabled = __disable_ftrace_function_probe();
/* /*
...@@ -4198,6 +4205,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops) ...@@ -4198,6 +4205,7 @@ unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
out_unlock: out_unlock:
mutex_unlock(&trace_probe_ops.func_hash->regex_lock); mutex_unlock(&trace_probe_ops.func_hash->regex_lock);
free_ftrace_hash(hash); free_ftrace_hash(hash);
return ret;
} }
static LIST_HEAD(ftrace_commands); static LIST_HEAD(ftrace_commands);
......
...@@ -6829,10 +6829,8 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash, ...@@ -6829,10 +6829,8 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
ops = param ? &snapshot_count_probe_ops : &snapshot_probe_ops; ops = param ? &snapshot_count_probe_ops : &snapshot_probe_ops;
if (glob[0] == '!') { if (glob[0] == '!')
unregister_ftrace_function_probe_func(glob+1, ops); return unregister_ftrace_function_probe_func(glob+1, ops);
return 0;
}
if (!param) if (!param)
goto out_reg; goto out_reg;
......
...@@ -963,7 +963,7 @@ void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper, ...@@ -963,7 +963,7 @@ void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper,
extern int extern int
register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
void *data); void *data);
extern void extern int
unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops); unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops);
int register_ftrace_command(struct ftrace_func_command *cmd); int register_ftrace_command(struct ftrace_func_command *cmd);
......
...@@ -2652,8 +2652,7 @@ event_enable_func(struct ftrace_hash *hash, ...@@ -2652,8 +2652,7 @@ event_enable_func(struct ftrace_hash *hash,
ops = param ? &event_disable_count_probe_ops : &event_disable_probe_ops; ops = param ? &event_disable_count_probe_ops : &event_disable_probe_ops;
if (glob[0] == '!') { if (glob[0] == '!') {
unregister_ftrace_function_probe_func(glob+1, ops); ret = unregister_ftrace_function_probe_func(glob+1, ops);
ret = 0;
goto out; goto out;
} }
......
...@@ -586,10 +586,8 @@ ftrace_trace_probe_callback(struct ftrace_probe_ops *ops, ...@@ -586,10 +586,8 @@ ftrace_trace_probe_callback(struct ftrace_probe_ops *ops,
if (!enable) if (!enable)
return -EINVAL; return -EINVAL;
if (glob[0] == '!') { if (glob[0] == '!')
unregister_ftrace_function_probe_func(glob+1, ops); return unregister_ftrace_function_probe_func(glob+1, ops);
return 0;
}
if (!param) if (!param)
goto out_reg; goto out_reg;
......
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