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:	Tue, 30 Jun 2015 14:14:28 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	kan.liang@...el.com
Cc:	acme@...nel.org, jolsa@...nel.org, ak@...ux.intel.com,
	namhyung@...nel.org, eranian@...gle.com, adrian.hunter@...el.com,
	dsahern@...il.com, a.p.zijlstra@...llo.nl, mingo@...hat.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] perf,tools: check and re-organize evsel cpu maps

On Mon, Jun 29, 2015 at 03:55:35PM -0400, kan.liang@...el.com wrote:

SNIP

> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 6cfdee6..f179379 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -1101,6 +1101,71 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
>  	return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
>  }
>  
> +static int cmp_ids(const void *a, const void *b)
> +{
> +	return *(int *)a - *(int *)b;
> +}
> +
> +static int perf_evlist__check_evsel_cpus(struct perf_evlist *evlist, struct perf_evsel *evsel)
> +{
> +	const struct cpu_map *cpus = evlist->cpus;
> +	const int ncpus = cpu_map__nr(evlist->cpus);
> +	int j = 0, cpu_nr = 0, tmp = 0;
> +	int i;
> +
> +	/* ensure we process id in increasing order */
> +	qsort(evlist->cpus->map, evlist->cpus->nr, sizeof(int), cmp_ids);

wouldn't sorting maps affect some other code?

> +
> +	/* find the common cpus between evsel and evlist. */
> +	for (i = 0; i < cpu_map__nr(evsel->cpus);)  {
> +
> +		if (j >= ncpus) {
> +			evsel->cpus->map[i++] = -1;
> +			continue;
> +		}
> +		for (; j < ncpus; j++) {
> +			if (cpus->map[j] < evsel->cpus->map[i])
> +				continue;
> +			if (cpus->map[j] == evsel->cpus->map[i]) {
> +				cpu_nr++;
> +				j++;

hum, do you skip 1 item in cpus by j++ here and in for loop header?

also some easy it'd be easier to read if you identify different cpu
maps somehow.. like evlist_cpus and evsel_cpus or such

I have no way of testing this.. could you please add automated test for this one?

thanks,
jirka

> +				i++;
> +			} else
> +				evsel->cpus->map[i++] = -1;
> +			break;
> +		}
> +	}
> +

SNIP
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ