Skip to content

Commit 1cffbe6

Browse files
valschneiderrostedt
authored andcommitted
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/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Daniel Bristot de Oliveira <[email protected]> Cc: Marcelo Tosatti <[email protected]> Cc: Leonardo Bras <[email protected]> Cc: Frederic Weisbecker <[email protected]> Suggested-by: Steven Rostedt <[email protected]> Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent ca77dd8 commit 1cffbe6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ static int parse_pred(const char *str, void *data,
17501750
* then we can treat it as a scalar input.
17511751
*/
17521752
single = cpumask_weight(pred->mask) == 1;
1753-
if (single && field->filter_type != FILTER_CPU) {
1753+
if (single) {
17541754
pred->val = cpumask_first(pred->mask);
17551755
kfree(pred->mask);
17561756
}
@@ -1760,7 +1760,12 @@ static int parse_pred(const char *str, void *data,
17601760
FILTER_PRED_FN_CPUMASK_CPU :
17611761
FILTER_PRED_FN_CPUMASK;
17621762
} else if (field->filter_type == FILTER_CPU) {
1763-
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
1763+
if (single) {
1764+
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
1765+
pred->fn_num = FILTER_PRED_FN_CPU;
1766+
} else {
1767+
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
1768+
}
17641769
} else if (single) {
17651770
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
17661771
pred->fn_num = select_comparison_fn(pred->op, field->size, false);

0 commit comments

Comments
 (0)