Skip to content

Commit 347d24f

Browse files
valschneiderrostedt
authored andcommitted
tracing/filters: Enable filtering the CPU common field by a cpumask
The tracing_cpumask lets us specify which CPUs are traced in a buffer instance, but doesn't let us do this on a per-event basis (unless one creates an instance per event). A previous commit added filtering scalar fields by a user-given cpumask, make this work with the CPU common field as well. This enables doing things like $ trace-cmd record -e 'sched_switch' -f 'CPU & CPUS{12-52}' \ -e 'sched_wakeup' -f 'target_cpu & CPUS{12-52}' 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]> Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 3cbec9d commit 347d24f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum filter_pred_fn {
6868
FILTER_PRED_FN_PCHAR_USER,
6969
FILTER_PRED_FN_PCHAR,
7070
FILTER_PRED_FN_CPU,
71+
FILTER_PRED_FN_CPU_CPUMASK,
7172
FILTER_PRED_FN_CPUMASK,
7273
FILTER_PRED_FN_FUNCTION,
7374
FILTER_PRED_FN_,
@@ -937,6 +938,14 @@ static int filter_pred_cpu(struct filter_pred *pred, void *event)
937938
}
938939
}
939940

941+
/* Filter predicate for current CPU vs user-provided cpumask */
942+
static int filter_pred_cpu_cpumask(struct filter_pred *pred, void *event)
943+
{
944+
int cpu = raw_smp_processor_id();
945+
946+
return do_filter_scalar_cpumask(pred->op, cpu, pred->mask);
947+
}
948+
940949
/* Filter predicate for cpumask field vs user-provided cpumask */
941950
static int filter_pred_cpumask(struct filter_pred *pred, void *event)
942951
{
@@ -1440,6 +1449,8 @@ static int filter_pred_fn_call(struct filter_pred *pred, void *event)
14401449
return filter_pred_pchar(pred, event);
14411450
case FILTER_PRED_FN_CPU:
14421451
return filter_pred_cpu(pred, event);
1452+
case FILTER_PRED_FN_CPU_CPUMASK:
1453+
return filter_pred_cpu_cpumask(pred, event);
14431454
case FILTER_PRED_FN_CPUMASK:
14441455
return filter_pred_cpumask(pred, event);
14451456
case FILTER_PRED_FN_FUNCTION:
@@ -1659,6 +1670,7 @@ static int parse_pred(const char *str, void *data,
16591670

16601671
switch (field->filter_type) {
16611672
case FILTER_CPUMASK:
1673+
case FILTER_CPU:
16621674
case FILTER_OTHER:
16631675
break;
16641676
default:
@@ -1714,6 +1726,8 @@ static int parse_pred(const char *str, void *data,
17141726
i++;
17151727
if (field->filter_type == FILTER_CPUMASK) {
17161728
pred->fn_num = FILTER_PRED_FN_CPUMASK;
1729+
} else if (field->filter_type == FILTER_CPU) {
1730+
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
17171731
} else {
17181732
switch (field->size) {
17191733
case 8:

0 commit comments

Comments
 (0)