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: <20121027201626.GE1039@krava.redhat.com>
Date:	Sat, 27 Oct 2012 22:16:26 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	linux-kernel@...r.kernel.org, acme@...hat.com,
	peterz@...radead.org, eranian@...gle.com, mingo@...nel.org,
	Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 32/33] perf, tools: Default to cpu// for events v2

On Fri, Oct 26, 2012 at 01:30:14PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@...ux.intel.com>
> 
> When an event fails to parse and it's not in a new style format,
> try to parse it again as a cpu event.
> 
> This allows to use sysfs exported events directly without //, so I can use
> 
> perf record -e tx-aborts ...

hum, seems usefull and hacky ;)

would not work for modifier stuff like:

  tx-aborts:u (not sure if 'u' makes sense for 'tx-aborts'..)

but nevermind, seems like usefull shortcut

> 
> instead of
> 
> perf record -e cpu/tx-aborts/
> 
> v2: Handle multiple events
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
> ---
>  tools/perf/util/parse-events.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 37 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index f800765..ee6a73c 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -768,6 +768,23 @@ int parse_events_name(struct list_head *list, char *name)
>  	return 0;
>  }
>  
> +static void str_append(char **s, int *len, const char *a)
> +{
> +	int olen = *s ? strlen(*s) : 0;
> +	int nlen = olen + strlen(a) + 1;
> +	if (*len < nlen) { 
> +		*len = *len * 2;
> +		if (*len < nlen)
> +			*len = nlen;
> +		*s = realloc(*s, *len);
> +		if (!*s) 

trailing whitespace

> +			exit(ENOMEM);
> +		if (olen == 0)
> +			**s = 0;
> +	}
> +	strcat(*s, a);
> +}
> +
>  static int parse_events__scanner(const char *str, void *data, int start_token)
>  {
>  	YY_BUFFER_STATE buffer;
> @@ -788,6 +805,26 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
>  	parse_events__flush_buffer(buffer, scanner);
>  	parse_events__delete_buffer(buffer, scanner);
>  	parse_events_lex_destroy(scanner);
> +
> +	if (ret && !strchr(str, '/')) {
> +		char *o = strdup(str);
> +		char *s = NULL;
> +		char *t = o;
> +		char *p;
> +		int len = 0;
> +
> +		if (!o)
> +			return ret;
> +		while ((p = strsep(&t, ",")) != NULL) {
> +			if (s)
> +				str_append(&s, &len, ",");
> +			str_append(&s, &len, "cpu/");
> +			str_append(&s, &len, p);
> +			str_append(&s, &len, "/");
> +		}
> +		free(o);
> +		ret = parse_events__scanner(s, data, start_token);

any chance above could be in separated function?

> +	}
>  	return ret;
>  }
>  
> -- 
> 1.7.7.6
> 
--
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