Skip to content

Commit 38c6f68

Browse files
valschneiderrostedt
authored andcommitted
tracing/filters: Further optimise scalar vs cpumask comparison
Per the previous commits, we now only enter do_filter_scalar_cpumask() with a mask of weight greater than one. Optimise the equality checks. 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 1cffbe6 commit 38c6f68

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,25 @@ do_filter_cpumask(int op, const struct cpumask *mask, const struct cpumask *cmp)
667667
/* Optimisation of do_filter_cpumask() for scalar fields */
668668
static inline int
669669
do_filter_scalar_cpumask(int op, unsigned int cpu, const struct cpumask *mask)
670+
{
671+
/*
672+
* Per the weight-of-one cpumask optimisations, the mask passed in this
673+
* function has a weight >= 2, so it is never equal to a single scalar.
674+
*/
675+
switch (op) {
676+
case OP_EQ:
677+
return false;
678+
case OP_NE:
679+
return true;
680+
case OP_BAND:
681+
return cpumask_test_cpu(cpu, mask);
682+
default:
683+
return 0;
684+
}
685+
}
686+
687+
static inline int
688+
do_filter_cpumask_scalar(int op, const struct cpumask *mask, unsigned int cpu)
670689
{
671690
switch (op) {
672691
case OP_EQ:
@@ -966,12 +985,7 @@ static int filter_pred_cpumask_cpu(struct filter_pred *pred, void *event)
966985
const struct cpumask *mask = (event + loc);
967986
unsigned int cpu = pred->val;
968987

969-
/*
970-
* This inverts the usual usage of the function (field is first element,
971-
* user parameter is second), but that's fine because the (scalar, mask)
972-
* operations used are symmetric.
973-
*/
974-
return do_filter_scalar_cpumask(pred->op, cpu, mask);
988+
return do_filter_cpumask_scalar(pred->op, mask, cpu);
975989
}
976990

977991
/* Filter predicate for COMM. */

0 commit comments

Comments
 (0)