perf stat: Use affinity for opening events
Restructure the event opening in perf stat to cycle through the events by CPU after setting affinity to that CPU. This eliminates IPI overhead in the perf API. We have to loop through the CPU in the outter builtin-stat code instead of leaving that to low level functions. It has to change the weak group fallback strategy slightly. Since we cannot easily undo the opens for other CPUs move the weak group retry to a separate loop. Before with a large test case with 94 CPUs: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 42.75 4.050910 67 60046 110 perf_event_open After: 26.86 0.944396 16 58069 110 perf_event_open (the number changes slightly because the weak group retries work differently and the test case relies on weak groups) Committer notes: Added one of the hunks in a patch provided by Andi after I noticed that the "event times" 'perf test' entry was segfaulting. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lore.kernel.org/lkml/20191121001522.180827-10-andi@firstfloor.org Link: http://lore.kernel.org/lkml/20191127232657.GL84886@tassilo.jf.intel.com # Fix Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
e0e6a6ca3a
commit
4804e01116
@@ -94,6 +94,8 @@ struct evsel {
|
||||
struct evsel *metric_leader;
|
||||
bool collect_stat;
|
||||
bool weak_group;
|
||||
bool reset_group;
|
||||
bool errored;
|
||||
bool percore;
|
||||
int cpu_iter;
|
||||
const char *pmu_name;
|
||||
@@ -223,7 +225,8 @@ int evsel__enable(struct evsel *evsel);
|
||||
int evsel__disable(struct evsel *evsel);
|
||||
|
||||
int perf_evsel__open_per_cpu(struct evsel *evsel,
|
||||
struct perf_cpu_map *cpus);
|
||||
struct perf_cpu_map *cpus,
|
||||
int cpu);
|
||||
int perf_evsel__open_per_thread(struct evsel *evsel,
|
||||
struct perf_thread_map *threads);
|
||||
int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
|
||||
|
Reference in New Issue
Block a user