[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160304214848.GY3604@kernel.org>
Date: Fri, 4 Mar 2016 18:48:48 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Jiri Olsa <jolsa@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <andi@...stfloor.org>,
Stephane Eranian <eranian@...gle.com>,
Wang Nan <wangnan0@...wei.com>
Subject: Re: [PATCH v2 4/8] perf tools: Support multiple sort keys in a
hierarchy level
Em Fri, Mar 04, 2016 at 11:59:38PM +0900, Namhyung Kim escreveu:
> This implements having multiple sort keys in a single hierarchy level.
> +++ b/tools/perf/util/sort.c
> @@ -2310,18 +2310,40 @@ static int setup_sort_list(char *str, struct perf_evlist *evlist)
> char *tmp, *tok;
> int ret = 0;
> int level = 0;
> + int next_level = 1;
> + bool in_group = false;
> +
> + do {
> + tok = str;
> + tmp = strpbrk(str, "{}, ");
Ok, I'll test this, but since we use lex/yacc for parsing event
descriptions, perhaps we should use it here as well? Or do you think
we're stopping at this level of complexity (I doubt) :-)
> + if (tmp) {
> + if (in_group)
> + next_level = level;
> + else
> + next_level = level + 1;
> +
> + if (*tmp == '{')
> + in_group = true;
> + else if (*tmp == '}')
> + in_group = false;
> +
> + *tmp = '\0';
> + str = tmp + 1;
> + }
>
> - for (tok = strtok_r(str, ", ", &tmp);
> - tok; tok = strtok_r(NULL, ", ", &tmp)) {
> - ret = sort_dimension__add(tok, evlist, level++);
> - if (ret == -EINVAL) {
> - error("Invalid --sort key: `%s'", tok);
> - break;
> - } else if (ret == -ESRCH) {
> - error("Unknown --sort key: `%s'", tok);
> - break;
> + if (*tok) {
> + ret = sort_dimension__add(tok, evlist, level);
> + if (ret == -EINVAL) {
> + error("Invalid --sort key: `%s'", tok);
> + break;
> + } else if (ret == -ESRCH) {
> + error("Unknown --sort key: `%s'", tok);
> + break;
> + }
> }
> - }
> +
> + level = next_level;
> + } while (tmp);
>
> return ret;
> }
> --
> 2.7.2
Powered by blists - more mailing lists