lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 23 Oct 2019 06:07:13 -0700
From:   Andi Kleen <ak@...ux.intel.com>
To:     Jiri Olsa <jolsa@...hat.com>
Cc:     Andi Kleen <andi@...stfloor.org>, acme@...nel.org,
        linux-kernel@...r.kernel.org, jolsa@...nel.org, eranian@...gle.com,
        kan.liang@...ux.intel.com, peterz@...radead.org
Subject: Re: [PATCH v2 9/9] perf stat: Use affinity for enabling/disabling
 events

On Wed, Oct 23, 2019 at 12:30:48PM +0200, Jiri Olsa wrote:
> On Sun, Oct 20, 2019 at 10:52:02AM -0700, Andi Kleen wrote:
> 
> SNIP
> 
> >  
> >  void evlist__enable(struct evlist *evlist)
> >  {
> >  	struct evsel *pos;
> > +	struct affinity affinity;
> > +	struct perf_cpu_map *cpus;
> > +	int i;
> > +
> > +	if (affinity__setup(&affinity) < 0)
> > +		return;
> > +
> > +	cpus = evlist__cpu_iter_start(evlist);
> > +	for (i = 0; i < cpus->nr; i++) {
> > +		int cpu = cpus->map[i];
> > +		affinity__set(&affinity, cpu);
> >  
> > +		evlist__for_each_entry(evlist, pos) {
> > +			if (evlist__cpu_iter_skip(pos, cpu))
> > +				continue;
> > +			if (!perf_evsel__is_group_leader(pos) || !pos->core.fd)
> > +				continue;
> 
> all the previous patches and this one have this code in common,
> could we make this a single function, that would call a callback
> that would have affinity set.. sort of like what we do in 
> cpu_function_call in the kernel

I'm personally not a big friend of call backs. They usually make
the code harder to read and reason about. 

Prefer to use callable libraries of common code.

Also the event open code has some more complex variants of this pattern
which would need multiple call backs.

I already factored the common code into the iterator.

I guess the for loop could be a macro, and affinity_set() could
perhaps accept the map and return the cpu. I'll add that in
the next version. This will reduce the common code by a few lines
more.

-Andi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ