Re: [PATCH v3 4/7] perf stat: Use affinity for closing file descriptors
From: Jiri Olsa
Date: Wed Oct 30 2019 - 06:06:03 EST
On Fri, Oct 25, 2019 at 11:14:14AM -0700, Andi Kleen wrote:
SNIP
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index da3c8f8ef68e..aeb82de36043 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -18,6 +18,7 @@
> #include "debug.h"
> #include "units.h"
> #include <internal/lib.h> // page_size
> +#include "affinity.h"
> #include "../perf.h"
> #include "asm/bug.h"
> #include "bpf-event.h"
> @@ -1170,9 +1171,33 @@ void perf_evlist__set_selected(struct evlist *evlist,
> void evlist__close(struct evlist *evlist)
> {
> struct evsel *evsel;
> + struct affinity affinity;
> + struct perf_cpu_map *cpus;
> + int i, cpu;
> +
> + if (!evlist->core.cpus) {
> + evlist__for_each_entry_reverse(evlist, evsel)
> + evsel__close(evsel);
> + return;
> + }
>
> - evlist__for_each_entry_reverse(evlist, evsel)
> - evsel__close(evsel);
> + if (affinity__setup(&affinity) < 0)
> + return;
> + cpus = evlist__cpu_iter_start(evlist);
> + cpumap__for_each_cpu (cpus, i, cpu) {
> + affinity__set(&affinity, cpu);
whats the point of affinity->changed flags when we call
affinity__set unconditionaly? I think we can do without
it, becase we'll always endup calling affinity__set
also here you're missing affinity__cleanup call in here
however, it seems superfluous to always allocate those
bitmaps, while we need just the current cpus that we
run on and also that is probably questionable
could we put 'struct affinity' to 'struct evlist'
and get rid of all affinity__setup/cleanup calls?
(apart from those in evlist__init and evlist__delete)
thanks,
jirka