Skip to content

Commit f8b61bd

Browse files
liu-song-6acmel
authored andcommitted
perf stat: Skip evlist__[enable|disable] when all events uses BPF
When all events of a perf-stat session use BPF, it is not necessary to call evlist__enable() and evlist__disable(). Skip them when all_counters_use_bpf is true. Signed-off-by: Song Liu <song@kernel.org> Reported-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f42907e commit f8b61bd

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎tools/perf/builtin-stat.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ static int enable_counters(void)
572572
* - we have initial delay configured
573573
*/
574574
if (!target__none(&target) || stat_config.initial_delay) {
575-
evlist__enable(evsel_list);
575+
if (!all_counters_use_bpf)
576+
evlist__enable(evsel_list);
576577
if (stat_config.initial_delay > 0)
577578
pr_info(EVLIST_ENABLED_MSG);
578579
}
@@ -581,13 +582,19 @@ static int enable_counters(void)
581582

582583
static void disable_counters(void)
583584
{
585+
struct evsel *counter;
586+
584587
/*
585588
* If we don't have tracee (attaching to task or cpu), counters may
586589
* still be running. To get accurate group ratios, we must stop groups
587590
* from counting before reading their constituent counters.
588591
*/
589-
if (!target__none(&target))
590-
evlist__disable(evsel_list);
592+
if (!target__none(&target)) {
593+
evlist__for_each_entry(evsel_list, counter)
594+
bpf_counter__disable(counter);
595+
if (!all_counters_use_bpf)
596+
evlist__disable(evsel_list);
597+
}
591598
}
592599

593600
static volatile int workload_exec_errno;

‎tools/perf/util/evlist.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
425425
if (affinity__setup(&affinity) < 0)
426426
return;
427427

428-
evlist__for_each_entry(evlist, pos)
429-
bpf_counter__disable(pos);
430-
431428
/* Disable 'immediate' events last */
432429
for (imm = 0; imm <= 1; imm++) {
433430
evlist__for_each_cpu(evlist, i, cpu) {

0 commit comments

Comments
 (0)