Commit 1cffbe6c authored by Valentin Schneider's avatar Valentin Schneider Committed by Steven Rostedt (Google)

tracing/filters: Optimise CPU vs cpumask filtering when the user mask is a single CPU

Steven noted that when the user-provided cpumask contains a single CPU,
then the filtering function can use a scalar as input instead of a
full-fledged cpumask.

In this case we can directly re-use filter_pred_cpu(), we just need to
transform '&' into '==' before executing it.

Link: https://lkml.kernel.org/r/20230707172155.70873-8-vschneid@redhat.com

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Leonardo Bras <leobras@redhat.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarValentin Schneider <vschneid@redhat.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent ca77dd8c
...@@ -1750,7 +1750,7 @@ static int parse_pred(const char *str, void *data, ...@@ -1750,7 +1750,7 @@ static int parse_pred(const char *str, void *data,
* then we can treat it as a scalar input. * then we can treat it as a scalar input.
*/ */
single = cpumask_weight(pred->mask) == 1; single = cpumask_weight(pred->mask) == 1;
if (single && field->filter_type != FILTER_CPU) { if (single) {
pred->val = cpumask_first(pred->mask); pred->val = cpumask_first(pred->mask);
kfree(pred->mask); kfree(pred->mask);
} }
...@@ -1760,7 +1760,12 @@ static int parse_pred(const char *str, void *data, ...@@ -1760,7 +1760,12 @@ static int parse_pred(const char *str, void *data,
FILTER_PRED_FN_CPUMASK_CPU : FILTER_PRED_FN_CPUMASK_CPU :
FILTER_PRED_FN_CPUMASK; FILTER_PRED_FN_CPUMASK;
} else if (field->filter_type == FILTER_CPU) { } else if (field->filter_type == FILTER_CPU) {
if (single) {
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
pred->fn_num = FILTER_PRED_FN_CPU;
} else {
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
}
} else if (single) { } else if (single) {
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
pred->fn_num = select_comparison_fn(pred->op, field->size, false); pred->fn_num = select_comparison_fn(pred->op, field->size, false);
......
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