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: <20180129072905.GA8162@krava>
Date:   Mon, 29 Jan 2018 08:29:05 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     ufo19890607 <ufo19890607@...il.com>
Cc:     peterz@...radead.org, mingo@...hat.com,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        dsahern@...il.com, namhyung@...nel.org, milian.wolff@...b.com,
        arnaldo.melo@...il.com, yuzhoujian@...ichuxing.com,
        adrian.hunter@...el.com, wangnan0@...wei.com, Kan.liang@...el.com,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        acme@...hat.com
Subject: Re: [PATCH v3 1/2] perf stat: Add support to print counts for fixed
 times

On Fri, Jan 26, 2018 at 10:06:56AM +0100, ufo19890607 wrote:

SNIP

> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -168,6 +168,7 @@ static struct timespec		ref_time;
>  static struct cpu_map		*aggr_map;
>  static aggr_get_id_t		aggr_get_id;
>  static bool			append_file;
> +static bool			interval_count;
>  static const char		*output_name;
>  static int			output_fd;
>  static int			print_free_counters_hint;
> @@ -571,6 +572,7 @@ static struct perf_evsel *perf_evsel__reset_weak_group(struct perf_evsel *evsel)
>  static int __run_perf_stat(int argc, const char **argv)
>  {
>  	int interval = stat_config.interval;
> +	int times = stat_config.times;
>  	char msg[BUFSIZ];
>  	unsigned long long t0, t1;
>  	struct perf_evsel *counter;
> @@ -700,6 +702,10 @@ static int __run_perf_stat(int argc, const char **argv)
>  			while (!waitpid(child_pid, &status, WNOHANG)) {
>  				nanosleep(&ts, NULL);
>  				process_interval();
> +				if (interval_count == true) {
> +					if (--times == 0)
> +						break;

why not single line in here?

if (interval_count && !(--times))

> +				}
>  			}
>  		}
>  		waitpid(child_pid, &status, 0);
> @@ -716,8 +722,13 @@ static int __run_perf_stat(int argc, const char **argv)
>  		enable_counters();
>  		while (!done) {
>  			nanosleep(&ts, NULL);
> -			if (interval)
> +			if (interval) {
>  				process_interval();
> +				if (interval_count == true) {
> +					if (--times == 0)
> +						break;

same here

SNIP

>  	}
> +	if (times && interval)
> +		interval_count = true;
> +	else if (times && !interval) {
> +		pr_err("interval-count option should be used together with "
> +				"interval-print.\n");
> +		parse_options_usage(stat_usage, stat_options, "interval-count", 0);
> +		parse_options_usage(stat_usage, stat_options, "I", 1);
> +		goto out;
> +	}
>  
>  	if (perf_evlist__alloc_stats(evsel_list, interval))
>  		goto out;
> diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
> index dbc6f7134f61..b2f8a347d358 100644
> --- a/tools/perf/util/stat.h
> +++ b/tools/perf/util/stat.h
> @@ -90,6 +90,7 @@ struct perf_stat_config {
>  	bool		scale;
>  	FILE		*output;
>  	unsigned int	interval;
> +	int				times;

wrong indent

thanks,
jirka

>  	struct runtime_stat *stats;
>  	int		stats_num;
>  };
> -- 
> 2.14.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ