Commit f5f6b255 authored by Tom Zanussi's avatar Tom Zanussi Committed by Steven Rostedt (VMware)

tracing: Add synth_event_delete()

create_or_delete_synth_event() contains code to delete a synthetic
event, which would be useful on its own - specifically, it would be
useful to allow event-creating modules to call it separately.

Separate out the delete code from that function and create an exported
function named synth_event_delete().

Link: http://lkml.kernel.org/r/050db3b06df7f0a4b8a2922da602d1d879c7c1c2.1580323897.git.zanussi@kernel.orgAcked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarTom Zanussi <zanussi@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent e3e2a2cc
...@@ -354,6 +354,8 @@ extern struct trace_event_file *trace_get_event_file(const char *instance, ...@@ -354,6 +354,8 @@ extern struct trace_event_file *trace_get_event_file(const char *instance,
const char *event); const char *event);
extern void trace_put_event_file(struct trace_event_file *file); extern void trace_put_event_file(struct trace_event_file *file);
extern int synth_event_delete(const char *name);
/* /*
* Event file flags: * Event file flags:
* ENABLED - The event is enabled * ENABLED - The event is enabled
......
...@@ -1360,29 +1360,54 @@ static int __create_synth_event(int argc, const char *name, const char **argv) ...@@ -1360,29 +1360,54 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
goto out; goto out;
} }
static int create_or_delete_synth_event(int argc, char **argv) static int destroy_synth_event(struct synth_event *se)
{ {
const char *name = argv[0];
struct synth_event *event = NULL;
int ret; int ret;
/* trace_run_command() ensures argc != 0 */ if (se->ref)
if (name[0] == '!') {
mutex_lock(&event_mutex);
event = find_synth_event(name + 1);
if (event) {
if (event->ref)
ret = -EBUSY; ret = -EBUSY;
else { else {
ret = unregister_synth_event(event); ret = unregister_synth_event(se);
if (!ret) { if (!ret) {
dyn_event_remove(&event->devent); dyn_event_remove(&se->devent);
free_synth_event(event); free_synth_event(se);
} }
} }
} else
ret = -ENOENT; return ret;
}
/**
* synth_event_delete - Delete a synthetic event
* @event_name: The name of the new sythetic event
*
* Delete a synthetic event that was created with synth_event_create().
*
* Return: 0 if successful, error otherwise.
*/
int synth_event_delete(const char *event_name)
{
struct synth_event *se = NULL;
int ret = -ENOENT;
mutex_lock(&event_mutex);
se = find_synth_event(event_name);
if (se)
ret = destroy_synth_event(se);
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(synth_event_delete);
static int create_or_delete_synth_event(int argc, char **argv)
{
const char *name = argv[0];
int ret;
/* trace_run_command() ensures argc != 0 */
if (name[0] == '!') {
ret = synth_event_delete(name + 1);
return ret; return 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