Skip to content

Commit ca77dd8

Browse files
valschneiderrostedt
authored andcommitted
tracing/filters: Optimise scalar 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. When the mask contains a single CPU, directly re-use the unsigned field predicate functions. Transform '&' into '==' beforehand. 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 fe4fa4e commit ca77dd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 6 additions & 1 deletion
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_CPUMASK) {
1753+
if (single && field->filter_type != FILTER_CPU) {
17541754
pred->val = cpumask_first(pred->mask);
17551755
kfree(pred->mask);
17561756
}
@@ -1761,6 +1761,11 @@ static int parse_pred(const char *str, void *data,
17611761
FILTER_PRED_FN_CPUMASK;
17621762
} else if (field->filter_type == FILTER_CPU) {
17631763
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
1764+
} else if (single) {
1765+
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
1766+
pred->fn_num = select_comparison_fn(pred->op, field->size, false);
1767+
if (pred->op == OP_NE)
1768+
pred->not = 1;
17641769
} else {
17651770
switch (field->size) {
17661771
case 8:

0 commit comments

Comments
 (0)