In gtrace_setup_aux(), remember the sink found for the first CPU and pass it to gtrace_create_path() for the remaining CPUs so they share a compatible default sink. Clear a CPU from the mask when no path can be built for it and abort when no sink is reachable at all. --- drivers/hwtracing/gtrace/gtrace-perf.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/gtrace/gtrace-perf.c b/drivers/hwtracing/gtrace/gtrace-perf.c index 3c8b620df5a8..9b874daa807f 100644 --- a/drivers/hwtracing/gtrace/gtrace-perf.c +++ b/drivers/hwtracing/gtrace/gtrace-perf.c @@ -109,6 +109,7 @@ static void *gtrace_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { struct gtrace_event_data *event_data = NULL; + struct gtrace_component *sink = NULL; struct page **pagelist; int cpu = event->cpu, i; cpumask_t *mask; @@ -120,7 +121,7 @@ static void *gtrace_setup_aux(struct perf_event *event, void **pages, INIT_WORK(&event_data->work, free_event_data); mask = &event_data->mask; /* - * Create the path for each CPU in the mask. In case of any failure skip the CPU + * Create the path for each CPU in the mask. In case of any failure clear the CPU */ for_each_cpu(cpu, mask) { struct gtrace_component *src; @@ -132,16 +133,28 @@ static void *gtrace_setup_aux(struct perf_event *event, void **pages, continue; }
- path = gtrace_create_path(src, NULL, GTRACE_COMPONENT_MODE_PERF); + path = gtrace_create_path(src, sink, GTRACE_COMPONENT_MODE_PERF); if (IS_ERR(path)) { cpumask_clear_cpu(cpu, mask); continue; }
+ /* + * The first found sink is saved here and passed to + * gtrace_create_path() to check whether the remaining sources + * have a compatible default sink. + */ + if (!sink) + sink = gtrace_path_sink(path); + path->event = event; *gtrace_event_cpu_path_ptr(event_data, cpu) = path; }
+ /* no sink found for any CPU - cannot trace */ + if (!sink) + goto err; + /* If we don't have any CPUs ready for tracing, abort */ cpu = cpumask_first(&event_data->mask); if (cpu >= nr_cpu_ids)