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: <20200522095314.GD264196@krava>
Date:   Fri, 22 May 2020 11:53:14 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Jin Yao <yao.jin@...ux.intel.com>
Cc:     acme@...nel.org, jolsa@...nel.org, peterz@...radead.org,
        mingo@...hat.com, alexander.shishkin@...ux.intel.com,
        Linux-kernel@...r.kernel.org, ak@...ux.intel.com,
        kan.liang@...el.com, yao.jin@...el.com
Subject: Re: [PATCH] perf evlist: Ensure grouped events with same cpu map

On Thu, May 21, 2020 at 02:22:40PM +0800, Jin Yao wrote:

SNIP

> ---
>  tools/perf/builtin-stat.c |  3 +++
>  tools/perf/util/evlist.c  | 32 ++++++++++++++++++++++++++++++++
>  tools/perf/util/evlist.h  |  5 +++++
>  3 files changed, 40 insertions(+)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 377e575f9645..0e4fc6b3323c 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -584,6 +584,9 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
>  	if (affinity__setup(&affinity) < 0)
>  		return -1;
>  
> +	if (!evlist__cpus_matched(evsel_list))
> +		evlist__force_disable_group(evsel_list);
> +
>  	evlist__for_each_cpu (evsel_list, i, cpu) {
>  		affinity__set(&affinity, cpu);
>  
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index 2a9de6491700..fc6e410ca63b 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -1704,3 +1704,35 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,
>  	}
>  	return leader;
>  }
> +
> +bool evlist__cpus_matched(struct evlist *evlist)
> +{
> +	struct evsel *prev = evlist__first(evlist), *evsel = prev;
> +
> +	if (prev->core.nr_members <= 1)
> +		return true;

hum, this assumes there's only one group in evlist?

how about case like A,{B,C},D,{E,F}

also please add automated tests for this

> +
> +	evlist__for_each_entry_continue(evlist, evsel) {
> +		if (evsel->core.cpus->nr != prev->core.cpus->nr)
> +			return false;
> +
> +		for (int i = 0; i < evsel->core.cpus->nr; i++) {
> +			if (evsel->core.cpus->map[i] != prev->core.cpus->map[i])
> +				return false;
> +		}
> +
> +		prev = evsel;
> +	}
> +
> +	return true;
> +}
> +
> +void evlist__force_disable_group(struct evlist *evlist)
> +{
> +	struct evsel *evsel;

we need to put some warning for user in here

thanks,
jirka

> +
> +	evlist__for_each_entry(evlist, evsel) {
> +		evsel->leader = evsel;
> +		evsel->core.nr_members = 0;
> +	}
> +}
> diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
> index b6f325dfb4d2..ea7a53166cbd 100644
> --- a/tools/perf/util/evlist.h
> +++ b/tools/perf/util/evlist.h
> @@ -355,4 +355,9 @@ void perf_evlist__force_leader(struct evlist *evlist);
>  struct evsel *perf_evlist__reset_weak_group(struct evlist *evlist,
>  						 struct evsel *evsel,
>  						bool close);
> +
> +bool evlist__cpus_matched(struct evlist *evlist);
> +
> +void evlist__force_disable_group(struct evlist *evlist);
> +
>  #endif /* __PERF_EVLIST_H */
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ