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]
Message-ID: <20191106163350.GL30214@krava>
Date:   Wed, 6 Nov 2019 17:33:50 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Andi Kleen <andi@...stfloor.org>
Cc:     acme@...nel.org, jolsa@...nel.org, linux-kernel@...r.kernel.org,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v4 5/9] perf stat: Use affinity for closing file
 descriptors

On Mon, Nov 04, 2019 at 04:25:18PM -0800, Andi Kleen wrote:

SNIP

> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index dccf96e0d01b..8f3bfbe277b5 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"
> @@ -1165,9 +1166,33 @@ void perf_evlist__set_selected(struct evlist *evlist,
>  void evlist__close(struct evlist *evlist)
>  {
>  	struct evsel *evsel;
> +	struct affinity affinity;
> +	int cpu, i;
>  
> -	evlist__for_each_entry_reverse(evlist, evsel)
> -		evsel__close(evsel);
> +	if (!evlist->core.cpus) {
> +		evlist__for_each_entry_reverse(evlist, evsel)
> +			evsel__close(evsel);
> +		return;
> +	}
> +
> +	if (affinity__setup(&affinity) < 0)
> +		return;
> +	evlist__cpu_iter_start(evlist);
> +	evlist__for_each_cpu (evlist, i, cpu) {
> +		affinity__set(&affinity, cpu);
> +
> +		evlist__for_each_entry_reverse(evlist, evsel) {
> +			if (evlist__cpu_iter_skip(evsel, cpu))
> +			    continue;
> +			perf_evsel__close_cpu(&evsel->core, evsel->cpu_index);
> +			evlist__cpu_iter_next(evsel);
> +		}
> +	}

looks much better, how about we make it even more compact
from above patern, like:

	affinity__setup

	evlist__cpu_iter(evlist, i, cpu) {
		affinity__set(&affinity, cpu);

		evlist__for_each_entry_reverse(evlist, evsel) {
			if (evsel__cpu_iter_skip(evsel, cpu))
				continue;
			perf_evsel__close_cpu(&evsel->core, evsel->cpu_iter);
		}
	}

	affinity__cleanup

where:
  - evlist__cpu_iter would call evlist__cpu_iter_start

  - evlist__cpu_iter_skip could increment evsel->cpu_index in false case
    so there's no need to have evlist__cpu_iter_next

  - rename evsel->cpu_index to evsel->cpu_iter

  - renamse evlist__cpu_iter_skip to evsel__cpu_iter_skip

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ