[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121128155313.GF1038@krava.brq.redhat.com>
Date: Wed, 28 Nov 2012 16:53:13 +0100
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,
namhyung@...nel.org, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 31/32] perf, tools: Default to cpu// for events v3
On Fri, Nov 09, 2012 at 05:27:47PM -0800, 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 ...
>
> instead of
>
> perf record -e cpu/tx-aborts/
>
> v2: Handle multiple events
> v3: Move to separate function
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
> ---
> tools/perf/util/parse-events.c | 45 +++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 44 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 5b97a2b..70cbd1c 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -768,6 +768,47 @@ 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)
> + exit(ENOMEM);
Rather use BUG_ON or event better return -ENOMEM.
> + if (olen == 0)
> + **s = 0;
> + }
> + strcat(*s, a);
> +}
Could this one be moved to util/string.c in some generic form?
thanks,
jirka
--
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