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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1246167089.4497.8.camel@hpdv5.satnam>
Date:	Sun, 28 Jun 2009 11:01:29 +0530
From:	Jaswinder Singh Rajput <jaswinder@...nel.org>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -tip] perf stat: memcpy is only required if no event is
 selected and !null_run

If You want can also add Impact Line.

Impact: Speedup, reduce binary size.


On Sat, 2009-06-27 at 23:49 +0530, Jaswinder Singh Rajput wrote:
> Set attrs and nr_counters if no event is selected and !null_run
> 
> Setting of attrs should depend on number of counters,
> so we need to memcpy only for sizeof(default_attrs)
> 
> and set nr_counters as ARRAY_SIZE(default_attrs) in place of hardcoded value
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@...il.com>
> ---
>  tools/perf/builtin-stat.c |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 3840a70..3e5ea4e 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -46,7 +46,7 @@
>  #include <sys/prctl.h>
>  #include <math.h>
>  
> -static struct perf_counter_attr default_attrs[MAX_COUNTERS] = {
> +static struct perf_counter_attr default_attrs[] = {
>  
>    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK	},
>    { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES},
> @@ -477,16 +477,17 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
>  {
>  	int status;
>  
> -	memcpy(attrs, default_attrs, sizeof(attrs));
> -
>  	argc = parse_options(argc, argv, options, stat_usage, 0);
>  	if (!argc)
>  		usage_with_options(stat_usage, options);
>  	if (run_count <= 0 || run_count > MAX_RUN)
>  		usage_with_options(stat_usage, options);
>  
> -	if (!null_run && !nr_counters)
> -		nr_counters = 8;
> +	/* Set attrs and nr_counters if no event is selected and !null_run */
> +	if (!null_run && !nr_counters) {
> +		memcpy(attrs, default_attrs, sizeof(default_attrs));
> +		nr_counters = ARRAY_SIZE(default_attrs);
> +	}
>  
>  	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
>  	assert(nr_cpus <= MAX_NR_CPUS);

--
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