mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-03 08:06:42 +07:00
tracing/filters: Refactor subsystem filter code
Change: for_each_pred for_each_subsystem To: for_each_subsystem for_each_pred This change also prepares for later patches. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <4AD69502.8060903@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
713490e02e
commit
fce29d15b5
@ -683,7 +683,6 @@ struct event_filter {
|
|||||||
int n_preds;
|
int n_preds;
|
||||||
struct filter_pred **preds;
|
struct filter_pred **preds;
|
||||||
char *filter_string;
|
char *filter_string;
|
||||||
bool no_reset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct event_subsystem {
|
struct event_subsystem {
|
||||||
|
@ -615,14 +615,7 @@ static int init_subsystem_preds(struct event_subsystem *system)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
static void filter_free_subsystem_preds(struct event_subsystem *system)
|
||||||
FILTER_DISABLE_ALL,
|
|
||||||
FILTER_INIT_NO_RESET,
|
|
||||||
FILTER_SKIP_NO_RESET,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void filter_free_subsystem_preds(struct event_subsystem *system,
|
|
||||||
int flag)
|
|
||||||
{
|
{
|
||||||
struct ftrace_event_call *call;
|
struct ftrace_event_call *call;
|
||||||
|
|
||||||
@ -633,14 +626,6 @@ static void filter_free_subsystem_preds(struct event_subsystem *system,
|
|||||||
if (strcmp(call->system, system->name) != 0)
|
if (strcmp(call->system, system->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (flag == FILTER_INIT_NO_RESET) {
|
|
||||||
call->filter->no_reset = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag == FILTER_SKIP_NO_RESET && call->filter->no_reset)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
filter_disable_preds(call);
|
filter_disable_preds(call);
|
||||||
remove_filter_string(call->filter);
|
remove_filter_string(call->filter);
|
||||||
}
|
}
|
||||||
@ -817,44 +802,6 @@ static int filter_add_pred(struct filter_parse_state *ps,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_add_subsystem_pred(struct filter_parse_state *ps,
|
|
||||||
struct event_subsystem *system,
|
|
||||||
struct filter_pred *pred,
|
|
||||||
char *filter_string,
|
|
||||||
bool dry_run)
|
|
||||||
{
|
|
||||||
struct ftrace_event_call *call;
|
|
||||||
int err = 0;
|
|
||||||
bool fail = true;
|
|
||||||
|
|
||||||
list_for_each_entry(call, &ftrace_events, list) {
|
|
||||||
|
|
||||||
if (!call->define_fields)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strcmp(call->system, system->name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (call->filter->no_reset)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
err = filter_add_pred(ps, call, pred, dry_run);
|
|
||||||
if (err)
|
|
||||||
call->filter->no_reset = true;
|
|
||||||
else
|
|
||||||
fail = false;
|
|
||||||
|
|
||||||
if (!dry_run)
|
|
||||||
replace_filter_string(call->filter, filter_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fail) {
|
|
||||||
parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void parse_init(struct filter_parse_state *ps,
|
static void parse_init(struct filter_parse_state *ps,
|
||||||
struct filter_op *ops,
|
struct filter_op *ops,
|
||||||
char *infix_string)
|
char *infix_string)
|
||||||
@ -1209,8 +1156,7 @@ static int check_preds(struct filter_parse_state *ps)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int replace_preds(struct event_subsystem *system,
|
static int replace_preds(struct ftrace_event_call *call,
|
||||||
struct ftrace_event_call *call,
|
|
||||||
struct filter_parse_state *ps,
|
struct filter_parse_state *ps,
|
||||||
char *filter_string,
|
char *filter_string,
|
||||||
bool dry_run)
|
bool dry_run)
|
||||||
@ -1257,11 +1203,7 @@ static int replace_preds(struct event_subsystem *system,
|
|||||||
add_pred:
|
add_pred:
|
||||||
if (!pred)
|
if (!pred)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (call)
|
err = filter_add_pred(ps, call, pred, dry_run);
|
||||||
err = filter_add_pred(ps, call, pred, false);
|
|
||||||
else
|
|
||||||
err = filter_add_subsystem_pred(ps, system, pred,
|
|
||||||
filter_string, dry_run);
|
|
||||||
filter_free_pred(pred);
|
filter_free_pred(pred);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
@ -1272,6 +1214,44 @@ static int replace_preds(struct event_subsystem *system,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int replace_system_preds(struct event_subsystem *system,
|
||||||
|
struct filter_parse_state *ps,
|
||||||
|
char *filter_string)
|
||||||
|
{
|
||||||
|
struct ftrace_event_call *call;
|
||||||
|
int err;
|
||||||
|
bool fail = true;
|
||||||
|
|
||||||
|
list_for_each_entry(call, &ftrace_events, list) {
|
||||||
|
|
||||||
|
if (!call->define_fields)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(call->system, system->name) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* try to see if the filter can be applied */
|
||||||
|
err = replace_preds(call, ps, filter_string, true);
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* really apply the filter */
|
||||||
|
filter_disable_preds(call);
|
||||||
|
err = replace_preds(call, ps, filter_string, false);
|
||||||
|
if (err)
|
||||||
|
filter_disable_preds(call);
|
||||||
|
else
|
||||||
|
replace_filter_string(call->filter, filter_string);
|
||||||
|
fail = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fail) {
|
||||||
|
parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
|
int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -1306,7 +1286,7 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = replace_preds(NULL, call, ps, filter_string, false);
|
err = replace_preds(call, ps, filter_string, false);
|
||||||
if (err)
|
if (err)
|
||||||
append_filter_err(ps, call->filter);
|
append_filter_err(ps, call->filter);
|
||||||
|
|
||||||
@ -1334,7 +1314,7 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
|
|||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
if (!strcmp(strstrip(filter_string), "0")) {
|
if (!strcmp(strstrip(filter_string), "0")) {
|
||||||
filter_free_subsystem_preds(system, FILTER_DISABLE_ALL);
|
filter_free_subsystem_preds(system);
|
||||||
remove_filter_string(system->filter);
|
remove_filter_string(system->filter);
|
||||||
mutex_unlock(&event_mutex);
|
mutex_unlock(&event_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1354,23 +1334,9 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_free_subsystem_preds(system, FILTER_INIT_NO_RESET);
|
err = replace_system_preds(system, ps, filter_string);
|
||||||
|
if (err)
|
||||||
/* try to see the filter can be applied to which events */
|
|
||||||
err = replace_preds(system, NULL, ps, filter_string, true);
|
|
||||||
if (err) {
|
|
||||||
append_filter_err(ps, system->filter);
|
append_filter_err(ps, system->filter);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
filter_free_subsystem_preds(system, FILTER_SKIP_NO_RESET);
|
|
||||||
|
|
||||||
/* really apply the filter to the events */
|
|
||||||
err = replace_preds(system, NULL, ps, filter_string, false);
|
|
||||||
if (err) {
|
|
||||||
append_filter_err(ps, system->filter);
|
|
||||||
filter_free_subsystem_preds(system, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
filter_opstack_clear(ps);
|
filter_opstack_clear(ps);
|
||||||
|
Loading…
Reference in New Issue
Block a user