tracing: Simplify creation and deletion of synthetic events
Since the event_mutex and synth_event_mutex ordering issue is gone, we can skip existing event check when adding or deleting events, and some redundant code in error path. This changes release_all_synth_events() to abort the process when it hits any error and returns the error code. It succeeds only if it has no error. Link: http://lkml.kernel.org/r/154140847194.17322.17960275728005067803.stgit@devbox Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com> Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
Родитель
fc800a10be
Коммит
faacb361f2
|
@ -1008,18 +1008,6 @@ struct hist_var_data {
|
||||||
struct hist_trigger_data *hist_data;
|
struct hist_trigger_data *hist_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void add_or_delete_synth_event(struct synth_event *event, int delete)
|
|
||||||
{
|
|
||||||
if (delete)
|
|
||||||
free_synth_event(event);
|
|
||||||
else {
|
|
||||||
if (!find_synth_event(event->name))
|
|
||||||
list_add(&event->list, &synth_event_list);
|
|
||||||
else
|
|
||||||
free_synth_event(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int create_synth_event(int argc, char **argv)
|
static int create_synth_event(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct synth_field *field, *fields[SYNTH_FIELDS_MAX];
|
struct synth_field *field, *fields[SYNTH_FIELDS_MAX];
|
||||||
|
@ -1052,15 +1040,16 @@ static int create_synth_event(int argc, char **argv)
|
||||||
if (event) {
|
if (event) {
|
||||||
if (delete_event) {
|
if (delete_event) {
|
||||||
if (event->ref) {
|
if (event->ref) {
|
||||||
event = NULL;
|
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
list_del(&event->list);
|
ret = unregister_synth_event(event);
|
||||||
goto out;
|
if (!ret) {
|
||||||
}
|
list_del(&event->list);
|
||||||
event = NULL;
|
free_synth_event(event);
|
||||||
ret = -EEXIST;
|
}
|
||||||
|
} else
|
||||||
|
ret = -EEXIST;
|
||||||
goto out;
|
goto out;
|
||||||
} else if (delete_event) {
|
} else if (delete_event) {
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
|
@ -1100,29 +1089,21 @@ static int create_synth_event(int argc, char **argv)
|
||||||
event = NULL;
|
event = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
ret = register_synth_event(event);
|
||||||
|
if (!ret)
|
||||||
|
list_add(&event->list, &synth_event_list);
|
||||||
|
else
|
||||||
|
free_synth_event(event);
|
||||||
out:
|
out:
|
||||||
if (event) {
|
|
||||||
if (delete_event) {
|
|
||||||
ret = unregister_synth_event(event);
|
|
||||||
add_or_delete_synth_event(event, !ret);
|
|
||||||
} else {
|
|
||||||
ret = register_synth_event(event);
|
|
||||||
add_or_delete_synth_event(event, ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mutex_unlock(&synth_event_mutex);
|
mutex_unlock(&synth_event_mutex);
|
||||||
mutex_unlock(&event_mutex);
|
mutex_unlock(&event_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
err:
|
err:
|
||||||
mutex_unlock(&synth_event_mutex);
|
|
||||||
mutex_unlock(&event_mutex);
|
|
||||||
|
|
||||||
for (i = 0; i < n_fields; i++)
|
for (i = 0; i < n_fields; i++)
|
||||||
free_synth_field(fields[i]);
|
free_synth_field(fields[i]);
|
||||||
free_synth_event(event);
|
|
||||||
|
|
||||||
return ret;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int release_all_synth_events(void)
|
static int release_all_synth_events(void)
|
||||||
|
@ -1141,10 +1122,12 @@ static int release_all_synth_events(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry_safe(event, e, &synth_event_list, list) {
|
list_for_each_entry_safe(event, e, &synth_event_list, list) {
|
||||||
list_del(&event->list);
|
|
||||||
|
|
||||||
ret = unregister_synth_event(event);
|
ret = unregister_synth_event(event);
|
||||||
add_or_delete_synth_event(event, !ret);
|
if (!ret) {
|
||||||
|
list_del(&event->list);
|
||||||
|
free_synth_event(event);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
mutex_unlock(&synth_event_mutex);
|
mutex_unlock(&synth_event_mutex);
|
||||||
mutex_unlock(&event_mutex);
|
mutex_unlock(&event_mutex);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче